(trunk libT) dead code removal -- the buffer & buflen arguments to tr_ioTestPiece() were unused

This commit is contained in:
Charles Kerr 2010-02-23 06:05:18 +00:00
parent 8973806d44
commit f1221f958f
3 changed files with 7 additions and 24 deletions

View File

@ -290,23 +290,15 @@ tr_ioWrite( tr_torrent * tor,
static tr_bool static tr_bool
recalculateHash( tr_torrent * tor, recalculateHash( tr_torrent * tor,
tr_piece_index_t pieceIndex, tr_piece_index_t pieceIndex,
void * buffer,
size_t buflen,
uint8_t * setme ) uint8_t * setme )
{ {
size_t bytesLeft; size_t bytesLeft;
uint32_t offset = 0; uint32_t offset = 0;
tr_bool success = TRUE; 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; SHA_CTX sha;
/* fallback buffer */
if( ( buffer == NULL ) || ( buflen < 1 ) )
{
buffer = stackbuf;
buflen = sizeof( stackbuf );
}
assert( tor != NULL ); assert( tor != NULL );
assert( pieceIndex < tor->info.pieceCount ); assert( pieceIndex < tor->info.pieceCount );
assert( buffer != NULL ); assert( buffer != NULL );
@ -334,13 +326,10 @@ recalculateHash( tr_torrent * tor,
} }
tr_bool tr_bool
tr_ioTestPiece( tr_torrent * tor, tr_ioTestPiece( tr_torrent * tor, tr_piece_index_t piece )
tr_piece_index_t pieceIndex,
void * buffer,
size_t buflen )
{ {
uint8_t hash[SHA_DIGEST_LENGTH]; uint8_t hash[SHA_DIGEST_LENGTH];
return recalculateHash( tor, pieceIndex, buffer, buflen, hash ) return recalculateHash( tor, piece, hash )
&& !memcmp( hash, tor->info.pieces[pieceIndex].hash, SHA_DIGEST_LENGTH ); && !memcmp( hash, tor->info.pieces[piece].hash, SHA_DIGEST_LENGTH );
} }

View File

@ -52,15 +52,9 @@ int tr_ioWrite( struct tr_torrent * tor,
/** /**
* @brief Test to see if the piece matches its metainfo's SHA1 checksum. * @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_bool tr_ioTestPiece( tr_torrent * tor,
tr_piece_index_t piece, tr_piece_index_t piece );
void * optionalBuffer,
size_t optionalBufferLen );
/** /**

View File

@ -1335,7 +1335,7 @@ peerCallbackFunc( void * vpeer, void * vevent, void * vt )
if( tr_cpPieceIsComplete( &tor->completion, e->pieceIndex ) ) if( tr_cpPieceIsComplete( &tor->completion, e->pieceIndex ) )
{ {
const tr_piece_index_t p = 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 ) if( !ok )
{ {