1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 08:43:27 +00:00

add some assertion tests for #transmission

This commit is contained in:
Charles Kerr 2007-07-24 20:49:47 +00:00
parent 8c79683c83
commit 79b85b36ab
3 changed files with 18 additions and 2 deletions

View file

@ -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 );

View file

@ -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;

View file

@ -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