summaryrefslogtreecommitdiffstats
path: root/src/import
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-07-14 09:14:08 +0200
committerGitHub <noreply@github.com>2021-07-14 09:14:08 +0200
commite18f21e34924d02dd7c330a644149d89fcc38042 (patch)
tree28782cf9a88b12e13f57e10069a795c4b6998865 /src/import
parentnetwork: update interface name stored in various network engines (diff)
parentnetworkd: minor refactoring (diff)
downloadsystemd-e18f21e34924d02dd7c330a644149d89fcc38042.tar.xz
systemd-e18f21e34924d02dd7c330a644149d89fcc38042.zip
Merge pull request #20109 from keszybz/timestamp-macros
Add macros that define scratch buffer internally for timestamp/timespan formatting
Diffstat (limited to 'src/import')
-rw-r--r--src/import/import-fs.c7
-rw-r--r--src/import/pull-job.c13
2 files changed, 6 insertions, 14 deletions
diff --git a/src/import/import-fs.c b/src/import/import-fs.c
index a12ee77ef9..e8c3740879 100644
--- a/src/import/import-fs.c
+++ b/src/import/import-fs.c
@@ -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) {
diff --git a/src/import/pull-job.c b/src/import/pull-job.c
index 9ab3776e50..038fa2be8b 100644
--- a/src/import/pull-job.c
+++ b/src/import/pull-job.c
@@ -501,15 +501,12 @@ 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;
+ r = log_error_errno(SYNTHETIC_ERRNO(EFBIG), "Content too large.");
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;
@@ -554,10 +551,8 @@ static int pull_job_progress_callback(void *userdata, curl_off_t dltotal, curl_o
if (n > j->last_status_usec + USEC_PER_SEC &&
percent != j->progress_percent &&
dlnow < dltotal) {
- char buf[FORMAT_TIMESPAN_MAX];
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,8 +561,8 @@ static int pull_job_progress_callback(void *userdata, curl_off_t dltotal, curl_o
log_info("Got %u%% of %s. %s left at %s/s.",
percent,
j->url,
- format_timespan(buf, sizeof(buf), left, USEC_PER_SEC),
- format_bytes(y, sizeof(y), (uint64_t) ((double) dlnow / ((double) done / (double) USEC_PER_SEC))));
+ FORMAT_TIMESPAN(left, 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);