summaryrefslogtreecommitdiffstats
path: root/src/machine
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2024-03-19 23:34:01 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2024-03-20 15:18:21 +0100
commit237bbec1173b41c0e0f2eaf9c30e19ab82073b8d (patch)
treef51300ce66d8a05cd141c1141d4b28f15750a6a4 /src/machine
parentbasic/time-util: use strdup_to() and reformat a bit (diff)
downloadsystemd-237bbec1173b41c0e0f2eaf9c30e19ab82073b8d.tar.xz
systemd-237bbec1173b41c0e0f2eaf9c30e19ab82073b8d.zip
machinectl: use strdup_to() and move cleanup out of the loop
It doesn't matter much, but it seems nicer to call va_end() just once.
Diffstat (limited to 'src/machine')
-rw-r--r--src/machine/machinectl.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index bab3719a49..32a60e388f 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -159,24 +159,22 @@ static int call_get_os_release(sd_bus *bus, const char *method, const char *name
if (r < 0)
return bus_log_parse_error(r);
+ r = 0;
va_start(ap, query);
for (count = 0; count < awaited_args; count++) {
- char *val, **out;
+ char **out;
out = va_arg(ap, char **);
assert(out);
if (query_res[count]) {
- val = strdup(query_res[count]);
- if (!val) {
- va_end(ap);
- return -ENOMEM;
- }
- *out = val;
+ r = strdup_to(out, query_res[count]);
+ if (r < 0)
+ break;
}
}
va_end(ap);
- return 0;
+ return r;
}
static int call_get_addresses(