mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
add some assertion tests for #transmission
This commit is contained in:
parent
8c79683c83
commit
79b85b36ab
3 changed files with 18 additions and 2 deletions
|
@ -126,6 +126,14 @@ void tr_cpPieceRem( tr_completion_t * cp, int piece )
|
|||
const int startBlock = tr_pieceStartBlock( piece );
|
||||
const int endBlock = startBlock + n_blocks;
|
||||
|
||||
assert( cp != NULL );
|
||||
assert( 0 <= piece );
|
||||
assert( piece < tor->info.pieceCount );
|
||||
assert( 0 <= startBlock );
|
||||
assert( startBlock < tor->blockCount );
|
||||
assert( startBlock <= endBlock );
|
||||
assert( endBlock < tor->blockCount );
|
||||
|
||||
cp->completeBlocks[piece] = 0;
|
||||
tr_bitfieldRemRange ( cp->blockBitfield, startBlock, endBlock );
|
||||
tr_bitfieldRem( cp->pieceBitfield, piece );
|
||||
|
|
|
@ -220,6 +220,10 @@ checkPiece ( tr_torrent_t * tor, int pieceIndex )
|
|||
void
|
||||
tr_ioCheckFiles( tr_torrent_t * tor )
|
||||
{
|
||||
assert( tor != NULL );
|
||||
assert( tor->completion != NULL );
|
||||
assert( tor->info.pieceCount > 0 );
|
||||
|
||||
if( tor->uncheckedPieces != NULL )
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -574,7 +574,7 @@ tr_bitfieldIsEmpty( const tr_bitfield_t * bitfield )
|
|||
return 1;
|
||||
}
|
||||
|
||||
#define BIN(nth) ((unsigned int)nth/8u)
|
||||
#define BIN(nth) (nth>>3)
|
||||
#define BIT(nth) (1<<(7-(nth%8)))
|
||||
|
||||
int
|
||||
|
@ -606,7 +606,11 @@ tr_bitfieldRem( tr_bitfield_t * bitfield,
|
|||
size_t nth )
|
||||
{
|
||||
if( bitfield != NULL )
|
||||
bitfield->bits[BIN(nth)] &= ~BIT(nth);
|
||||
{
|
||||
const int bin = BIN(nth);
|
||||
assert( bin < bitfield->len );
|
||||
bitfield->bits[bin] &= ~BIT(nth);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue