From f1221f958f38303665a4361f4ae68b80d39fa586 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 23 Feb 2010 06:05:18 +0000 Subject: [PATCH] (trunk libT) dead code removal -- the buffer & buflen arguments to tr_ioTestPiece() were unused --- libtransmission/inout.c | 21 +++++---------------- libtransmission/inout.h | 8 +------- libtransmission/peer-mgr.c | 2 +- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/libtransmission/inout.c b/libtransmission/inout.c index f32e8dd23..6a6c11886 100644 --- a/libtransmission/inout.c +++ b/libtransmission/inout.c @@ -290,23 +290,15 @@ tr_ioWrite( tr_torrent * tor, static tr_bool recalculateHash( tr_torrent * tor, tr_piece_index_t pieceIndex, - void * buffer, - size_t buflen, uint8_t * setme ) { size_t bytesLeft; uint32_t offset = 0; tr_bool success = TRUE; - uint8_t stackbuf[MAX_STACK_ARRAY_SIZE]; + uint8_t buffer[MAX_STACK_ARRAY_SIZE]; + const size_t buflen = MAX_STACK_ARRAY_SIZE; SHA_CTX sha; - /* fallback buffer */ - if( ( buffer == NULL ) || ( buflen < 1 ) ) - { - buffer = stackbuf; - buflen = sizeof( stackbuf ); - } - assert( tor != NULL ); assert( pieceIndex < tor->info.pieceCount ); assert( buffer != NULL ); @@ -334,13 +326,10 @@ recalculateHash( tr_torrent * tor, } tr_bool -tr_ioTestPiece( tr_torrent * tor, - tr_piece_index_t pieceIndex, - void * buffer, - size_t buflen ) +tr_ioTestPiece( tr_torrent * tor, tr_piece_index_t piece ) { uint8_t hash[SHA_DIGEST_LENGTH]; - return recalculateHash( tor, pieceIndex, buffer, buflen, hash ) - && !memcmp( hash, tor->info.pieces[pieceIndex].hash, SHA_DIGEST_LENGTH ); + return recalculateHash( tor, piece, hash ) + && !memcmp( hash, tor->info.pieces[piece].hash, SHA_DIGEST_LENGTH ); } diff --git a/libtransmission/inout.h b/libtransmission/inout.h index 7eddb89b8..e06da02ff 100644 --- a/libtransmission/inout.h +++ b/libtransmission/inout.h @@ -52,15 +52,9 @@ int tr_ioWrite( struct tr_torrent * tor, /** * @brief Test to see if the piece matches its metainfo's SHA1 checksum. - * - * @param optionalBuffer if calling tr_ioTestPiece() repeatedly, you can - * get best performance by providing a buffer with - * tor->info.pieceSize bytes. */ tr_bool tr_ioTestPiece( tr_torrent * tor, - tr_piece_index_t piece, - void * optionalBuffer, - size_t optionalBufferLen ); + tr_piece_index_t piece ); /** diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 1b0bcf6ca..6b8075a49 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -1335,7 +1335,7 @@ peerCallbackFunc( void * vpeer, void * vevent, void * vt ) if( tr_cpPieceIsComplete( &tor->completion, e->pieceIndex ) ) { const tr_piece_index_t p = e->pieceIndex; - const tr_bool ok = tr_ioTestPiece( tor, p, NULL, 0 ); + const tr_bool ok = tr_ioTestPiece( tor, p ); if( !ok ) {