Changeset 6841


Ignore:
Timestamp:
Oct 3, 2008, 12:51:40 AM (13 years ago)
Author:
charles
Message:

(libT) eliminating tr_errno, part 4: don't use it in recalculateHash()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/inout.c

    r6838 r6841  
    232232****/
    233233
    234 static tr_errno
     234static int
    235235recalculateHash( const tr_torrent * tor,
    236236                 tr_piece_index_t   pieceIndex,
     
    240240    size_t   n;
    241241    uint32_t offset = 0;
    242     tr_errno err =  0;
     242    int      success = TRUE;
    243243    SHA_CTX  sha;
    244244
     
    254254        uint8_t   buf[2048];
    255255        const int len = MIN( bytesLeft, sizeof( buf ) );
    256         if( ( err = tr_ioRead( tor, pieceIndex, offset, len, buf ) ) )
     256        success = !tr_ioRead( tor, pieceIndex, offset, len, buf );
     257        if( !success )
    257258            break;
    258259        SHA1_Update( &sha, buf, len );
     
    261262    }
    262263
    263     if( !err )
     264    if( success )
    264265        SHA1_Final( setme, &sha );
    265266
    266     return err;
     267    return success;
    267268}
    268269
     
    272273{
    273274    uint8_t hash[SHA_DIGEST_LENGTH];
    274     const tr_errno err = recalculateHash( tor, pieceIndex, hash );
    275     return !err && !memcmp( hash, tor->info.pieces[pieceIndex].hash, SHA_DIGEST_LENGTH );
    276 }
    277 
     275    const int recalculated = recalculateHash( tor, pieceIndex, hash );
     276    return recalculated && !memcmp( hash, tor->info.pieces[pieceIndex].hash, SHA_DIGEST_LENGTH );
     277}
     278
Note: See TracChangeset for help on using the changeset viewer.