mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +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 startBlock = tr_pieceStartBlock( piece );
|
||||||
const int endBlock = startBlock + n_blocks;
|
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;
|
cp->completeBlocks[piece] = 0;
|
||||||
tr_bitfieldRemRange ( cp->blockBitfield, startBlock, endBlock );
|
tr_bitfieldRemRange ( cp->blockBitfield, startBlock, endBlock );
|
||||||
tr_bitfieldRem( cp->pieceBitfield, piece );
|
tr_bitfieldRem( cp->pieceBitfield, piece );
|
||||||
|
|
|
@ -220,6 +220,10 @@ checkPiece ( tr_torrent_t * tor, int pieceIndex )
|
||||||
void
|
void
|
||||||
tr_ioCheckFiles( tr_torrent_t * tor )
|
tr_ioCheckFiles( tr_torrent_t * tor )
|
||||||
{
|
{
|
||||||
|
assert( tor != NULL );
|
||||||
|
assert( tor->completion != NULL );
|
||||||
|
assert( tor->info.pieceCount > 0 );
|
||||||
|
|
||||||
if( tor->uncheckedPieces != NULL )
|
if( tor->uncheckedPieces != NULL )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -574,7 +574,7 @@ tr_bitfieldIsEmpty( const tr_bitfield_t * bitfield )
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BIN(nth) ((unsigned int)nth/8u)
|
#define BIN(nth) (nth>>3)
|
||||||
#define BIT(nth) (1<<(7-(nth%8)))
|
#define BIT(nth) (1<<(7-(nth%8)))
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -606,7 +606,11 @@ tr_bitfieldRem( tr_bitfield_t * bitfield,
|
||||||
size_t nth )
|
size_t nth )
|
||||||
{
|
{
|
||||||
if( bitfield != NULL )
|
if( bitfield != NULL )
|
||||||
bitfield->bits[BIN(nth)] &= ~BIT(nth);
|
{
|
||||||
|
const int bin = BIN(nth);
|
||||||
|
assert( bin < bitfield->len );
|
||||||
|
bitfield->bits[bin] &= ~BIT(nth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue