(trunk libT) fix a few -Wconversion warnings

This commit is contained in:
Charles Kerr
2010-07-01 15:14:35 +00:00
parent 4ad26f7910
commit 2c85178f9b
3 changed files with 20 additions and 21 deletions

View File

@@ -79,8 +79,9 @@ blocklistClose( tr_blocklist * b )
static void
blocklistLoad( tr_blocklist * b )
{
int fd;
struct stat st;
int fd;
size_t byteCount;
struct stat st;
const char * err_fmt = _( "Couldn't read \"%1$s\": %2$s" );
blocklistClose( b );
@@ -95,7 +96,8 @@ blocklistLoad( tr_blocklist * b )
return;
}
b->rules = mmap( NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0 );
byteCount = (size_t) st.st_size;
b->rules = mmap( NULL, byteCount, PROT_READ, MAP_PRIVATE, fd, 0 );
if( !b->rules )
{
tr_err( err_fmt, b->filename, tr_strerror( errno ) );
@@ -103,9 +105,9 @@ blocklistLoad( tr_blocklist * b )
return;
}
b->byteCount = st.st_size;
b->ruleCount = st.st_size / sizeof( struct tr_ip_range );
b->fd = fd;
b->byteCount = byteCount;
b->ruleCount = byteCount / sizeof( struct tr_ip_range );
{
char * base = tr_basename( b->filename );
@@ -145,8 +147,7 @@ blocklistDelete( tr_blocklist * b )
***/
tr_blocklist *
_tr_blocklistNew( const char * filename,
int isEnabled )
_tr_blocklistNew( const char * filename, tr_bool isEnabled )
{
tr_blocklist * b;

View File

@@ -21,7 +21,7 @@ struct tr_address;
typedef struct tr_blocklist tr_blocklist;
tr_blocklist* _tr_blocklistNew ( const char * filename,
int isEnabled );
tr_bool isEnabled );
int _tr_blocklistExists ( const tr_blocklist * b );

View File

@@ -88,12 +88,12 @@ getFiles( const char * dir,
return list;
}
static int
static uint32_t
bestPieceSize( uint64_t totalSize )
{
const uint64_t GiB = 1073741824;
const uint64_t MiB = 1048576;
const uint64_t KiB = 1024;
const uint32_t GiB = 1073741824;
const uint32_t MiB = 1048576;
const uint32_t KiB = 1024;
if( totalSize >= ( 2 * GiB ) ) return 2 * MiB;
if( totalSize >= ( 1 * GiB ) ) return 1 * MiB;
@@ -226,21 +226,19 @@ getHashInfo( tr_metainfo_builder * b )
}
while( totalRemain )
{
uint8_t * bufptr = buf;
const uint64_t thisPieceSize =
MIN( (uint32_t)b->pieceSize, totalRemain );
uint64_t pieceRemain = thisPieceSize;
uint8_t * bufptr = buf;
const uint32_t thisPieceSize = (uint32_t) MIN( b->pieceSize, totalRemain );
uint32_t leftInPiece = thisPieceSize;
assert( b->pieceIndex < b->pieceCount );
while( pieceRemain )
while( leftInPiece )
{
const uint64_t n_this_pass =
MIN( ( b->files[fileIndex].size - off ), pieceRemain );
const size_t n_this_pass = (size_t) MIN( ( b->files[fileIndex].size - off ), leftInPiece );
read( fd, bufptr, n_this_pass );
bufptr += n_this_pass;
off += n_this_pass;
pieceRemain -= n_this_pass;
leftInPiece -= n_this_pass;
if( off == b->files[fileIndex].size )
{
off = 0;
@@ -265,7 +263,7 @@ getHashInfo( tr_metainfo_builder * b )
}
assert( bufptr - buf == (int)thisPieceSize );
assert( pieceRemain == 0 );
assert( leftInPiece == 0 );
tr_sha1( walk, buf, thisPieceSize, NULL );
walk += SHA_DIGEST_LENGTH;