summaryrefslogtreecommitdiffstats
path: root/src/import/import-raw.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-11-23 19:52:35 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-11-23 19:53:18 +0100
commit0d94088e4e9e00f5ca9afdb8e68c94558fe23268 (patch)
tree26f8388c8cb35e437a785d093c360f54509dc57f /src/import/import-raw.c
parentimport: use _cleanup_ attribute for CURL object (diff)
downloadsystemd-0d94088e4e9e00f5ca9afdb8e68c94558fe23268.tar.xz
systemd-0d94088e4e9e00f5ca9afdb8e68c94558fe23268.zip
import: use structured initializers
Diffstat (limited to 'src/import/import-raw.c')
-rw-r--r--src/import/import-raw.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/import/import-raw.c b/src/import/import-raw.c
index f62247cabd..e8adaae740 100644
--- a/src/import/import-raw.c
+++ b/src/import/import-raw.c
@@ -94,26 +94,33 @@ int raw_import_new(
void *userdata) {
_cleanup_(raw_import_unrefp) RawImport *i = NULL;
+ _cleanup_free_ char *root = NULL;
+ bool grow;
int r;
assert(ret);
- i = new0(RawImport, 1);
- if (!i)
+ root = strdup(image_root ?: "/var/lib/machines");
+ if (!root)
return -ENOMEM;
- i->input_fd = i->output_fd = -1;
- i->on_finished = on_finished;
- i->userdata = userdata;
-
- RATELIMIT_INIT(i->progress_rate_limit, 100 * USEC_PER_MSEC, 1);
- i->last_percent = (unsigned) -1;
+ grow = path_startswith(root, "/var/lib/machines");
- i->image_root = strdup(image_root ?: "/var/lib/machines");
- if (!i->image_root)
+ i = new(RawImport, 1);
+ if (!i)
return -ENOMEM;
- i->grow_machine_directory = path_startswith(i->image_root, "/var/lib/machines");
+ *i = (RawImport) {
+ .input_fd = -1,
+ .output_fd = -1,
+ .on_finished = on_finished,
+ .userdata = userdata,
+ .last_percent = (unsigned) -1,
+ .image_root = TAKE_PTR(root),
+ .grow_machine_directory = grow,
+ };
+
+ RATELIMIT_INIT(i->progress_rate_limit, 100 * USEC_PER_MSEC, 1);
if (event)
i->event = sd_event_ref(event);