(trunk) #3914 "strlsize() passes variable of incompatible type to the tr_formatter_size_B()" -- fixed.

This commit is contained in:
Jordan Lee 2011-01-19 18:14:01 +00:00
parent 3c14abd183
commit 06884387da
3 changed files with 9 additions and 7 deletions

View File

@ -172,7 +172,9 @@ strlmem( char * buf, int64_t bytes, size_t buflen )
static char*
strlsize( char * buf, int64_t bytes, size_t buflen )
{
if( !bytes )
if( bytes < 1 )
tr_strlcpy( buf, "Unknown", buflen );
else if( !bytes )
tr_strlcpy( buf, "None", buflen );
else
tr_formatter_size_B( buf, bytes, buflen );

View File

@ -1659,7 +1659,7 @@ tr_realpath( const char * path, char * resolved_path )
struct formatter_unit
{
char * name;
uint64_t value;
int64_t value;
};
struct formatter_units
@ -1694,7 +1694,7 @@ formatter_init( struct formatter_units * units,
static char*
formatter_get_size_str( const struct formatter_units * u,
char * buf, uint64_t bytes, size_t buflen )
char * buf, int64_t bytes, size_t buflen )
{
int precision;
double value;
@ -1729,7 +1729,7 @@ tr_formatter_size_init( unsigned int kilo,
}
char*
tr_formatter_size_B( char * buf, uint64_t bytes, size_t buflen )
tr_formatter_size_B( char * buf, int64_t bytes, size_t buflen )
{
return formatter_get_size_str( &size_units, buf, bytes, buflen );
}
@ -1784,7 +1784,7 @@ tr_formatter_mem_init( unsigned int kilo,
}
char*
tr_formatter_mem_B( char * buf, uint64_t bytes_per_second, size_t buflen )
tr_formatter_mem_B( char * buf, int64_t bytes_per_second, size_t buflen )
{
return formatter_get_size_str( &mem_units, buf, bytes_per_second, buflen );
}

View File

@ -585,13 +585,13 @@ extern unsigned int tr_size_K;
char* tr_formatter_speed_KBps( char * buf, double KBps, size_t buflen );
/* format a memory size from bytes into a user-readable string. */
char* tr_formatter_mem_B( char * buf, uint64_t bytes, size_t buflen );
char* tr_formatter_mem_B( char * buf, int64_t bytes, size_t buflen );
/* format a memory size from MB into a user-readable string. */
static inline char* tr_formatter_mem_MB( char * buf, double MBps, size_t buflen ) { return tr_formatter_mem_B( buf, MBps * tr_mem_K * tr_mem_K, buflen ); }
/* format a file size from bytes into a user-readable string. */
char* tr_formatter_size_B( char * buf, uint64_t bytes, size_t buflen );
char* tr_formatter_size_B( char * buf, int64_t bytes, size_t buflen );
void tr_formatter_get_units( struct tr_benc * dict );