summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/conf-files.c5
-rw-r--r--src/shared/fdset.c4
-rw-r--r--src/shared/path-util.c4
-rw-r--r--src/shared/util.c3
4 files changed, 4 insertions, 12 deletions
diff --git a/src/shared/conf-files.c b/src/shared/conf-files.c
index 64ce8a0e57..c72a099b5a 100644
--- a/src/shared/conf-files.c
+++ b/src/shared/conf-files.c
@@ -98,7 +98,7 @@ static int base_cmp(const void *a, const void *b) {
}
static int conf_files_list_strv_internal(char ***strv, const char *suffix, const char *root, char **dirs) {
- Hashmap *fh;
+ _cleanup_hashmap_free_ Hashmap *fh = NULL;
char **files, **p;
int r;
@@ -116,7 +116,6 @@ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const
STRV_FOREACH(p, dirs) {
r = files_add(fh, root, *p, suffix);
if (r == -ENOMEM) {
- hashmap_free_free(fh);
return r;
} else if (r < 0)
log_debug("Failed to search for files in %s: %s",
@@ -125,14 +124,12 @@ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const
files = hashmap_get_strv(fh);
if (files == NULL) {
- hashmap_free_free(fh);
return -ENOMEM;
}
qsort_safe(files, hashmap_size(fh), sizeof(char *), base_cmp);
*strv = files;
- hashmap_free(fh);
return 0;
}
diff --git a/src/shared/fdset.c b/src/shared/fdset.c
index a2c861de3f..d2ea665016 100644
--- a/src/shared/fdset.c
+++ b/src/shared/fdset.c
@@ -104,7 +104,7 @@ int fdset_remove(FDSet *s, int fd) {
}
int fdset_new_fill(FDSet **_s) {
- DIR *d;
+ _cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
FDSet *s;
@@ -150,8 +150,6 @@ int fdset_new_fill(FDSet **_s) {
s = NULL;
finish:
- closedir(d);
-
/* We won't close the fds here! */
if (s)
set_free(MAKE_SET(s));
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index d193494afb..fd35e0c786 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -442,7 +442,7 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
};
int mount_id, mount_id_parent;
- char *parent;
+ _cleanup_free_ char *parent = NULL;
struct stat a, b;
int r;
@@ -473,7 +473,6 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
h.handle.handle_bytes = MAX_HANDLE_SZ;
r = name_to_handle_at(AT_FDCWD, parent, &h.handle, &mount_id_parent, 0);
- free(parent);
if (r < 0) {
/* The parent can't do name_to_handle_at() but the
* directory we are interested in can? If so, it must
@@ -504,7 +503,6 @@ fallback:
return r;
r = lstat(parent, &b);
- free(parent);
if (r < 0)
return -errno;
diff --git a/src/shared/util.c b/src/shared/util.c
index dbdb69270d..e7ff0f8840 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1440,7 +1440,7 @@ _pure_ static bool fd_in_set(int fd, const int fdset[], unsigned n_fdset) {
}
int close_all_fds(const int except[], unsigned n_except) {
- DIR *d;
+ _cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
@@ -1495,7 +1495,6 @@ int close_all_fds(const int except[], unsigned n_except) {
}
}
- closedir(d);
return r;
}