Changeset 2485


Ignore:
Timestamp:
Jul 24, 2007, 8:49:47 PM (15 years ago)
Author:
charles
Message:

add some assertion tests for #transmission

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.c

    r2481 r2485  
    127127    const int endBlock   = startBlock + n_blocks;
    128128
     129    assert( cp != NULL );
     130    assert( 0 <= piece );
     131    assert( piece < tor->info.pieceCount );
     132    assert( 0 <= startBlock );
     133    assert( startBlock < tor->blockCount );
     134    assert( startBlock <= endBlock );
     135    assert( endBlock < tor->blockCount );
     136
    129137    cp->completeBlocks[piece] = 0;
    130138    tr_bitfieldRemRange ( cp->blockBitfield, startBlock, endBlock );
  • trunk/libtransmission/inout.c

    r2474 r2485  
    221221tr_ioCheckFiles( tr_torrent_t * tor )
    222222{
     223    assert( tor != NULL );
     224    assert( tor->completion != NULL );
     225    assert( tor->info.pieceCount > 0 );
     226
    223227    if( tor->uncheckedPieces != NULL )
    224228    {
  • trunk/libtransmission/utils.c

    r2484 r2485  
    575575}
    576576
    577 #define BIN(nth) ((unsigned int)nth/8u)
     577#define BIN(nth) (nth>>3)
    578578#define BIT(nth) (1<<(7-(nth%8)))
    579579
     
    607607{
    608608    if( bitfield != NULL )
    609         bitfield->bits[BIN(nth)] &= ~BIT(nth);
     609    {
     610        const int bin = BIN(nth);
     611        assert( bin < bitfield->len );
     612        bitfield->bits[bin] &= ~BIT(nth);
     613    }
    610614}
    611615
Note: See TracChangeset for help on using the changeset viewer.