summaryrefslogtreecommitdiffstats
path: root/src/portable
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-02-22 23:12:53 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-02-23 03:43:43 +0100
commit8c2d0d3af46ba1f371ef73e06cbb460711187d2b (patch)
treee865a3b5daf04fb2bbbf7dcdc021396d8c104f22 /src/portable
parentmemory-util: add a concept for gcc cleanup attribute based array destruction (diff)
downloadsystemd-8c2d0d3af46ba1f371ef73e06cbb460711187d2b.tar.xz
systemd-8c2d0d3af46ba1f371ef73e06cbb460711187d2b.zip
tree-wide: port various things over to CLEANUP_ARRAY()
Diffstat (limited to 'src/portable')
-rw-r--r--src/portable/portabled-image-bus.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/portable/portabled-image-bus.c b/src/portable/portabled-image-bus.c
index 07d10b05bf..6c4cb6ec9d 100644
--- a/src/portable/portabled-image-bus.c
+++ b/src/portable/portabled-image-bus.c
@@ -574,7 +574,6 @@ static int normalize_portable_changes(
PortableChange *changes = NULL;
size_t n_changes = 0;
- int r = 0;
assert(ret_n_changes);
assert(ret_changes);
@@ -586,12 +585,13 @@ static int normalize_portable_changes(
if (!changes)
return -ENOMEM;
+ CLEANUP_ARRAY(changes, n_changes, portable_changes_free);
+
/* Corner case: only detached, nothing attached */
if (n_changes_attached == 0) {
memcpy(changes, changes_detached, sizeof(PortableChange) * n_changes_detached);
*ret_changes = TAKE_PTR(changes);
*ret_n_changes = n_changes_detached;
-
return 0;
}
@@ -608,17 +608,13 @@ static int normalize_portable_changes(
_cleanup_free_ char *path = NULL, *source = NULL;
path = strdup(changes_detached[i].path);
- if (!path) {
- r = -ENOMEM;
- goto fail;
- }
+ if (!path)
+ return -ENOMEM;
if (changes_detached[i].source) {
source = strdup(changes_detached[i].source);
- if (!source) {
- r = -ENOMEM;
- goto fail;
- }
+ if (!source)
+ return -ENOMEM;
}
changes[n_changes++] = (PortableChange) {
@@ -633,10 +629,6 @@ static int normalize_portable_changes(
*ret_changes = TAKE_PTR(changes);
return 0;
-
-fail:
- portable_changes_free(changes, n_changes);
- return r;
}
int bus_image_common_reattach(