Changeset 6838


Ignore:
Timestamp:
Oct 2, 2008, 8:30:29 PM (12 years ago)
Author:
charles
Message:

(libT) eliminating tr_errno, part 1: make tr_ioTestPiece return an int instead of a tr_errno.

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/inout.c

    r6832 r6838  
    267267}
    268268
    269 tr_errno
     269int
    270270tr_ioTestPiece( const tr_torrent * tor,
    271271                int                pieceIndex )
    272272{
    273     int     err;
    274273    uint8_t hash[SHA_DIGEST_LENGTH];
    275 
    276     err  = recalculateHash( tor, pieceIndex, hash );
    277 
    278     if( !err && memcmp( hash, tor->info.pieces[pieceIndex].hash,
    279                         SHA_DIGEST_LENGTH ) )
    280         err = TR_ERROR_IO_CHECKSUM;
    281 
    282     tr_tordbg ( tor, "piece %d hash check: %s",
    283                pieceIndex, ( err ? "FAILED" : "OK" ) );
    284 
    285     return err;
    286 }
    287 
     274    const tr_errno err = recalculateHash( tor, pieceIndex, hash );
     275    return !err && !memcmp( hash, tor->info.pieces[pieceIndex].hash, SHA_DIGEST_LENGTH );
     276}
     277
  • trunk/libtransmission/inout.h

    r6795 r6838  
    5151
    5252/**
    53  * returns 0 if the piece matches its metainfo's SHA1 checksum,
    54  * or TR_ERROR_IO_* if there was a problem reading the piece,
    55  * or TR_ERROR if the checksum didn't match.
     53 * returns nonzero if the piece matches its metainfo's SHA1 checksum.
    5654 */
    57 tr_errno tr_ioTestPiece( const tr_torrent*,
    58                          int   piece );
     55int tr_ioTestPiece( const tr_torrent*,
     56                    int   piece );
    5957
    6058
  • trunk/libtransmission/peer-mgr.c

    r6832 r6838  
    960960            {
    961961                const tr_piece_index_t p = e->pieceIndex;
    962                 const tr_errno         err = tr_ioTestPiece( tor, p );
    963 
    964                 if( err )
     962                const int              ok = tr_ioTestPiece( tor, p );
     963
     964                if( !ok )
    965965                {
    966966                    tr_torerr( tor,
    967                               _(
    968                                   "Piece %lu, which was just downloaded, failed its checksum test: %s" ),
    969                               (unsigned long)p, tr_errorString( err ) );
     967                              _( "Piece %lu, which was just downloaded, failed its checksum test" ),
     968                              (unsigned long)p );
    970969                }
    971970
    972                 tr_torrentSetHasPiece( tor, p, !err );
     971                tr_torrentSetHasPiece( tor, p, ok );
    973972                tr_torrentSetPieceChecked( tor, p, TRUE );
    974                 tr_peerMgrSetBlame( tor->session->peerMgr, tor->info.hash, p,
    975                                     !err );
    976 
    977                 if( err )
     973                tr_peerMgrSetBlame( tor->session->peerMgr, tor->info.hash, p, ok );
     974
     975                if( !ok )
    978976                    gotBadPiece( t, p );
    979977                else
  • trunk/libtransmission/verify.c

    r6795 r6838  
    8686            const int      wasComplete = tr_cpPieceIsComplete(
    8787                tor->completion, i );
    88             const tr_errno err = tr_ioTestPiece( tor, i );
    89 
    90             if( !err ) /* yay */
     88
     89            if( tr_ioTestPiece( tor, i ) ) /* yay */
    9190            {
    9291                tr_torrentSetHasPiece( tor, i, TRUE );
Note: See TracChangeset for help on using the changeset viewer.