From 34776b10d6721a1e4e2fa75feefdc971f864c47b Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Fri, 10 Feb 2012 13:47:40 +0100 Subject: fb-helper.c: change format_bytes() arguments and buffer size Signed-off-by: Florian Pritz --- fb-helper.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fb-helper.c b/fb-helper.c index b2d6e66..2fa248c 100644 --- a/fb-helper.c +++ b/fb-helper.c @@ -25,8 +25,8 @@ #include #define FORMAT_ARRAY_SIZE 5 -#define FORMAT_BYTES_BUFFER 64 -#define FORMAT_TIME_BUFFER 32 +#define FORMAT_BYTES_BUFFER 16 +#define FORMAT_TIME_BUFFER 16 #define SAMPLE_COUNT 15 #define UNUSED __attribute__((unused)) @@ -78,7 +78,7 @@ int load_file(const char *fn, char **data, size_t *data_size) return 0; } -void format_bytes(double bytes, char *buf) +void format_bytes(char *buf, int bufsize, double bytes) { double size = bytes; int suffix_pos = 0; @@ -95,9 +95,9 @@ void format_bytes(double bytes, char *buf) // don't print decimals for bytes if (suffix_pos != 0) - snprintf(buf, FORMAT_BYTES_BUFFER, "%.2f%s", size, suffix[suffix_pos]); + snprintf(buf, bufsize, "%.2f%s", size, suffix[suffix_pos]); else - snprintf(buf, FORMAT_BYTES_BUFFER, "%.0f%s", size, suffix[suffix_pos]); + snprintf(buf, bufsize, "%.0f%s", size, suffix[suffix_pos]); } void format_time(char *buf, int bufsize, time_t time) @@ -183,8 +183,8 @@ int progress_callback( format_time(eta, sizeof(eta), time_remaining); } - format_bytes(ulnow, (char *)&total); - format_bytes(ulspeed, (char *)&speed); + format_bytes((char *)&total, sizeof(total), ulnow); + format_bytes((char *)&speed, sizeof(speed), ulspeed); /* print the progress */ printed = fprintf(stderr, -- cgit v1.2.3-24-g4f1b