summaryrefslogtreecommitdiff
path: root/src/portable
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-06-24 17:42:13 +0200
committerGitHub <noreply@github.com>2020-06-24 17:42:13 +0200
commitf83803a6499cd7ad314ba35be2f5f69ae12ab0e9 (patch)
treeba34799ac9e404113b92cf36023e607be53db3a2 /src/portable
parent41d1f469cf10f5f3e9cb4f4853ace9b0cfe5beae (diff)
parente198eba7c231b7ab9883e81d841631d7a235be84 (diff)
downloadsystemd-f83803a6499cd7ad314ba35be2f5f69ae12ab0e9.tar.gz
Merge pull request #16238 from keszybz/set-handling-more
Fix handling of cases where a duplicate item is added to a set and related cleanups
Diffstat (limited to 'src/portable')
-rw-r--r--src/portable/portable.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/portable/portable.c b/src/portable/portable.c
index 7917ea3902..3dc6d9e422 100644
--- a/src/portable/portable.c
+++ b/src/portable/portable.c
@@ -1125,7 +1125,7 @@ int portable_detach(
sd_bus_error *error) {
_cleanup_(lookup_paths_free) LookupPaths paths = {};
- _cleanup_set_free_free_ Set *unit_files = NULL, *markers = NULL;
+ _cleanup_set_free_ Set *unit_files = NULL, *markers = NULL;
_cleanup_closedir_ DIR *d = NULL;
const char *where, *item;
Iterator iterator;
@@ -1149,10 +1149,6 @@ int portable_detach(
return log_debug_errno(errno, "Failed to open '%s' directory: %m", where);
}
- markers = set_new(&path_hash_ops);
- if (!markers)
- return -ENOMEM;
-
FOREACH_DIRENT(de, d, return log_debug_errno(errno, "Failed to enumerate '%s' directory: %m", where)) {
_cleanup_free_ char *marker = NULL;
UnitFileState state;
@@ -1193,15 +1189,9 @@ int portable_detach(
if (path_is_absolute(marker) &&
!image_in_search_path(IMAGE_PORTABLE, marker)) {
- r = set_ensure_allocated(&markers, &path_hash_ops);
+ r = set_ensure_consume(&markers, &path_hash_ops_free, TAKE_PTR(marker));
if (r < 0)
return r;
-
- r = set_put(markers, marker);
- if (r >= 0)
- marker = NULL;
- else if (r != -EEXIST)
- return r;
}
}