tree-wide: add FORMAT_BYTES()

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-07-09 11:11:21 +02:00
parent 6c1abe8807
commit 2b59bf51a0
25 changed files with 170 additions and 258 deletions
+2 -5
View File
@@ -62,11 +62,8 @@ static void progress_show(ProgressInfo *p) {
if (p->size == 0)
log_info("Copying tree, currently at '%s'...", p->path);
else {
char buffer[FORMAT_BYTES_MAX];
log_info("Copying tree, currently at '%s' (@%s)...", p->path, format_bytes(buffer, sizeof(buffer), p->size));
}
else
log_info("Copying tree, currently at '%s' (@%s)...", p->path, FORMAT_BYTES(p->size));
}
static int progress_path(const char *path, const struct stat *st, void *userdata) {
+2 -5
View File
@@ -501,15 +501,13 @@ static size_t pull_job_header_callback(void *contents, size_t size, size_t nmemb
(void) safe_atou64(length, &j->content_length);
if (j->content_length != UINT64_MAX) {
char bytes[FORMAT_BYTES_MAX];
if (j->content_length > j->compressed_max) {
log_error("Content too large.");
r = -EFBIG;
goto fail;
}
log_info("Downloading %s for %s.", format_bytes(bytes, sizeof(bytes), j->content_length), j->url);
log_info("Downloading %s for %s.", FORMAT_BYTES(j->content_length), j->url);
}
return sz;
@@ -556,7 +554,6 @@ static int pull_job_progress_callback(void *userdata, curl_off_t dltotal, curl_o
dlnow < dltotal) {
if (n - j->start_usec > USEC_PER_SEC && dlnow > 0) {
char y[FORMAT_BYTES_MAX];
usec_t left, done;
done = n - j->start_usec;
@@ -566,7 +563,7 @@ static int pull_job_progress_callback(void *userdata, curl_off_t dltotal, curl_o
percent,
j->url,
FORMAT_TIMESPAN(left, USEC_PER_SEC),
format_bytes(y, sizeof(y), (uint64_t) ((double) dlnow / ((double) done / (double) USEC_PER_SEC))));
FORMAT_BYTES((uint64_t) ((double) dlnow / ((double) done / (double) USEC_PER_SEC))));
} else
log_info("Got %u%% of %s.", percent, j->url);