Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3200

Show
Ignore:
Timestamp:
02/16/08 06:38:41 (7 months ago)
Author:
DRK
Message:

This should clean up the warnings from core.Variant, io.archive.Zip, io.TempFile? and io.vfs.ZipFolder?. However, there are still two warnings in io.archive.Zip which do not give file or line numbers. I'll keep trying to track them down. Refs #919.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/core/Variant.d

    r3196 r3200  
    431431            } 
    432432        } 
    433         assert(false); 
    434433    } 
    435434 
  • trunk/tango/io/TempFile.d

    r3197 r3200  
    548548        long seek(long offset, Seek.Anchor anchor = Seek.Anchor.Begin) 
    549549        { 
    550             long result = lseek(handle, offset, anchor); 
     550            assert( offset <= int.sizeof ); 
     551            long result = lseek(handle, cast(int) offset, anchor); 
    551552            if (result is -1) 
    552553                error(); 
  • trunk/tango/io/archive/Zip.d

    r3185 r3200  
    130130        // Update lengths in data 
    131131        Data data = this.data; 
    132         data.file_name_length = file_name.length; 
    133         data.extra_field_length = extra_field.length; 
     132        data.file_name_length = cast(ushort) file_name.length; 
     133        data.extra_field_length = cast(ushort) extra_field.length; 
    134134 
    135135        // Do it 
     
    315315        // Update the lengths 
    316316        Data data = *(this.data); 
    317         data.file_name_length = file_name.length; 
    318         data.extra_field_length = extra_field.length; 
    319        data.file_comment_length = file_comment.length; 
     317        data.file_name_length = cast(ushort) file_name.length; 
     318        data.extra_field_length = cast(ushort) extra_field.length; 
     319        data.file_comment_length = cast(ushort) file_comment.length; 
    320320 
    321321        // Ok; let's do this! 
     
    426426        // Set up data block 
    427427        Data data = this.data; 
    428         data.file_comment_length = file_comment.length; 
     428        data.file_comment_length = cast(ushort) file_comment.length; 
    429429 
    430430        version( BigEndian ) swapAll(data); 
     
    494494            default:    return Method.Unsupported; 
    495495        } 
     496 
     497        assert(false); 
    496498    } 
    497499 
     
    505507                assert(false, "unsupported compression method"); 
    506508        } 
     509 
     510        assert(false); 
    507511    } 
    508512 
     
    666670            case State.Done: 
    667671                return false; 
     672 
     673            default: 
     674                assert(false); 
    668675        } 
     676 
     677        assert(false); 
    669678    } 
    670679 
     
    796805 
    797806            auto used = header.map(cd_data[4..$]); 
    798             cd_data = cd_data[4+used..$]; 
     807            assert( used <= (size_t.max-4) ); 
     808            cd_data = cd_data[4+cast(size_t)used..$]; 
    799809 
    800810            // Update offset for next record 
     
    836846 
    837847        auto file_len = seeker.seek(0, IConduit.Seek.Anchor.End); 
     848        assert( file_len <= size_t.max ); 
    838849 
    839850        // We're going to need min(max_chunk_len, file_len) bytes. 
    840         long chunk_len = max_chunk_len; 
     851        size_t chunk_len = max_chunk_len; 
    841852        if( file_len < max_chunk_len ) 
    842             chunk_len = file_len; 
     853            chunk_len = cast(size_t) file_len; 
    843854        //Stderr.formatln(" . chunk_len = {}", chunk_len); 
    844855 
    845856        // Seek back and read in the chunk.  Don't forget to clean up after 
    846857        // ourselves. 
    847         seeker.seek(-chunk_len, IConduit.Seek.Anchor.End); 
     858        seeker.seek(-cast(long)chunk_len, IConduit.Seek.Anchor.End); 
    848859        auto chunk_offset = seeker.seek(0, IConduit.Seek.Anchor.Current); 
    849860        //Stderr.formatln(" . chunk_offset = {}", chunk_offset); 
     
    860871        size_t eocd_loc = -1; 
    861872 
    862         for( size_t i=chunk_len-18; i>=0; --i ) 
    863         { 
    864             if( *(cast(uint*)(chunk.ptr+i)) == eocd_magic ) 
     873        if( chunk_len >= 18 ) 
     874            for( size_t i=chunk_len-18; i>=0; --i ) 
    865875            { 
    866                 // Found the bugger!  Make sure we skip the signature (forgot 
    867                 // to do that originally; talk about weird errors :P) 
    868                 eocd_loc = i+4; 
    869                 break; 
     876                if( *(cast(uint*)(chunk.ptr+i)) == eocd_magic ) 
     877                { 
     878                    // Found the bugger!  Make sure we skip the signature (forgot 
     879                    // to do that originally; talk about weird errors :P) 
     880                    eocd_loc = i+4; 
     881                    break; 
     882                } 
    870883            } 
    871         } 
    872884 
    873885        // If we didn't find it, then we'll assume that this is not a valid 
     
    11211133 
    11221134        { 
     1135            assert( entries.length < ushort.max ); 
     1136            assert( cd_len < uint.max ); 
     1137            assert( cd_pos < uint.max ); 
     1138 
    11231139            EndOfCDRecord eocdr; 
    11241140            eocdr.data.central_directory_entries_on_this_disk = 
    1125                 entries.length; 
    1126             eocdr.data.central_directory_entries_total = entries.length; 
    1127             eocdr.data.size_of_central_directory = cd_len; 
    1128             eocdr.data.offset_of_start_of_cd_from_starting_disk = cd_pos; 
     1141                cast(ushort) entries.length; 
     1142            eocdr.data.central_directory_entries_total = 
     1143                cast(ushort) entries.length; 
     1144            eocdr.data.size_of_central_directory = 
     1145                cast(ushort) cd_len; 
     1146            eocdr.data.offset_of_start_of_cd_from_starting_disk = 
     1147                cast(ushort) cd_pos; 
    11291148 
    11301149            write(output, EndOfCDRecord.signature); 
     
    11861205            scope in_counter = new CounterInput(in_chain); 
    11871206            in_chain = in_counter; 
    1188             scope(success) uncompressed_size = in_counter.count; 
     1207            assert( in_counter.count <= typeof(uncompressed_size).max ); 
     1208            scope(success) uncompressed_size = cast(uint) in_counter.count; 
    11891209 
    11901210            // Count the number of bytes going out to the archive 
    11911211            scope out_counter = new CounterOutput(out_chain); 
    11921212            out_chain = out_counter; 
    1193             scope(success) compressed_size = out_counter.count; 
     1213            assert( out_counter.count <= typeof(compressed_size).max ); 
     1214            scope(success) compressed_size = cast(uint) out_counter.count; 
    11941215 
    11951216            // Add crc 
     
    12171238                    out_chain = compress; 
    12181239                    break; 
     1240 
     1241                default: 
     1242                    assert(false); 
    12191243            } 
    12201244 
     
    13171341                    case 0: minver(10); break; 
    13181342                    case 8: minver(20); break; 
     1343                    default: 
     1344                        assert(false); 
    13191345                } 
    13201346 
     
    13501376 
    13511377        // Save the header 
     1378        assert( header_pos <= int.max ); 
    13521379        Entry entry; 
    13531380        entry.data.fromLocal(header.data); 
    13541381        entry.filename = file_name; 
    13551382        entry.header_position = header_pos; 
    1356         entry.data.relative_offset_of_local_header = header_pos; 
     1383        entry.data.relative_offset_of_local_header = cast(int) header_pos; 
    13571384        entries ~= entry; 
    13581385    } 
     
    13821409    uint size() 
    13831410    { 
    1384         return header.data.uncompressed_size;; 
     1411        return header.data.uncompressed_size; 
    13851412    } 
    13861413 
     
    22302257 
    22312258    auto span = time.span; 
    2232     dostime = 
     2259    dostime = cast(ushort) ( 
    22332260        (span.seconds / 2) 
    22342261      | (span.minutes << 5) 
    2235       | (span.hours   << 11)
    2236  
    2237     dosdate = 
     2262      | (span.hours   << 11))
     2263 
     2264    dosdate = cast(ushort) ( 
    22382265        (cal.getDayOfMonth(time)) 
    22392266      | (cal.getMonth(time) << 5) 
    2240       |((cal.getYear(time) - 1980) << 9)
     2267      |((cal.getYear(time) - 1980) << 9))
    22412268} 
    22422269 
     
    24402467        // Otherwise, make sure we don't try to read past the end of the slice 
    24412468        if( _position+dst.length > length ) 
    2442             dst.length = length-_position
     2469            dst.length = cast(size_t) (length-_position)
    24432470 
    24442471        // Seek source stream to the appropriate location. 
     
    24802507                if( _position < 0 ) _position = 0; 
    24812508                break; 
     2509 
     2510            default: 
     2511                assert(false); 
    24822512        } 
    24832513 
     
    25402570        // Otherwise, make sure we don't try to read past the end of the slice 
    25412571        if( dst.length > _length ) 
    2542             dst.length = _length; 
     2572            dst.length = cast(size_t) _length; 
    25432573 
    25442574        // Do the read 
     
    26192649        // slice 
    26202650        if( _position+src.length > length ) 
    2621             src.length = length-_position
     2651            src.length = cast(size_t) (length-_position)
    26222652 
    26232653        // Seek source stream to the appropriate location. 
     
    26642694                if( _position < 0 ) _position = 0; 
    26652695                break; 
     2696 
     2697            default: 
     2698                assert(false); 
    26662699        } 
    26672700 
  • trunk/tango/io/vfs/ZipFolder.d

    r3195 r3200  
    113113 
    114114            else if( file.tempFile !is null ) 
    115                 return file.tempFile.length; 
    116  
     115            { 
     116                assert( file.tempFile.length >= 0 ); 
     117                return cast(ulong) file.tempFile.length; 
     118            } 
    117119            else 
    118120                return 0; 
     
    243245                    break; 
    244246 
    245                 debug( ZipFolder ) 
    246                 { 
    247247                default: 
    248                     Stderr.formatln( 
     248                    debug( ZipFolder ) Stderr.formatln( 
    249249                            "Entry.dispose_children: unknown type {}", 
    250250                            type); 
    251251                    assert(false); 
    252                 } 
    253252            } 
    254253        } 
     
    725724        } 
    726725        while( true ); 
     726 
     727        assert(false); 
    727728    } 
    728729 
     
    989990            error("ZipFile.size: cannot reliably determine size of a " 
    990991                    "non-existent file"); 
     992 
     993        assert(false); 
    991994    } 
    992995 
     
    11381141            error("ZipFile.input: cannot open non-existent file for input; " 
    11391142                    "results would not be very useful"); 
     1143 
     1144        assert(false); 
    11401145    } 
    11411146 
     
    13061311                    ~ parent.fullname ~ "/" ~ name 
    13071312                    ~ "\" does not exist"); 
     1313 
     1314            assert(false); 
    13081315        } 
    13091316    }