diff --git a/daemon/remote.c b/daemon/remote.c index 39dc9e765..0fb4d7ceb 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -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 ); diff --git a/libtransmission/utils.c b/libtransmission/utils.c index b6cd13de7..2df7e66b8 100644 --- a/libtransmission/utils.c +++ b/libtransmission/utils.c @@ -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 ); } diff --git a/libtransmission/utils.h b/libtransmission/utils.h index ea592aa05..826d866a5 100644 --- a/libtransmission/utils.h +++ b/libtransmission/utils.h @@ -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 );