From 6c3d651ffebad6bbb2381d161e5dc12f3af65b31 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 11 Oct 2010 21:44:46 +0000 Subject: [PATCH] (trunk) #3618 "FreeBSD 8.1 & GCC 4.2.1 compiler warnings" -- fix some compiler warnings. --- libtransmission/fdlimit.c | 2 +- libtransmission/peer-mgr.c | 15 +++++---------- libtransmission/torrent-magnet.c | 2 +- libtransmission/torrent.c | 6 +++--- third-party/dht/dht.c | 30 ++++++++++++++++-------------- 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/libtransmission/fdlimit.c b/libtransmission/fdlimit.c index 7ca841515..e6c387fee 100644 --- a/libtransmission/fdlimit.c +++ b/libtransmission/fdlimit.c @@ -231,7 +231,7 @@ tr_pwrite( int fd, const void *buf, size_t count, off_t offset ) } int -tr_prefetch( int fd, off_t offset, size_t count ) +tr_prefetch( int fd UNUSED, off_t offset UNUSED, size_t count UNUSED ) { #ifdef HAVE_POSIX_FADVISE return posix_fadvise( fd, offset, count, POSIX_FADV_WILLNEED ); diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 7ed101fc1..8b5f40563 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -836,20 +836,15 @@ comparePieceByIndex( const void * va, const void * vb ) static void pieceListSort( Torrent * t, int mode ) { - int(*compar)(const void *, const void *); - assert( mode==PIECES_SORTED_BY_INDEX || mode==PIECES_SORTED_BY_WEIGHT ); - switch( mode ) { - case PIECES_SORTED_BY_WEIGHT: compar = comparePieceByWeight; break; - case PIECES_SORTED_BY_INDEX: compar = comparePieceByIndex; break; - default: assert( 0 && "unhandled" ); break; - } - weightTorrent = t->tor; - qsort( t->pieces, t->pieceCount, - sizeof( struct weighted_piece ), compar ); + + if( mode == PIECES_SORTED_BY_WEIGHT ) + qsort( t->pieces, t->pieceCount, sizeof( struct weighted_piece ), comparePieceByWeight ); + else + qsort( t->pieces, t->pieceCount, sizeof( struct weighted_piece ), comparePieceByIndex ); } static tr_bool diff --git a/libtransmission/torrent-magnet.c b/libtransmission/torrent-magnet.c index 1f03852d7..12a54f8f4 100644 --- a/libtransmission/torrent-magnet.c +++ b/libtransmission/torrent-magnet.c @@ -268,7 +268,7 @@ tr_torrentSetMetadataPiece( tr_torrent * tor, int piece, const void * data, in if( success && !tr_getBlockSize( info.pieceSize ) ) { - tr_torrentSetLocalError( tor, _( "Magnet torrent's metadata is not usable" ) ); + tr_torrentSetLocalError( tor, "%s", _( "Magnet torrent's metadata is not usable" ) ); success = FALSE; } diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index a0f42ef4c..58b3d9c7f 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -1484,7 +1484,7 @@ checkAndStartImpl( void * vtor ) stop the torrent and log an error. */ if( tor->preVerifyTotal && !tr_cpHaveTotal( &tor->completion ) ) { - tr_torrentSetLocalError( tor, _( "No data found! Reconnect any disconnected drives, use \"Set Location\", or restart the torrent to re-download." ) ); + tr_torrentSetLocalError( tor, "%s", _( "No data found! Reconnect any disconnected drives, use \"Set Location\", or restart the torrent to re-download." ) ); } else { @@ -1567,7 +1567,7 @@ torrentRecheckDoneImpl( void * vtor ) if( tor->preVerifyTotal && !tr_cpHaveTotal( &tor->completion ) ) { - tr_torrentSetLocalError( tor, _( "Can't find local data. Try \"Set Location\" to find it, or restart the torrent to re-download." ) ); + tr_torrentSetLocalError( tor, "%s", _( "Can't find local data. Try \"Set Location\" to find it, or restart the torrent to re-download." ) ); } else if( tor->startAfterVerify ) { @@ -1680,7 +1680,7 @@ closeTorrent( void * vtor ) tr_bencDictAddInt( d, "id", tor->uniqueId ); tr_bencDictAddInt( d, "date", tr_time( ) ); - tr_torinf( tor, _( "Removing torrent" ) ); + tr_torinf( tor, "%s", _( "Removing torrent" ) ); stopTorrent( tor ); diff --git a/third-party/dht/dht.c b/third-party/dht/dht.c index bd554b14f..d022ee8ae 100644 --- a/third-party/dht/dht.c +++ b/third-party/dht/dht.c @@ -380,7 +380,7 @@ is_martian(struct sockaddr *sa) /* Forget about the ``XOR-metric''. An id is just a path from the root of the tree, so bits are numbered from the start. */ -static inline int +static int id_cmp(const unsigned char *restrict id1, const unsigned char *restrict id2) { /* Memcmp is guaranteed to perform an unsigned comparison. */ @@ -1224,10 +1224,24 @@ static int storage_store(const unsigned char *id, struct sockaddr *sa) { int i, len; - struct storage *st = storage; + struct storage *st; unsigned char *ip; unsigned short port; + if(sa->sa_family == AF_INET) { + struct sockaddr_in *sin = (struct sockaddr_in*)sa; + ip = (unsigned char*)&sin->sin_addr; + len = 4; + port = ntohs(sin->sin_port); + } else if(sa->sa_family == AF_INET6) { + struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa; + ip = (unsigned char*)&sin6->sin6_addr; + len = 16; + port = ntohs(sin6->sin6_port); + } else { + return -1; + } + st = find_storage(id); if(st == NULL) { @@ -1241,18 +1255,6 @@ storage_store(const unsigned char *id, struct sockaddr *sa) numstorage++; } - if(sa->sa_family == AF_INET) { - struct sockaddr_in *sin = (struct sockaddr_in*)sa; - ip = (unsigned char*)&sin->sin_addr; - len = 4; - port = ntohs(sin->sin_port); - } else if(sa->sa_family == AF_INET6) { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa; - ip = (unsigned char*)&sin6->sin6_addr; - len = 16; - port = ntohs(sin6->sin6_port); - } - for(i = 0; i < st->numpeers; i++) { if(st->peers[i].port == port && st->peers[i].len == len && memcmp(st->peers[i].ip, ip, len) == 0)