From b860119cd313de52c4ea91ab07ba79cae014e980 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 1 Aug 2008 16:43:22 +0000 Subject: [PATCH] minor text cleanup --- libtransmission/Makefile.am | 4 +-- libtransmission/bencode.c | 14 ++++----- libtransmission/completion.c | 2 +- libtransmission/crypto.c | 6 ++-- libtransmission/fdlimit.c | 4 +-- libtransmission/handshake.c | 6 ++-- libtransmission/inout.c | 4 +-- libtransmission/list.c | 8 ++--- libtransmission/makemeta.c | 4 +-- libtransmission/peer-io.c | 54 +++++++++++++++++----------------- libtransmission/peer-mgr.c | 44 +++++++++++++-------------- libtransmission/peer-msgs.c | 30 +++++++++---------- libtransmission/ptrarray.c | 14 ++++----- libtransmission/publish.c | 4 +-- libtransmission/ratecontrol.c | 2 +- libtransmission/rpc.c | 2 +- libtransmission/session.c | 8 ++--- libtransmission/stats.c | 4 +-- libtransmission/torrent-ctor.c | 2 +- libtransmission/torrent.c | 30 +++++++++---------- libtransmission/utils.c | 16 +++++----- libtransmission/verify.c | 4 +-- 22 files changed, 133 insertions(+), 133 deletions(-) diff --git a/libtransmission/Makefile.am b/libtransmission/Makefile.am index 4e0cc6abb..8d2c95b61 100644 --- a/libtransmission/Makefile.am +++ b/libtransmission/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS = -I. -I$(top_srcdir) -I$(top_srcdir)/third-party/ -D__TRANSMISSION__ $(LIBEVENT_CPPFLAGS) -AM_CFLAGS = $(OPENSSL_CFLAGS) $(LIBCURL_CFLAGS) $(PTHREAD_CFLAGS) +AM_CFLAGS = $(LIBCURL_CFLAGS) $(OPENSSL_CFLAGS) $(PTHREAD_CFLAGS) noinst_LIBRARIES = libtransmission.a @@ -110,8 +110,8 @@ APPS_LDADD = \ $(top_builddir)/third-party/libnatpmp/libnatpmp.a \ $(top_builddir)/third-party/libevent/libevent.la \ $(INTLLIBS) \ - $(OPENSSL_LIBS) \ $(LIBCURL_LIBS) \ + $(OPENSSL_LIBS) \ $(PTHREAD_LIBS) \ -lm diff --git a/libtransmission/bencode.c b/libtransmission/bencode.c index bed62a517..f3940cf43 100644 --- a/libtransmission/bencode.c +++ b/libtransmission/bencode.c @@ -33,7 +33,7 @@ int tr_bencIsType( const tr_benc * val, int type ) { - return ( ( val != NULL ) && ( val->type == type ) ); + return ( ( val ) && ( val->type == type ) ); } static int @@ -176,14 +176,14 @@ getNode( tr_benc * top, tr_ptrArray * parentStack, int type ) { tr_benc * parent; - assert( top != NULL ); - assert( parentStack != NULL ); + assert( top ); + assert( parentStack ); if( tr_ptrArrayEmpty( parentStack ) ) return top; parent = tr_ptrArrayBack( parentStack ); - assert( parent != NULL ); + assert( parent ); /* dictionary keys must be strings */ if( ( parent->type == TYPE_DICT ) @@ -300,7 +300,7 @@ tr_bencParse( const void * buf_in, err = !isSomething( top ) || !tr_ptrArrayEmpty( parentStack ); - if( !err && ( setme_end != NULL ) ) + if( !err && setme_end ) *setme_end = buf; tr_ptrArrayFree( parentStack, NULL ); @@ -903,7 +903,7 @@ tr_bencSave( const tr_benc * top, int * len ) walkFuncs.containerEndFunc = saveContainerEndFunc; bencWalk( top, &walkFuncs, out ); - if( len != NULL ) + if( len ) *len = EVBUFFER_LENGTH( out ); ret = tr_strndup( (char*) EVBUFFER_DATA( out ), EVBUFFER_LENGTH( out ) ); evbuffer_free( out ); @@ -1205,7 +1205,7 @@ tr_bencSaveAsJSON( const tr_benc * top, int * len ) if( EVBUFFER_LENGTH( data.out ) ) evbuffer_add_printf( data.out, "\n" ); - if( len != NULL ) + if( len ) *len = EVBUFFER_LENGTH( data.out ); ret = tr_strndup( (char*) EVBUFFER_DATA( data.out ), EVBUFFER_LENGTH( data.out ) ); evbuffer_free( data.out ); diff --git a/libtransmission/completion.c b/libtransmission/completion.c index 0dad5a6c8..c455ee1d7 100644 --- a/libtransmission/completion.c +++ b/libtransmission/completion.c @@ -163,7 +163,7 @@ tr_cpPieceRem( tr_completion * cp, tr_piece_index_t piece ) const tr_block_index_t end = start + tr_torPieceCountBlocks( tor, piece ); tr_block_index_t block; - assert( cp != NULL ); + assert( cp ); assert( piece < tor->info.pieceCount ); assert( start < tor->blockCount ); assert( start <= end ); diff --git a/libtransmission/crypto.c b/libtransmission/crypto.c index 7806f3f35..ab24eab59 100644 --- a/libtransmission/crypto.c +++ b/libtransmission/crypto.c @@ -241,7 +241,7 @@ tr_cryptoSetTorrentHash( tr_crypto * crypto, { crypto->torrentHashIsSet = hash ? 1 : 0; - if( hash != NULL ) + if( hash ) memcpy( crypto->torrentHash, hash, SHA_DIGEST_LENGTH ); else memset( crypto->torrentHash, 0, SHA_DIGEST_LENGTH ); @@ -250,7 +250,7 @@ tr_cryptoSetTorrentHash( tr_crypto * crypto, const uint8_t* tr_cryptoGetTorrentHash( const tr_crypto * crypto ) { - assert( crypto != NULL ); + assert( crypto ); assert( crypto->torrentHashIsSet ); return crypto->torrentHash; @@ -259,7 +259,7 @@ tr_cryptoGetTorrentHash( const tr_crypto * crypto ) int tr_cryptoHasTorrentHash( const tr_crypto * crypto ) { - assert( crypto != NULL ); + assert( crypto ); return crypto->torrentHashIsSet ? 1 : 0; } diff --git a/libtransmission/fdlimit.c b/libtransmission/fdlimit.c index 4dccdd438..2da77d3f3 100644 --- a/libtransmission/fdlimit.c +++ b/libtransmission/fdlimit.c @@ -385,8 +385,8 @@ tr_fdSocketAccept( int b, struct in_addr * addr, tr_port_t * port ) unsigned int len; struct sockaddr_in sock; - assert( addr != NULL ); - assert( port != NULL ); + assert( addr ); + assert( port ); tr_lockLock( gFd->lock ); if( gFd->normal < getSocketMax( gFd ) ) diff --git a/libtransmission/handshake.c b/libtransmission/handshake.c index 06ced31ec..96af0ea33 100644 --- a/libtransmission/handshake.c +++ b/libtransmission/handshake.c @@ -286,7 +286,7 @@ sendYa( tr_handshake * handshake ) /* add our public key (Ya) */ public_key = tr_cryptoGetMyPublicKey( handshake->crypto, &len ); assert( len == KEY_LEN ); - assert( public_key != NULL ); + assert( public_key ); evbuffer_add( outbuf, public_key, len ); /* add some bullshit padding */ @@ -1057,8 +1057,8 @@ tr_handshakeNew( tr_peerIo * io, const struct in_addr * tr_handshakeGetAddr( const struct tr_handshake * handshake, uint16_t * port ) { - assert( handshake != NULL ); - assert( handshake->io != NULL ); + assert( handshake ); + assert( handshake->io ); return tr_peerIoGetAddress( handshake->io, port ); } diff --git a/libtransmission/inout.c b/libtransmission/inout.c index e516ba440..411d0076e 100644 --- a/libtransmission/inout.c +++ b/libtransmission/inout.c @@ -240,8 +240,8 @@ recalculateHash( const tr_torrent * tor, tr_lockLock( lock ); - assert( tor != NULL ); - assert( setme != NULL ); + assert( tor ); + assert( setme ); assert( pieceIndex < tor->info.pieceCount ); n = tr_torPieceCountBytes( tor, pieceIndex ); diff --git a/libtransmission/list.c b/libtransmission/list.c index a8f27d1da..a568bfc2c 100644 --- a/libtransmission/list.c +++ b/libtransmission/list.c @@ -37,7 +37,7 @@ tr_list_free( tr_list** list, TrListForeachFunc data_free_func ) { tr_list *node = *list; *list = (*list)->next; - if( data_free_func != NULL ) + if( data_free_func ) data_free_func( node->data ); node_free( node ); } @@ -125,7 +125,7 @@ void* tr_list_pop_front( tr_list ** list ) { void * ret = NULL; - if( *list != NULL ) + if( *list ) { ret = (*list)->data; tr_list_remove_node( list, *list ); @@ -161,7 +161,7 @@ tr_list_find ( tr_list * list , const void * b, TrListCompareFunc func ) void tr_list_foreach( tr_list * list, TrListForeachFunc func ) { - while( list != NULL ) { + while( list ) { func( list->data ); list = list->next; } @@ -171,7 +171,7 @@ int tr_list_size( const tr_list * list ) { int size = 0; - while( list != NULL ) { + while( list ) { ++size; list = list->next; } diff --git a/libtransmission/makemeta.c b/libtransmission/makemeta.c index 54720643a..f224281cb 100644 --- a/libtransmission/makemeta.c +++ b/libtransmission/makemeta.c @@ -262,7 +262,7 @@ getHashInfo ( tr_metainfo_builder * b ) assert( b->abortFlag || (walk-ret == (int)(SHA_DIGEST_LENGTH*b->pieceCount)) ); assert( b->abortFlag || !totalRemain ); - if( fp != NULL ) + if( fp ) fclose( fp ); tr_free( buf ); @@ -431,7 +431,7 @@ static void workerFunc( void * user_data ) /* find the next builder to process */ tr_lock * lock = getQueueLock ( handle ); tr_lockLock( lock ); - if( queue != NULL ) { + if( queue ) { builder = queue; queue = queue->nextBuilder; } diff --git a/libtransmission/peer-io.c b/libtransmission/peer-io.c index 05c2aa392..38d51dc7b 100644 --- a/libtransmission/peer-io.c +++ b/libtransmission/peer-io.c @@ -80,8 +80,8 @@ static void didWriteWrapper( struct bufferevent * e, void * userData ) { tr_peerIo * c = (tr_peerIo *) userData; - if( c->didWrite != NULL ) - (*c->didWrite)( e, c->userData ); + if( c->didWrite ) + c->didWrite( e, c->userData ); } static void @@ -98,7 +98,7 @@ canReadWrapper( struct bufferevent * e, void * userData ) while( !done ) { - const int ret = (*c->canRead)( e, c->userData ); + const int ret = c->canRead( e, c->userData ); switch( ret ) { @@ -118,8 +118,8 @@ static void gotErrorWrapper( struct bufferevent * e, short what, void * userData ) { tr_peerIo * c = userData; - if( c->gotError != NULL ) - (*c->gotError)( e, what, c->userData ); + if( c->gotError ) + c->gotError( e, what, c->userData ); } /** @@ -168,8 +168,8 @@ tr_peerIoNewIncoming( struct tr_handle * handle, uint16_t port, int socket ) { - assert( handle != NULL ); - assert( in_addr != NULL ); + assert( handle ); + assert( in_addr ); assert( socket >= 0 ); return tr_peerIoNew( handle, in_addr, port, @@ -185,10 +185,10 @@ tr_peerIoNewOutgoing( struct tr_handle * handle, { int socket; - assert( handle != NULL ); - assert( in_addr != NULL ); + assert( handle ); + assert( in_addr ); assert( port >= 0 ); - assert( torrentHash != NULL ); + assert( torrentHash ); socket = tr_netOpenTCP( in_addr, port, 0 ); @@ -211,7 +211,7 @@ io_dtor( void * vio ) void tr_peerIoFree( tr_peerIo * io ) { - if( io != NULL ) + if( io ) { io->canRead = NULL; io->didWrite = NULL; @@ -223,8 +223,8 @@ tr_peerIoFree( tr_peerIo * io ) tr_handle* tr_peerIoGetHandle( tr_peerIo * io ) { - assert( io != NULL ); - assert( io->handle != NULL ); + assert( io ); + assert( io->handle ); return io->handle; } @@ -232,9 +232,9 @@ tr_peerIoGetHandle( tr_peerIo * io ) const struct in_addr* tr_peerIoGetAddress( const tr_peerIo * io, uint16_t * port ) { - assert( io != NULL ); + assert( io ); - if( port != NULL ) + if( port ) *port = io->port; return &io->in_addr; @@ -329,7 +329,7 @@ void tr_peerIoSetTorrentHash( tr_peerIo * io, const uint8_t * hash ) { - assert( io != NULL ); + assert( io ); tr_cryptoSetTorrentHash( io->crypto, hash ); } @@ -337,8 +337,8 @@ tr_peerIoSetTorrentHash( tr_peerIo * io, const uint8_t* tr_peerIoGetTorrentHash( tr_peerIo * io ) { - assert( io != NULL ); - assert( io->crypto != NULL ); + assert( io ); + assert( io->crypto ); return tr_cryptoGetTorrentHash( io->crypto ); } @@ -346,8 +346,8 @@ tr_peerIoGetTorrentHash( tr_peerIo * io ) int tr_peerIoHasTorrentHash( const tr_peerIo * io ) { - assert( io != NULL ); - assert( io->crypto != NULL ); + assert( io ); + assert( io->crypto ); return tr_cryptoHasTorrentHash( io->crypto ); } @@ -360,7 +360,7 @@ void tr_peerIoSetPeersId( tr_peerIo * io, const uint8_t * peer_id ) { - assert( io != NULL ); + assert( io ); if(( io->peerIdIsSet = peer_id != NULL )) memcpy( io->peerId, peer_id, 20 ); @@ -371,7 +371,7 @@ tr_peerIoSetPeersId( tr_peerIo * io, const uint8_t* tr_peerIoGetPeersId( const tr_peerIo * io ) { - assert( io != NULL ); + assert( io ); assert( io->peerIdIsSet ); return io->peerId; @@ -384,7 +384,7 @@ tr_peerIoGetPeersId( const tr_peerIo * io ) void tr_peerIoEnableLTEP( tr_peerIo * io, int flag ) { - assert( io != NULL ); + assert( io ); assert( flag==0 || flag==1 ); io->extendedProtocolSupported = flag; @@ -393,7 +393,7 @@ tr_peerIoEnableLTEP( tr_peerIo * io, int flag ) void tr_peerIoEnableFEXT( tr_peerIo * io, int flag ) { - assert( io != NULL ); + assert( io ); assert( flag==0 || flag==1 ); io->fastPeersSupported = flag; @@ -402,7 +402,7 @@ tr_peerIoEnableFEXT( tr_peerIo * io, int flag ) int tr_peerIoSupportsLTEP( const tr_peerIo * io ) { - assert( io != NULL ); + assert( io ); return io->extendedProtocolSupported; } @@ -410,7 +410,7 @@ tr_peerIoSupportsLTEP( const tr_peerIo * io ) int tr_peerIoSupportsFEXT( const tr_peerIo * io ) { - assert( io != NULL ); + assert( io ); return io->fastPeersSupported; } @@ -456,7 +456,7 @@ void tr_peerIoSetEncryption( tr_peerIo * io, int encryptionMode ) { - assert( io != NULL ); + assert( io ); assert( encryptionMode==PEER_ENCRYPTION_NONE || encryptionMode==PEER_ENCRYPTION_RC4 ); io->encryptionMode = encryptionMode; diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 84ed8f2a6..754fecb83 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -248,11 +248,11 @@ static tr_peer* getExistingPeer( Torrent * torrent, const struct in_addr * in_addr ) { assert( torrentIsLocked( torrent ) ); - assert( in_addr != NULL ); + assert( in_addr ); - return (tr_peer*) tr_ptrArrayFindSorted( torrent->peers, - in_addr, - peerCompareToAddr ); + return tr_ptrArrayFindSorted( torrent->peers, + in_addr, + peerCompareToAddr ); } static struct peer_atom* @@ -305,8 +305,8 @@ getPeer( Torrent * torrent, const struct in_addr * in_addr ) static void peerDestructor( tr_peer * peer ) { - assert( peer != NULL ); - assert( peer->msgs != NULL ); + assert( peer ); + assert( peer->msgs ); tr_peerMsgsUnsubscribe( peer->msgs, peer->msgsTag ); tr_peerMsgsFree( peer->msgs ); @@ -330,7 +330,7 @@ removePeer( Torrent * t, tr_peer * peer ) assert( torrentIsLocked( t ) ); atom = getExistingAtom( t, &peer->in_addr ); - assert( atom != NULL ); + assert( atom ); atom->time = time( NULL ); removed = tr_ptrArrayRemoveSorted( t->peers, peer, peerCompare ); @@ -350,9 +350,9 @@ torrentDestructor( Torrent * t ) { uint8_t hash[SHA_DIGEST_LENGTH]; - assert( t != NULL ); + assert( t ); assert( !t->isRunning ); - assert( t->peers != NULL ); + assert( t->peers ); assert( torrentIsLocked( t ) ); assert( tr_ptrArrayEmpty( t->outgoingHandshakes ) ); assert( tr_ptrArrayEmpty( t->peers ) ); @@ -480,7 +480,7 @@ getConnectedPeers( Torrent * t, int * setmeCount ) ret = tr_new( tr_peer*, peerCount ); for( i=connectionCount=0; imsgs != NULL ) + if( peers[i]->msgs ) ret[connectionCount++] = peers[i]; *setmeCount = connectionCount; @@ -936,7 +936,7 @@ myHandshakeDoneCB( tr_handshake * handshake, Torrent * t; tr_handshake * ours; - assert( io != NULL ); + assert( io ); assert( isConnected==0 || isConnected==1 ); t = tr_peerIoHasTorrentHash( io ) @@ -946,16 +946,16 @@ myHandshakeDoneCB( tr_handshake * handshake, if( tr_peerIoIsIncoming ( io ) ) ours = tr_ptrArrayRemoveSorted( manager->incomingHandshakes, handshake, handshakeCompare ); - else if( t != NULL ) + else if( t ) ours = tr_ptrArrayRemoveSorted( t->outgoingHandshakes, handshake, handshakeCompare ); else ours = handshake; - assert( ours != NULL ); + assert( ours ); assert( ours == handshake ); - if( t != NULL ) + if( t ) torrentLock( t ); addr = tr_peerIoGetAddress( io, &port ); @@ -1000,7 +1000,7 @@ myHandshakeDoneCB( tr_handshake * handshake, { tr_peer * peer = getExistingPeer( t, addr ); - if( peer != NULL ) /* we already have this peer */ + if( peer ) /* we already have this peer */ { tr_peerIoFree( io ); } @@ -1024,7 +1024,7 @@ myHandshakeDoneCB( tr_handshake * handshake, } } - if( t != NULL ) + if( t ) torrentUnlock( t ); } @@ -1136,8 +1136,8 @@ tr_peerMgrSetBlame( tr_peerMgr * manager, int tr_pexCompare( const void * va, const void * vb ) { - const tr_pex * a = (const tr_pex *) va; - const tr_pex * b = (const tr_pex *) vb; + const tr_pex * a = va; + const tr_pex * b = vb; int i = memcmp( &a->in_addr, &b->in_addr, sizeof(struct in_addr) ); if( i ) return i; if( a->port < b->port ) return -1; @@ -1210,7 +1210,7 @@ tr_peerMgrStartTorrent( tr_peerMgr * manager, t = getExistingTorrent( manager, torrentHash ); - assert( t != NULL ); + assert( t ); assert( ( t->isRunning != 0 ) == ( t->reconnectTimer != NULL ) ); assert( ( t->isRunning != 0 ) == ( t->rechokeTimer != NULL ) ); @@ -1274,7 +1274,7 @@ tr_peerMgrAddTorrent( tr_peerMgr * manager, managerLock( manager ); - assert( tor != NULL ); + assert( tor ); assert( getExistingTorrent( manager, tor->info.hash ) == NULL ); t = torrentConstructor( manager, tor ); @@ -1292,7 +1292,7 @@ tr_peerMgrRemoveTorrent( tr_peerMgr * manager, managerLock( manager ); t = getExistingTorrent( manager, torrentHash ); - assert( t != NULL ); + assert( t ); stopTorrent( t ); tr_ptrArrayRemoveSorted( manager->torrents, t, torrentCompare ); torrentDestructor( t ); @@ -1905,7 +1905,7 @@ reconnectPulse( void * vtorrent ) myHandshakeDoneCB, mgr ); - assert( tr_peerIoGetTorrentHash( io ) != NULL ); + assert( tr_peerIoGetTorrentHash( io ) ); ++newConnectionsThisSecond; diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index 843df36de..cd3d9d4ea 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -336,7 +336,7 @@ myDebug( const char * file, int line, const char * fmt, ... ) { FILE * fp = tr_getLog( ); - if( fp != NULL ) + if( fp ) { va_list args; char timestr[64]; @@ -551,7 +551,7 @@ isPeerInteresting( const tr_peermsgs * msgs ) static void sendInterest( tr_peermsgs * msgs, int weAreInterested ) { - assert( msgs != NULL ); + assert( msgs ); assert( weAreInterested==0 || weAreInterested==1 ); msgs->info->clientIsInterested = weAreInterested; @@ -585,8 +585,8 @@ tr_peerMsgsSetChoke( tr_peermsgs * msgs, int choke ) { const time_t fibrillationTime = time(NULL) - MIN_CHOKE_PERIOD_SEC; - assert( msgs != NULL ); - assert( msgs->info != NULL ); + assert( msgs ); + assert( msgs->info ); assert( choke==0 || choke==1 ); if( msgs->info->chokeChangedAt > fibrillationTime ) @@ -621,7 +621,7 @@ static void sendFastSuggest( tr_peermsgs * msgs, uint32_t pieceIndex ) { - assert( msgs != NULL ); + assert( msgs ); if( tr_peerIoSupportsFEXT( msgs->io ) ) { @@ -633,7 +633,7 @@ sendFastSuggest( tr_peermsgs * msgs, static void sendFastHave( tr_peermsgs * msgs, int all ) { - assert( msgs != NULL ); + assert( msgs ); if( tr_peerIoSupportsFEXT( msgs->io ) ) { @@ -651,7 +651,7 @@ sendFastReject( tr_peermsgs * msgs, uint32_t offset, uint32_t length ) { - assert( msgs != NULL ); + assert( msgs ); if( tr_peerIoSupportsFEXT( msgs->io ) ) { @@ -684,7 +684,7 @@ static void sendFastAllowed( tr_peermsgs * msgs, uint32_t pieceIndex) { - assert( msgs != NULL ); + assert( msgs ); if( tr_peerIoSupportsFEXT( msgs->io ) ) { @@ -850,8 +850,8 @@ tr_peerMsgsAddRequest( tr_peermsgs * msgs, { struct peer_request req; - assert( msgs != NULL ); - assert( msgs->torrent != NULL ); + assert( msgs ); + assert( msgs->torrent ); assert( piece < msgs->torrent->info.pieceCount ); /** @@ -1492,8 +1492,8 @@ clientGotBlock( tr_peermsgs * msgs, tr_torrent * tor = msgs->torrent; const tr_block_index_t block = _tr_block( tor, req->index, req->offset ); - assert( msgs != NULL ); - assert( req != NULL ); + assert( msgs ); + assert( req ); if( req->length != tr_torBlockCountBytes( msgs->torrent, block ) ) { @@ -1907,8 +1907,8 @@ tr_peerMsgsNew( struct tr_torrent * torrent, { tr_peermsgs * m; - assert( info != NULL ); - assert( info->io != NULL ); + assert( info ); + assert( info->io ); m = tr_new0( tr_peermsgs, 1 ); m->publisher = tr_publisherNew( ); @@ -1952,7 +1952,7 @@ tr_peerMsgsNew( struct tr_torrent * torrent, void tr_peerMsgsFree( tr_peermsgs* msgs ) { - if( msgs != NULL ) + if( msgs ) { tr_timerFree( &msgs->pulseTimer ); tr_timerFree( &msgs->rateTimer ); diff --git a/libtransmission/ptrarray.c b/libtransmission/ptrarray.c index 15d26e6b4..4c3e2602f 100644 --- a/libtransmission/ptrarray.c +++ b/libtransmission/ptrarray.c @@ -56,9 +56,9 @@ tr_ptrArrayForeach( tr_ptrArray * t, PtrArrayForeachFunc func ) { int i; - assert( t != NULL ); - assert( t->items != NULL ); - assert( func != NULL ); + assert( t ); + assert( t->items ); + assert( func ); for( i=0; in_items; ++i ) func( t->items[i] ); @@ -67,10 +67,10 @@ tr_ptrArrayForeach( tr_ptrArray * t, PtrArrayForeachFunc func ) void tr_ptrArrayFree( tr_ptrArray * t, PtrArrayForeachFunc func ) { - assert( t != NULL ); - assert( t->items != NULL ); + assert( t ); + assert( t->items ); - if( func != NULL ) + if( func ) tr_ptrArrayForeach( t, func ); tr_free( t->items ); @@ -93,7 +93,7 @@ tr_ptrArrayBase( tr_ptrArray * t ) void* tr_ptrArrayNth( tr_ptrArray* t, int i ) { - assert( t != NULL ); + assert( t ); assert( i >= 0 ); assert( i < t->n_items ); diff --git a/libtransmission/publish.c b/libtransmission/publish.c index fdf2b19d5..5c9152e81 100644 --- a/libtransmission/publish.c +++ b/libtransmission/publish.c @@ -35,8 +35,8 @@ tr_publisherNew( void ) void tr_publisherFree( tr_publisher_t ** p ) { - assert( p != NULL ); - assert( *p != NULL ); + assert( p ); + assert( *p ); tr_list_free( &(*p)->list, NULL ); tr_free( *p ); diff --git a/libtransmission/ratecontrol.c b/libtransmission/ratecontrol.c index cdf6c6e2c..fd11114cd 100644 --- a/libtransmission/ratecontrol.c +++ b/libtransmission/ratecontrol.c @@ -96,7 +96,7 @@ tr_rcBytesLeft( const tr_ratecontrol * r ) { size_t bytes = 0; - if( r != NULL ) + if( r ) { const float cur = rateForInterval( r, SHORT_INTERVAL_MSEC ); const float max = r->limit; diff --git a/libtransmission/rpc.c b/libtransmission/rpc.c index f77b9db76..191bf0520 100644 --- a/libtransmission/rpc.c +++ b/libtransmission/rpc.c @@ -33,7 +33,7 @@ static void notify( tr_handle * session, int type, tr_torrent * tor ) { - if( session->rpc_func != NULL ) + if( session->rpc_func ) session->rpc_func( session, type, tor, session->rpc_func_user_data ); } diff --git a/libtransmission/session.c b/libtransmission/session.c index 921f65831..ae4ebe289 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -83,7 +83,7 @@ tr_getPeerId( void ) tr_encryption_mode tr_sessionGetEncryption( tr_session * session ) { - assert( session != NULL ); + assert( session ); return session->encryptionMode; } @@ -91,7 +91,7 @@ tr_sessionGetEncryption( tr_session * session ) void tr_sessionSetEncryption( tr_session * session, tr_encryption_mode mode ) { - assert( session != NULL ); + assert( session ); assert( mode==TR_ENCRYPTION_PREFERRED || mode==TR_ENCRYPTION_REQUIRED || mode==TR_PLAINTEXT_PREFERRED ); @@ -392,7 +392,7 @@ tr_sessionSetPeerPort( tr_handle * handle, int port ) int tr_sessionGetPeerPort( const tr_handle * h ) { - assert( h != NULL ); + assert( h ); return tr_sharedGetPeerPort( h->shared ); } @@ -844,7 +844,7 @@ tr_sessionSetTorrentFile( tr_handle * h, h->metainfoLookupCount, sizeof( struct tr_metainfo_lookup ), compareHashStringToLookupEntry ); - if( l != NULL ) + if( l ) { if( l->filename != filename ) { diff --git a/libtransmission/stats.c b/libtransmission/stats.c index 058032eac..1e77c2b1d 100644 --- a/libtransmission/stats.c +++ b/libtransmission/stats.c @@ -158,7 +158,7 @@ tr_sessionGetStats( const tr_handle * handle, tr_session_stats * setme ) { const struct tr_stats_handle * stats = getStats( handle ); - assert( stats != NULL ); + assert( stats ); *setme = stats->single; setme->secondsActive = time( NULL ) - stats->startTime; updateRatio( setme ); @@ -169,7 +169,7 @@ tr_sessionGetCumulativeStats( const tr_handle * handle, tr_session_stats * setme ) { const struct tr_stats_handle * stats = getStats( handle ); - assert( stats != NULL ); + assert( stats ); tr_session_stats current; tr_sessionGetStats( handle, ¤t ); addStats( setme, &stats->old, ¤t ); diff --git a/libtransmission/torrent-ctor.c b/libtransmission/torrent-ctor.c index 697aacaf5..b808c5987 100644 --- a/libtransmission/torrent-ctor.c +++ b/libtransmission/torrent-ctor.c @@ -107,7 +107,7 @@ tr_ctorSetMetainfoFromFile( tr_ctor * ctor, /* if no `name' field was set, then set it from the filename */ if( ctor->isSet_metainfo ) { tr_benc * info = tr_bencDictFindType( &ctor->metainfo, "info", TYPE_DICT ); - if( info != NULL ) { + if( info ) { tr_benc * name = tr_bencDictFindFirst( info, "name.utf-8", "name", NULL ); if( name == NULL ) name = tr_bencDictAdd( info, "name" ); diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 5b4ff7674..dea7f9177 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -232,7 +232,7 @@ onTrackerResponse( void * tracker UNUSED, void * vevent, void * user_data ) static int getBytePiece( const tr_info * info, uint64_t byteOffset ) { - assert( info != NULL ); + assert( info ); assert( info->pieceSize != 0 ); return byteOffset / info->pieceSize; @@ -244,7 +244,7 @@ initFilePieces ( tr_info * info, tr_file_index_t fileIndex ) tr_file * file; uint64_t firstByte, lastByte; - assert( info != NULL ); + assert( info ); assert( fileIndex < info->fileCount ); file = &info->files[fileIndex]; @@ -309,7 +309,7 @@ tr_torrentInitFilePieces( tr_torrent * tor ) uint64_t offset = 0; tr_info * inf = &tor->info; - assert( inf != NULL ); + assert( inf ); for( ff=0; fffileCount; ++ff ) { inf->files[ff].offset = offset; @@ -327,7 +327,7 @@ tr_torrentPromoteTracker( tr_torrent * tor, int pos ) int i; int tier; - assert( tor != NULL ); + assert( tor ); assert( ( 0 <= pos ) && ( pos < tor->info.trackerCount ) ); /* the tier of the tracker we're promoting */ @@ -632,7 +632,7 @@ tr_torrentManualUpdate( tr_torrent * tor ) int tr_torrentCanManualUpdate( const tr_torrent * tor ) { - return ( tor != NULL ) + return ( tor ) && ( tor->isRunning ) && ( tr_trackerCanManualAnnounce( tor->tracker ) ); } @@ -804,7 +804,7 @@ fileBytesCompleted ( const tr_torrent * tor, tr_file_index_t fileIndex ) const uint64_t lastBlockOffset = (file->offset + lastOffset) % tor->blockSize; uint64_t haveBytes = 0; - assert( tor != NULL ); + assert( tor ); assert( fileIndex < tor->info.fileCount ); assert( file->offset + file->length <= tor->info.totalSize ); assert( ( firstBlock < tor->blockCount ) || (!file->length && file->offset==tor->info.totalSize) ); @@ -879,7 +879,7 @@ tr_torrentPeers( const tr_torrent * tor, int * peerCount ) { tr_peer_stat * ret = NULL; - if( tor != NULL ) + if( tor ) ret = tr_peerMgrPeerStats( tor->handle->peerMgr, tor->info.hash, peerCount ); @@ -929,7 +929,7 @@ tr_torrentSetHasPiece( tr_torrent * tor, tr_piece_index_t pieceIndex, int has ) { tr_torrentLock( tor ); - assert( tor != NULL ); + assert( tor ); assert( pieceIndex < tor->info.pieceCount ); if( has ) @@ -951,7 +951,7 @@ freeTorrent( tr_torrent * tor ) tr_handle * h = tor->handle; tr_info * inf = &tor->info; - assert( tor != NULL ); + assert( tor ); assert( !tor->isRunning ); tr_globalLock( h ); @@ -1160,11 +1160,11 @@ getCompletionString( int type ) static void fireStatusChange( tr_torrent * tor, cp_status_t status ) { - assert( tor != NULL ); + assert( tor ); assert( status==TR_CP_INCOMPLETE || status==TR_CP_DONE || status==TR_CP_COMPLETE ); - if( tor->status_func != NULL ) - (tor->status_func)( tor, status, tor->status_func_user_data ); + if( tor->status_func ) + tor->status_func( tor, status, tor->status_func_user_data ); } void @@ -1172,7 +1172,7 @@ tr_torrentSetStatusCallback( tr_torrent * tor, tr_torrent_status_func func, void * user_data ) { - assert( tor != NULL ); + assert( tor ); tor->status_func = func; tor->status_func_user_data = user_data; } @@ -1237,7 +1237,7 @@ tr_torrentInitFilePriority( tr_torrent * tor, tr_piece_index_t i; tr_file * file; - assert( tor != NULL ); + assert( tor ); assert( fileIndex < tor->info.fileCount ); assert( priority==TR_PRI_LOW || priority==TR_PRI_NORMAL || priority==TR_PRI_HIGH ); @@ -1269,7 +1269,7 @@ tr_torrentGetFilePriority( const tr_torrent * tor, tr_file_index_t file ) tr_priority_t ret; tr_torrentLock( tor ); - assert( tor != NULL ); + assert( tor ); assert( file < tor->info.fileCount ); ret = tor->info.files[file].priority; tr_torrentUnlock( tor ); diff --git a/libtransmission/utils.c b/libtransmission/utils.c index 62a62ccaf..9d728e535 100644 --- a/libtransmission/utils.c +++ b/libtransmission/utils.c @@ -176,7 +176,7 @@ void tr_deepLog( const char * file, int line, const char * name, const char * fmt, ... ) { FILE * fp = tr_getLog( ); - if( fp != NULL ) + if( fp ) { va_list args; char timestr[64]; @@ -652,7 +652,7 @@ tr_strndup( const void * in, int len ) { out = tr_strdup( in ); } - else if( in != NULL ) + else if( in ) { out = tr_malloc( len+1 ); memcpy( out, in, len ); @@ -823,8 +823,8 @@ tr_bitfieldFindTrue( const tr_bitfield * bitfield, int tr_bitfieldAdd( tr_bitfield * bitfield, size_t nth ) { - assert( bitfield != NULL ); - assert( bitfield->bits != NULL ); + assert( bitfield ); + assert( bitfield->bits ); if( nth >= bitfield->bitCount ) return -1; @@ -850,8 +850,8 @@ int tr_bitfieldRem( tr_bitfield * bitfield, size_t nth ) { - assert( bitfield != NULL ); - assert( bitfield->bits != NULL ); + assert( bitfield ); + assert( bitfield->bits ); if( nth >= bitfield->bitCount ) return -1; @@ -997,8 +997,8 @@ tr_strlcpy(char *dst, const char *src, size_t siz) const char *s = src; size_t n = siz; - assert( s != NULL ); - assert( d != NULL ); + assert( s ); + assert( d ); /* Copy as many bytes as will fit */ if (n != 0) { diff --git a/libtransmission/verify.c b/libtransmission/verify.c index fef7958a6..95516b1ad 100644 --- a/libtransmission/verify.c +++ b/libtransmission/verify.c @@ -36,8 +36,8 @@ static void fireCheckDone( tr_torrent * torrent, tr_verify_done_cb verify_done_cb ) { - if( verify_done_cb != NULL ) - (*verify_done_cb)( torrent ); + if( verify_done_cb ) + verify_done_cb( torrent ); } static struct verify_node currentNode; -- 2.40.0