]> granicus.if.org Git - transmission/commitdiff
(trunk libT) fix a few -Wconversion warnings
authorCharles Kerr <charles@transmissionbt.com>
Thu, 1 Jul 2010 15:14:35 +0000 (15:14 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Thu, 1 Jul 2010 15:14:35 +0000 (15:14 +0000)
libtransmission/blocklist.c
libtransmission/blocklist.h
libtransmission/makemeta.c

index 73897006a8a48233c3befe7e43fd7e0339bd33ef..cd85ab497ed848ab515d354ef119fe8085a1e4d3 100644 (file)
@@ -79,8 +79,9 @@ blocklistClose( tr_blocklist * b )
 static void
 blocklistLoad( tr_blocklist * b )
 {
-    int          fd;
-    struct stat  st;
+    int fd;
+    size_t byteCount;
+    struct stat st;
     const char * err_fmt = _( "Couldn't read \"%1$s\": %2$s" );
 
     blocklistClose( b );
@@ -95,7 +96,8 @@ blocklistLoad( tr_blocklist * b )
         return;
     }
 
-    b->rules = mmap( NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0 );
+    byteCount = (size_t) st.st_size;
+    b->rules = mmap( NULL, byteCount, PROT_READ, MAP_PRIVATE, fd, 0 );
     if( !b->rules )
     {
         tr_err( err_fmt, b->filename, tr_strerror( errno ) );
@@ -103,9 +105,9 @@ blocklistLoad( tr_blocklist * b )
         return;
     }
 
-    b->byteCount = st.st_size;
-    b->ruleCount = st.st_size / sizeof( struct tr_ip_range );
     b->fd = fd;
+    b->byteCount = byteCount;
+    b->ruleCount = byteCount / sizeof( struct tr_ip_range );
 
     {
         char * base = tr_basename( b->filename );
@@ -145,8 +147,7 @@ blocklistDelete( tr_blocklist * b )
 ***/
 
 tr_blocklist *
-_tr_blocklistNew( const char * filename,
-                  int          isEnabled )
+_tr_blocklistNew( const char * filename, tr_bool isEnabled )
 {
     tr_blocklist * b;
 
index 28bedc8429f95222a3113d1ea52c3bba08fca427..c2bdb42dfab21ae87876d7071e939c6525fdf347 100644 (file)
@@ -21,7 +21,7 @@ struct tr_address;
 typedef struct tr_blocklist tr_blocklist;
 
 tr_blocklist* _tr_blocklistNew         ( const char              * filename,
-                                         int                       isEnabled );
+                                         tr_bool                   isEnabled );
 
 int           _tr_blocklistExists      ( const tr_blocklist      * b );
 
index f98efcdd3f2313f69370589ac87ce40776c27617..a0073df643ff53e1eb222c308d77cf722b72bdf0 100644 (file)
@@ -88,12 +88,12 @@ getFiles( const char *      dir,
     return list;
 }
 
-static int
+static uint32_t
 bestPieceSize( uint64_t totalSize )
 {
-    const uint64_t GiB = 1073741824;
-    const uint64_t MiB = 1048576;
-    const uint64_t KiB = 1024;
+    const uint32_t GiB = 1073741824;
+    const uint32_t MiB = 1048576;
+    const uint32_t KiB = 1024;
 
     if( totalSize >=   ( 2 * GiB ) ) return 2 * MiB;
     if( totalSize >=   ( 1 * GiB ) ) return 1 * MiB;
@@ -226,21 +226,19 @@ getHashInfo( tr_metainfo_builder * b )
     }
     while( totalRemain )
     {
-        uint8_t *      bufptr = buf;
-        const uint64_t thisPieceSize =
-            MIN( (uint32_t)b->pieceSize, totalRemain );
-        uint64_t       pieceRemain = thisPieceSize;
+        uint8_t * bufptr = buf;
+        const uint32_t thisPieceSize = (uint32_t) MIN( b->pieceSize, totalRemain );
+        uint32_t leftInPiece = thisPieceSize;
 
         assert( b->pieceIndex < b->pieceCount );
 
-        while( pieceRemain )
+        while( leftInPiece )
         {
-            const uint64_t n_this_pass =
-                MIN( ( b->files[fileIndex].size - off ), pieceRemain );
+            const size_t n_this_pass = (size_t) MIN( ( b->files[fileIndex].size - off ), leftInPiece );
             read( fd, bufptr, n_this_pass );
             bufptr += n_this_pass;
             off += n_this_pass;
-            pieceRemain -= n_this_pass;
+            leftInPiece -= n_this_pass;
             if( off == b->files[fileIndex].size )
             {
                 off = 0;
@@ -265,7 +263,7 @@ getHashInfo( tr_metainfo_builder * b )
         }
 
         assert( bufptr - buf == (int)thisPieceSize );
-        assert( pieceRemain == 0 );
+        assert( leftInPiece == 0 );
         tr_sha1( walk, buf, thisPieceSize, NULL );
         walk += SHA_DIGEST_LENGTH;