]> granicus.if.org Git - transmission/commitdiff
(trunk) #4019 "Minor patch, kill useless casts in transmission source." -- fixed...
authorJordan Lee <jordan@transmissionbt.com>
Sat, 12 Feb 2011 17:27:47 +0000 (17:27 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Sat, 12 Feb 2011 17:27:47 +0000 (17:27 +0000)
jlouis used Coccinelle to scan transmission's source for redundant code that casts a type to its own type.

daemon/remote.c
libtransmission/fdlimit.c
libtransmission/handshake.c
libtransmission/json.c
libtransmission/peer-mgr.c
libtransmission/utils.c
libtransmission/utils.h

index 9db09a40311916694d3182ff45dd08a5dea78fd4..875fdcabac8e2f1b5e9ff95a11b7cb6bc2070c2c 100644 (file)
@@ -2277,7 +2277,7 @@ processArgs( const char * rpcurl, int argc, const char ** argv )
             }
             default:
             {
-                fprintf( stderr, "got opt [%d]\n", (int)c );
+                fprintf( stderr, "got opt [%d]\n", c );
                 showUsage( );
                 break;
             }
index c80953e4033525d286292ad6e0a077748a40db05..73edf6dbcb1e8c3b33f5e2babf3b683f5aaf5f31 100644 (file)
@@ -793,7 +793,7 @@ tr_fdSetPeerLimit( tr_session * session, int socket_limit )
 #endif
     gFd->public_socket_limit = socket_limit;
 
-    tr_dbg( "socket limit is %d", (int)gFd->socket_limit );
+    tr_dbg( "socket limit is %d", gFd->socket_limit );
 }
 
 int
index 020129c1cd20afb0acd6c215a17c7e3286ef75dd..4bd2875d30f8dea512d04d848598f7bb2dc5279f 100644 (file)
@@ -265,7 +265,7 @@ parseHandshake( tr_handshake *    handshake,
     uint8_t peer_id[PEER_ID_LEN];
 
     dbgmsg( handshake, "payload: need %d, got %zu",
-            (int)HANDSHAKE_SIZE, evbuffer_get_length( inbuf ) );
+            HANDSHAKE_SIZE, evbuffer_get_length( inbuf ) );
 
     if( evbuffer_get_length( inbuf ) < HANDSHAKE_SIZE )
         return READ_LATER;
@@ -608,7 +608,7 @@ readHandshake( tr_handshake *    handshake,
     uint8_t   hash[SHA_DIGEST_LENGTH];
 
     dbgmsg( handshake, "payload: need %d, got %zu",
-            (int)INCOMING_HANDSHAKE_LEN, evbuffer_get_length( inbuf ) );
+            INCOMING_HANDSHAKE_LEN, evbuffer_get_length( inbuf ) );
 
     if( evbuffer_get_length( inbuf ) < INCOMING_HANDSHAKE_LEN )
         return READ_LATER;
@@ -757,7 +757,7 @@ readYa( tr_handshake *    handshake,
     int            len;
 
     dbgmsg( handshake, "in readYa... need %d, have %zu",
-            (int)KEY_LEN, evbuffer_get_length( inbuf ) );
+            KEY_LEN, evbuffer_get_length( inbuf ) );
     if( evbuffer_get_length( inbuf ) < KEY_LEN )
         return READ_LATER;
 
index 01b08b80213066e409b7bdc247556e28fce5dc21..1e4b5e944a35aa9fa1f769ec02ca40a69dfa61d9 100644 (file)
@@ -91,7 +91,7 @@ callback( void *             vdata,
 
         case JSON_T_FLOAT:
             data->hasContent = TRUE;
-            tr_bencInitReal( getNode( data ), (double)value->vu.float_value );
+            tr_bencInitReal( getNode( data ), value->vu.float_value );
             break;
 
         case JSON_T_NULL:
index cc8dec10228fbb67e419df61a33d91ca4fe21e25..9b72af6fde6853888040d1027ac807eb1e5eb24e 100644 (file)
@@ -803,10 +803,10 @@ comparePieceByWeight( const void * va, const void * vb )
     /* primary key: weight */
     missing = tr_cpMissingBlocksInPiece( &tor->completion, a->index );
     pending = a->requestCount;
-    ia = missing > pending ? missing - pending : (int)(tor->blockCountInPiece + pending);
+    ia = missing > pending ? missing - pending : (tor->blockCountInPiece + pending);
     missing = tr_cpMissingBlocksInPiece( &tor->completion, b->index );
     pending = b->requestCount;
-    ib = missing > pending ? missing - pending : (int)(tor->blockCountInPiece + pending);
+    ib = missing > pending ? missing - pending : (tor->blockCountInPiece + pending);
     if( ia < ib ) return -1;
     if( ia > ib ) return 1;
 
index f8fe9439f873bb92e95437a5f31501c6fe924496..60e757789f8f15f641ac05607a71a31ebeed503b 100644 (file)
@@ -201,7 +201,7 @@ tr_getLogTimeStr( char * buf, int buflen )
     seconds = tv.tv_sec;
     tr_localtime_r( &seconds, &now_tm );
     strftime( tmp, sizeof( tmp ), "%H:%M:%S", &now_tm );
-    milliseconds = (int)( tv.tv_usec / 1000 );
+    milliseconds = tv.tv_usec / 1000;
     tr_snprintf( buf, buflen, "%s.%03d", tmp, milliseconds );
 
     return buf;
index f063c85d309006e119b7e4b8518888fe8bc74fc5..ab8d99a472663d1ac26f83f6cc9124dae61d6f44 100644 (file)
@@ -323,13 +323,13 @@ void evbuffer_ref_cleanup_tr_free( const void * data UNUSED, size_t datalen UNUS
 void* tr_memdup( const void * src, size_t byteCount );
 
 #define tr_new( struct_type, n_structs )           \
-    ( (struct_type *) tr_malloc ( ( (size_t) sizeof ( struct_type ) ) * ( ( size_t) ( n_structs ) ) ) )
+    ( (struct_type *) tr_malloc ( sizeof ( struct_type ) * ( ( size_t) ( n_structs ) ) ) )
 
 #define tr_new0( struct_type, n_structs )          \
-    ( (struct_type *) tr_malloc0 ( ( (size_t) sizeof ( struct_type ) ) * ( ( size_t) ( n_structs ) ) ) )
+    ( (struct_type *) tr_malloc0 ( sizeof ( struct_type ) * ( ( size_t) ( n_structs ) ) ) )
 
 #define tr_renew( struct_type, mem, n_structs )    \
-    ( (struct_type *) realloc ( ( mem ), ( (size_t) sizeof ( struct_type ) ) * ( ( size_t) ( n_structs ) ) ) )
+    ( (struct_type *) realloc ( ( mem ), sizeof ( struct_type ) * ( ( size_t) ( n_structs ) ) ) )
 
 void* tr_valloc( size_t bufLen );