From 6bedfcbb2970e06a4d3280c8fb62083d252ede73 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 26 Oct 2015 16:18:16 +0100 Subject: util-lib: split string parsing related calls from util.[ch] into parse-util.[ch] --- src/shared/fstab-util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/shared/fstab-util.c') diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c index bdfc13e3cd..20fb0f5a06 100644 --- a/src/shared/fstab-util.c +++ b/src/shared/fstab-util.c @@ -19,11 +19,12 @@ along with systemd; If not, see . ***/ +#include "fstab-util.h" +#include "parse-util.h" #include "path-util.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "fstab-util.h" bool fstab_is_mount_point(const char *mount) { _cleanup_endmntent_ FILE *f = NULL; -- cgit v1.2.3-54-g00ecf From 6550203eb471595e41e27f46e5d0a00a4c0e47bb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 26 Oct 2015 18:43:29 +0100 Subject: util-lib: move fstab_node_to_udev_node() to fstab-util.[ch] --- src/basic/device-nodes.h | 2 + src/basic/util.c | 57 ---------------------- src/basic/util.h | 2 - src/hibernate-resume/hibernate-resume-generator.c | 1 + src/shared/fstab-util.c | 58 +++++++++++++++++++++++ src/shared/fstab-util.h | 7 ++- src/test/test-util.c | 3 +- 7 files changed, 68 insertions(+), 62 deletions(-) (limited to 'src/shared/fstab-util.c') diff --git a/src/basic/device-nodes.h b/src/basic/device-nodes.h index 04ba4897e5..7db81f3d52 100644 --- a/src/basic/device-nodes.h +++ b/src/basic/device-nodes.h @@ -21,5 +21,7 @@ along with systemd; If not, see . ***/ +#include + int encode_devnode_name(const char *str, char *str_enc, size_t len); int whitelisted_char_for_devnode(char c, const char *additional); diff --git a/src/basic/util.c b/src/basic/util.c index 25ba59505d..607d9cd933 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -571,26 +571,6 @@ int touch(const char *path) { return touch_file(path, false, USEC_INFINITY, UID_INVALID, GID_INVALID, 0); } -static char *unquote(const char *s, const char* quotes) { - size_t l; - assert(s); - - /* This is rather stupid, simply removes the heading and - * trailing quotes if there is one. Doesn't care about - * escaping or anything. - * - * DON'T USE THIS FOR NEW CODE ANYMORE!*/ - - l = strlen(s); - if (l < 2) - return strdup(s); - - if (strchr(quotes, s[0]) && s[l-1] == s[0]) - return strndup(s+1, l-2); - - return strdup(s); -} - noreturn void freeze(void) { /* Make sure nobody waits for us on a socket anymore */ @@ -636,43 +616,6 @@ int null_or_empty_fd(int fd) { return null_or_empty(&st); } -static char *tag_to_udev_node(const char *tagvalue, const char *by) { - _cleanup_free_ char *t = NULL, *u = NULL; - size_t enc_len; - - u = unquote(tagvalue, QUOTES); - if (!u) - return NULL; - - enc_len = strlen(u) * 4 + 1; - t = new(char, enc_len); - if (!t) - return NULL; - - if (encode_devnode_name(u, t, enc_len) < 0) - return NULL; - - return strjoin("/dev/disk/by-", by, "/", t, NULL); -} - -char *fstab_node_to_udev_node(const char *p) { - assert(p); - - if (startswith(p, "LABEL=")) - return tag_to_udev_node(p+6, "label"); - - if (startswith(p, "UUID=")) - return tag_to_udev_node(p+5, "uuid"); - - if (startswith(p, "PARTUUID=")) - return tag_to_udev_node(p+9, "partuuid"); - - if (startswith(p, "PARTLABEL=")) - return tag_to_udev_node(p+10, "partlabel"); - - return strdup(p); -} - bool dirent_is_file(const struct dirent *de) { assert(de); diff --git a/src/basic/util.h b/src/basic/util.h index 9393140c72..c6c3ba99f2 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -199,8 +199,6 @@ bool null_or_empty(struct stat *st) _pure_; int null_or_empty_path(const char *fn); int null_or_empty_fd(int fd); -char *fstab_node_to_udev_node(const char *p); - void execute_directories(const char* const* directories, usec_t timeout, char *argv[]); bool plymouth_running(void); diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c index dff2ada384..da7d33508d 100644 --- a/src/hibernate-resume/hibernate-resume-generator.c +++ b/src/hibernate-resume/hibernate-resume-generator.c @@ -22,6 +22,7 @@ #include #include +#include "fstab-util.h" #include "log.h" #include "mkdir.h" #include "special.h" diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c index 20fb0f5a06..77faa7bc35 100644 --- a/src/shared/fstab-util.c +++ b/src/shared/fstab-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "device-nodes.h" #include "fstab-util.h" #include "parse-util.h" #include "path-util.h" @@ -196,3 +197,60 @@ int fstab_find_pri(const char *options, int *ret) { *ret = (int) pri; return 1; } + +static char *unquote(const char *s, const char* quotes) { + size_t l; + assert(s); + + /* This is rather stupid, simply removes the heading and + * trailing quotes if there is one. Doesn't care about + * escaping or anything. + * + * DON'T USE THIS FOR NEW CODE ANYMORE!*/ + + l = strlen(s); + if (l < 2) + return strdup(s); + + if (strchr(quotes, s[0]) && s[l-1] == s[0]) + return strndup(s+1, l-2); + + return strdup(s); +} + +static char *tag_to_udev_node(const char *tagvalue, const char *by) { + _cleanup_free_ char *t = NULL, *u = NULL; + size_t enc_len; + + u = unquote(tagvalue, QUOTES); + if (!u) + return NULL; + + enc_len = strlen(u) * 4 + 1; + t = new(char, enc_len); + if (!t) + return NULL; + + if (encode_devnode_name(u, t, enc_len) < 0) + return NULL; + + return strjoin("/dev/disk/by-", by, "/", t, NULL); +} + +char *fstab_node_to_udev_node(const char *p) { + assert(p); + + if (startswith(p, "LABEL=")) + return tag_to_udev_node(p+6, "label"); + + if (startswith(p, "UUID=")) + return tag_to_udev_node(p+5, "uuid"); + + if (startswith(p, "PARTUUID=")) + return tag_to_udev_node(p+9, "partuuid"); + + if (startswith(p, "PARTLABEL=")) + return tag_to_udev_node(p+10, "partlabel"); + + return strdup(p); +} diff --git a/src/shared/fstab-util.h b/src/shared/fstab-util.h index 872b2363cd..5ebea44019 100644 --- a/src/shared/fstab-util.h +++ b/src/shared/fstab-util.h @@ -23,11 +23,12 @@ #include #include + #include "macro.h" bool fstab_is_mount_point(const char *mount); -int fstab_filter_options(const char *opts, const char *names, - const char **namefound, char **value, char **filtered); + +int fstab_filter_options(const char *opts, const char *names, const char **namefound, char **value, char **filtered); int fstab_extract_values(const char *opts, const char *name, char ***values); @@ -49,3 +50,5 @@ static inline bool fstab_test_yes_no_option(const char *opts, const char *yes_no return opt == yes_no; } + +char *fstab_node_to_udev_node(const char *p); diff --git a/src/test/test-util.c b/src/test/test-util.c index 848ebe69f4..8e5860f0e4 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -37,9 +37,10 @@ #include "escape.h" #include "fd-util.h" #include "fileio.h" +#include "fstab-util.h" +#include "hexdecoct.h" #include "io-util.h" #include "mkdir.h" -#include "hexdecoct.h" #include "parse-util.h" #include "process-util.h" #include "rm-rf.h" -- cgit v1.2.3-54-g00ecf From 4349cd7c1d153c4ffa23cf1cff1644e0afa9bcf0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 26 Oct 2015 18:44:13 +0100 Subject: util-lib: move mount related utility calls to mount-util.[ch] --- Makefile.am | 2 + src/basic/mount-util.c | 483 ++++++++++++++++++++++++++++ src/basic/mount-util.h | 36 +++ src/basic/path-util.c | 199 ------------ src/basic/path-util.h | 2 - src/basic/rm-rf.c | 1 + src/basic/util.c | 249 -------------- src/basic/util.h | 10 - src/core/automount.c | 1 + src/core/machine-id-setup.c | 3 +- src/core/mount-setup.c | 21 +- src/core/namespace.c | 1 + src/cryptsetup/cryptsetup.c | 1 + src/fstab-generator/fstab-generator.c | 1 + src/gpt-auto-generator/gpt-auto-generator.c | 1 + src/login/logind-user.c | 1 + src/nspawn/nspawn-mount.c | 1 + src/nspawn/nspawn.c | 1 + src/remount-fs/remount-fs.c | 7 +- src/shared/condition.c | 1 + src/shared/fstab-util.c | 1 + src/shared/generator.c | 1 + src/shared/machine-pool.c | 1 + src/test/test-path-util.c | 1 + 24 files changed, 552 insertions(+), 474 deletions(-) create mode 100644 src/basic/mount-util.c create mode 100644 src/basic/mount-util.h (limited to 'src/shared/fstab-util.c') diff --git a/Makefile.am b/Makefile.am index 26d5587b11..275b856191 100644 --- a/Makefile.am +++ b/Makefile.am @@ -791,6 +791,8 @@ libbasic_la_SOURCES = \ src/basic/parse-util.h \ src/basic/user-util.c \ src/basic/user-util.h \ + src/basic/mount-util.c \ + src/basic/mount-util.h \ src/basic/hexdecoct.c \ src/basic/hexdecoct.h \ src/basic/extract-word.c \ diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c new file mode 100644 index 0000000000..6b33d43024 --- /dev/null +++ b/src/basic/mount-util.c @@ -0,0 +1,483 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/*** + This file is part of systemd. + + Copyright 2010 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see . +***/ + +#include +#include +#include + +#include "escape.h" +#include "fd-util.h" +#include "fileio.h" +#include "mount-util.h" +#include "parse-util.h" +#include "path-util.h" +#include "set.h" +#include "string-util.h" +#include "util.h" + +static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *mnt_id) { + char path[strlen("/proc/self/fdinfo/") + DECIMAL_STR_MAX(int)]; + _cleanup_free_ char *fdinfo = NULL; + _cleanup_close_ int subfd = -1; + char *p; + int r; + + if ((flags & AT_EMPTY_PATH) && isempty(filename)) + xsprintf(path, "/proc/self/fdinfo/%i", fd); + else { + subfd = openat(fd, filename, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_PATH); + if (subfd < 0) + return -errno; + + xsprintf(path, "/proc/self/fdinfo/%i", subfd); + } + + r = read_full_file(path, &fdinfo, NULL); + if (r == -ENOENT) /* The fdinfo directory is a relatively new addition */ + return -EOPNOTSUPP; + if (r < 0) + return -errno; + + p = startswith(fdinfo, "mnt_id:"); + if (!p) { + p = strstr(fdinfo, "\nmnt_id:"); + if (!p) /* The mnt_id field is a relatively new addition */ + return -EOPNOTSUPP; + + p += 8; + } + + p += strspn(p, WHITESPACE); + p[strcspn(p, WHITESPACE)] = 0; + + return safe_atoi(p, mnt_id); +} + + +int fd_is_mount_point(int fd, const char *filename, int flags) { + union file_handle_union h = FILE_HANDLE_INIT, h_parent = FILE_HANDLE_INIT; + int mount_id = -1, mount_id_parent = -1; + bool nosupp = false, check_st_dev = true; + struct stat a, b; + int r; + + assert(fd >= 0); + assert(filename); + + /* First we will try the name_to_handle_at() syscall, which + * tells us the mount id and an opaque file "handle". It is + * not supported everywhere though (kernel compile-time + * option, not all file systems are hooked up). If it works + * the mount id is usually good enough to tell us whether + * something is a mount point. + * + * If that didn't work we will try to read the mount id from + * /proc/self/fdinfo/. This is almost as good as + * name_to_handle_at(), however, does not return the + * opaque file handle. The opaque file handle is pretty useful + * to detect the root directory, which we should always + * consider a mount point. Hence we use this only as + * fallback. Exporting the mnt_id in fdinfo is a pretty recent + * kernel addition. + * + * As last fallback we do traditional fstat() based st_dev + * comparisons. This is how things were traditionally done, + * but unionfs breaks breaks this since it exposes file + * systems with a variety of st_dev reported. Also, btrfs + * subvolumes have different st_dev, even though they aren't + * real mounts of their own. */ + + r = name_to_handle_at(fd, filename, &h.handle, &mount_id, flags); + if (r < 0) { + if (errno == ENOSYS) + /* This kernel does not support name_to_handle_at() + * fall back to simpler logic. */ + goto fallback_fdinfo; + else if (errno == EOPNOTSUPP) + /* This kernel or file system does not support + * name_to_handle_at(), hence let's see if the + * upper fs supports it (in which case it is a + * mount point), otherwise fallback to the + * traditional stat() logic */ + nosupp = true; + else + return -errno; + } + + r = name_to_handle_at(fd, "", &h_parent.handle, &mount_id_parent, AT_EMPTY_PATH); + if (r < 0) { + if (errno == EOPNOTSUPP) { + if (nosupp) + /* Neither parent nor child do name_to_handle_at()? + We have no choice but to fall back. */ + goto fallback_fdinfo; + else + /* The parent can't do name_to_handle_at() but the + * directory we are interested in can? + * If so, it must be a mount point. */ + return 1; + } else + return -errno; + } + + /* The parent can do name_to_handle_at() but the + * directory we are interested in can't? If so, it + * must be a mount point. */ + if (nosupp) + return 1; + + /* If the file handle for the directory we are + * interested in and its parent are identical, we + * assume this is the root directory, which is a mount + * point. */ + + if (h.handle.handle_bytes == h_parent.handle.handle_bytes && + h.handle.handle_type == h_parent.handle.handle_type && + memcmp(h.handle.f_handle, h_parent.handle.f_handle, h.handle.handle_bytes) == 0) + return 1; + + return mount_id != mount_id_parent; + +fallback_fdinfo: + r = fd_fdinfo_mnt_id(fd, filename, flags, &mount_id); + if (r == -EOPNOTSUPP) + goto fallback_fstat; + if (r < 0) + return r; + + r = fd_fdinfo_mnt_id(fd, "", AT_EMPTY_PATH, &mount_id_parent); + if (r < 0) + return r; + + if (mount_id != mount_id_parent) + return 1; + + /* Hmm, so, the mount ids are the same. This leaves one + * special case though for the root file system. For that, + * let's see if the parent directory has the same inode as we + * are interested in. Hence, let's also do fstat() checks now, + * too, but avoid the st_dev comparisons, since they aren't + * that useful on unionfs mounts. */ + check_st_dev = false; + +fallback_fstat: + /* yay for fstatat() taking a different set of flags than the other + * _at() above */ + if (flags & AT_SYMLINK_FOLLOW) + flags &= ~AT_SYMLINK_FOLLOW; + else + flags |= AT_SYMLINK_NOFOLLOW; + if (fstatat(fd, filename, &a, flags) < 0) + return -errno; + + if (fstatat(fd, "", &b, AT_EMPTY_PATH) < 0) + return -errno; + + /* A directory with same device and inode as its parent? Must + * be the root directory */ + if (a.st_dev == b.st_dev && + a.st_ino == b.st_ino) + return 1; + + return check_st_dev && (a.st_dev != b.st_dev); +} + +/* flags can be AT_SYMLINK_FOLLOW or 0 */ +int path_is_mount_point(const char *t, int flags) { + _cleanup_close_ int fd = -1; + _cleanup_free_ char *canonical = NULL, *parent = NULL; + + assert(t); + + if (path_equal(t, "/")) + return 1; + + /* we need to resolve symlinks manually, we can't just rely on + * fd_is_mount_point() to do that for us; if we have a structure like + * /bin -> /usr/bin/ and /usr is a mount point, then the parent that we + * look at needs to be /usr, not /. */ + if (flags & AT_SYMLINK_FOLLOW) { + canonical = canonicalize_file_name(t); + if (!canonical) + return -errno; + + t = canonical; + } + + parent = dirname_malloc(t); + if (!parent) + return -ENOMEM; + + fd = openat(AT_FDCWD, parent, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_PATH); + if (fd < 0) + return -errno; + + return fd_is_mount_point(fd, basename(t), flags); +} + +int umount_recursive(const char *prefix, int flags) { + bool again; + int n = 0, r; + + /* Try to umount everything recursively below a + * directory. Also, take care of stacked mounts, and keep + * unmounting them until they are gone. */ + + do { + _cleanup_fclose_ FILE *proc_self_mountinfo = NULL; + + again = false; + r = 0; + + proc_self_mountinfo = fopen("/proc/self/mountinfo", "re"); + if (!proc_self_mountinfo) + return -errno; + + for (;;) { + _cleanup_free_ char *path = NULL, *p = NULL; + int k; + + k = fscanf(proc_self_mountinfo, + "%*s " /* (1) mount id */ + "%*s " /* (2) parent id */ + "%*s " /* (3) major:minor */ + "%*s " /* (4) root */ + "%ms " /* (5) mount point */ + "%*s" /* (6) mount options */ + "%*[^-]" /* (7) optional fields */ + "- " /* (8) separator */ + "%*s " /* (9) file system type */ + "%*s" /* (10) mount source */ + "%*s" /* (11) mount options 2 */ + "%*[^\n]", /* some rubbish at the end */ + &path); + if (k != 1) { + if (k == EOF) + break; + + continue; + } + + r = cunescape(path, UNESCAPE_RELAX, &p); + if (r < 0) + return r; + + if (!path_startswith(p, prefix)) + continue; + + if (umount2(p, flags) < 0) { + r = -errno; + continue; + } + + again = true; + n++; + + break; + } + + } while (again); + + return r ? r : n; +} + +static int get_mount_flags(const char *path, unsigned long *flags) { + struct statvfs buf; + + if (statvfs(path, &buf) < 0) + return -errno; + *flags = buf.f_flag; + return 0; +} + +int bind_remount_recursive(const char *prefix, bool ro) { + _cleanup_set_free_free_ Set *done = NULL; + _cleanup_free_ char *cleaned = NULL; + int r; + + /* Recursively remount a directory (and all its submounts) + * read-only or read-write. If the directory is already + * mounted, we reuse the mount and simply mark it + * MS_BIND|MS_RDONLY (or remove the MS_RDONLY for read-write + * operation). If it isn't we first make it one. Afterwards we + * apply MS_BIND|MS_RDONLY (or remove MS_RDONLY) to all + * submounts we can access, too. When mounts are stacked on + * the same mount point we only care for each individual + * "top-level" mount on each point, as we cannot + * influence/access the underlying mounts anyway. We do not + * have any effect on future submounts that might get + * propagated, they migt be writable. This includes future + * submounts that have been triggered via autofs. */ + + cleaned = strdup(prefix); + if (!cleaned) + return -ENOMEM; + + path_kill_slashes(cleaned); + + done = set_new(&string_hash_ops); + if (!done) + return -ENOMEM; + + for (;;) { + _cleanup_fclose_ FILE *proc_self_mountinfo = NULL; + _cleanup_set_free_free_ Set *todo = NULL; + bool top_autofs = false; + char *x; + unsigned long orig_flags; + + todo = set_new(&string_hash_ops); + if (!todo) + return -ENOMEM; + + proc_self_mountinfo = fopen("/proc/self/mountinfo", "re"); + if (!proc_self_mountinfo) + return -errno; + + for (;;) { + _cleanup_free_ char *path = NULL, *p = NULL, *type = NULL; + int k; + + k = fscanf(proc_self_mountinfo, + "%*s " /* (1) mount id */ + "%*s " /* (2) parent id */ + "%*s " /* (3) major:minor */ + "%*s " /* (4) root */ + "%ms " /* (5) mount point */ + "%*s" /* (6) mount options (superblock) */ + "%*[^-]" /* (7) optional fields */ + "- " /* (8) separator */ + "%ms " /* (9) file system type */ + "%*s" /* (10) mount source */ + "%*s" /* (11) mount options (bind mount) */ + "%*[^\n]", /* some rubbish at the end */ + &path, + &type); + if (k != 2) { + if (k == EOF) + break; + + continue; + } + + r = cunescape(path, UNESCAPE_RELAX, &p); + if (r < 0) + return r; + + /* Let's ignore autofs mounts. If they aren't + * triggered yet, we want to avoid triggering + * them, as we don't make any guarantees for + * future submounts anyway. If they are + * already triggered, then we will find + * another entry for this. */ + if (streq(type, "autofs")) { + top_autofs = top_autofs || path_equal(cleaned, p); + continue; + } + + if (path_startswith(p, cleaned) && + !set_contains(done, p)) { + + r = set_consume(todo, p); + p = NULL; + + if (r == -EEXIST) + continue; + if (r < 0) + return r; + } + } + + /* If we have no submounts to process anymore and if + * the root is either already done, or an autofs, we + * are done */ + if (set_isempty(todo) && + (top_autofs || set_contains(done, cleaned))) + return 0; + + if (!set_contains(done, cleaned) && + !set_contains(todo, cleaned)) { + /* The prefix directory itself is not yet a + * mount, make it one. */ + if (mount(cleaned, cleaned, NULL, MS_BIND|MS_REC, NULL) < 0) + return -errno; + + orig_flags = 0; + (void) get_mount_flags(cleaned, &orig_flags); + orig_flags &= ~MS_RDONLY; + + if (mount(NULL, prefix, NULL, orig_flags|MS_BIND|MS_REMOUNT|(ro ? MS_RDONLY : 0), NULL) < 0) + return -errno; + + x = strdup(cleaned); + if (!x) + return -ENOMEM; + + r = set_consume(done, x); + if (r < 0) + return r; + } + + while ((x = set_steal_first(todo))) { + + r = set_consume(done, x); + if (r == -EEXIST || r == 0) + continue; + if (r < 0) + return r; + + /* Try to reuse the original flag set, but + * don't care for errors, in case of + * obstructed mounts */ + orig_flags = 0; + (void) get_mount_flags(x, &orig_flags); + orig_flags &= ~MS_RDONLY; + + if (mount(NULL, x, NULL, orig_flags|MS_BIND|MS_REMOUNT|(ro ? MS_RDONLY : 0), NULL) < 0) { + + /* Deal with mount points that are + * obstructed by a later mount */ + + if (errno != ENOENT) + return -errno; + } + + } + } +} + +int mount_move_root(const char *path) { + assert(path); + + if (chdir(path) < 0) + return -errno; + + if (mount(path, "/", NULL, MS_MOVE, NULL) < 0) + return -errno; + + if (chroot(".") < 0) + return -errno; + + if (chdir("/") < 0) + return -errno; + + return 0; +} diff --git a/src/basic/mount-util.h b/src/basic/mount-util.h new file mode 100644 index 0000000000..b415d00e2f --- /dev/null +++ b/src/basic/mount-util.h @@ -0,0 +1,36 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +#pragma once + +/*** + This file is part of systemd. + + Copyright 2010 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see . +***/ + +#include +#include + +int fd_is_mount_point(int fd, const char *filename, int flags); +int path_is_mount_point(const char *path, int flags); + +int umount_recursive(const char *target, int flags); +int bind_remount_recursive(const char *prefix, bool ro); + +int mount_move_root(const char *path); + +DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, endmntent); +#define _cleanup_endmntent_ _cleanup_(endmntentp) diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 7abb3a7b9e..b1cab7356c 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -454,205 +454,6 @@ char* path_join(const char *root, const char *path, const char *rest) { NULL); } -static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *mnt_id) { - char path[strlen("/proc/self/fdinfo/") + DECIMAL_STR_MAX(int)]; - _cleanup_free_ char *fdinfo = NULL; - _cleanup_close_ int subfd = -1; - char *p; - int r; - - if ((flags & AT_EMPTY_PATH) && isempty(filename)) - xsprintf(path, "/proc/self/fdinfo/%i", fd); - else { - subfd = openat(fd, filename, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_PATH); - if (subfd < 0) - return -errno; - - xsprintf(path, "/proc/self/fdinfo/%i", subfd); - } - - r = read_full_file(path, &fdinfo, NULL); - if (r == -ENOENT) /* The fdinfo directory is a relatively new addition */ - return -EOPNOTSUPP; - if (r < 0) - return -errno; - - p = startswith(fdinfo, "mnt_id:"); - if (!p) { - p = strstr(fdinfo, "\nmnt_id:"); - if (!p) /* The mnt_id field is a relatively new addition */ - return -EOPNOTSUPP; - - p += 8; - } - - p += strspn(p, WHITESPACE); - p[strcspn(p, WHITESPACE)] = 0; - - return safe_atoi(p, mnt_id); -} - -int fd_is_mount_point(int fd, const char *filename, int flags) { - union file_handle_union h = FILE_HANDLE_INIT, h_parent = FILE_HANDLE_INIT; - int mount_id = -1, mount_id_parent = -1; - bool nosupp = false, check_st_dev = true; - struct stat a, b; - int r; - - assert(fd >= 0); - assert(filename); - - /* First we will try the name_to_handle_at() syscall, which - * tells us the mount id and an opaque file "handle". It is - * not supported everywhere though (kernel compile-time - * option, not all file systems are hooked up). If it works - * the mount id is usually good enough to tell us whether - * something is a mount point. - * - * If that didn't work we will try to read the mount id from - * /proc/self/fdinfo/. This is almost as good as - * name_to_handle_at(), however, does not return the - * opaque file handle. The opaque file handle is pretty useful - * to detect the root directory, which we should always - * consider a mount point. Hence we use this only as - * fallback. Exporting the mnt_id in fdinfo is a pretty recent - * kernel addition. - * - * As last fallback we do traditional fstat() based st_dev - * comparisons. This is how things were traditionally done, - * but unionfs breaks breaks this since it exposes file - * systems with a variety of st_dev reported. Also, btrfs - * subvolumes have different st_dev, even though they aren't - * real mounts of their own. */ - - r = name_to_handle_at(fd, filename, &h.handle, &mount_id, flags); - if (r < 0) { - if (errno == ENOSYS) - /* This kernel does not support name_to_handle_at() - * fall back to simpler logic. */ - goto fallback_fdinfo; - else if (errno == EOPNOTSUPP) - /* This kernel or file system does not support - * name_to_handle_at(), hence let's see if the - * upper fs supports it (in which case it is a - * mount point), otherwise fallback to the - * traditional stat() logic */ - nosupp = true; - else - return -errno; - } - - r = name_to_handle_at(fd, "", &h_parent.handle, &mount_id_parent, AT_EMPTY_PATH); - if (r < 0) { - if (errno == EOPNOTSUPP) { - if (nosupp) - /* Neither parent nor child do name_to_handle_at()? - We have no choice but to fall back. */ - goto fallback_fdinfo; - else - /* The parent can't do name_to_handle_at() but the - * directory we are interested in can? - * If so, it must be a mount point. */ - return 1; - } else - return -errno; - } - - /* The parent can do name_to_handle_at() but the - * directory we are interested in can't? If so, it - * must be a mount point. */ - if (nosupp) - return 1; - - /* If the file handle for the directory we are - * interested in and its parent are identical, we - * assume this is the root directory, which is a mount - * point. */ - - if (h.handle.handle_bytes == h_parent.handle.handle_bytes && - h.handle.handle_type == h_parent.handle.handle_type && - memcmp(h.handle.f_handle, h_parent.handle.f_handle, h.handle.handle_bytes) == 0) - return 1; - - return mount_id != mount_id_parent; - -fallback_fdinfo: - r = fd_fdinfo_mnt_id(fd, filename, flags, &mount_id); - if (r == -EOPNOTSUPP) - goto fallback_fstat; - if (r < 0) - return r; - - r = fd_fdinfo_mnt_id(fd, "", AT_EMPTY_PATH, &mount_id_parent); - if (r < 0) - return r; - - if (mount_id != mount_id_parent) - return 1; - - /* Hmm, so, the mount ids are the same. This leaves one - * special case though for the root file system. For that, - * let's see if the parent directory has the same inode as we - * are interested in. Hence, let's also do fstat() checks now, - * too, but avoid the st_dev comparisons, since they aren't - * that useful on unionfs mounts. */ - check_st_dev = false; - -fallback_fstat: - /* yay for fstatat() taking a different set of flags than the other - * _at() above */ - if (flags & AT_SYMLINK_FOLLOW) - flags &= ~AT_SYMLINK_FOLLOW; - else - flags |= AT_SYMLINK_NOFOLLOW; - if (fstatat(fd, filename, &a, flags) < 0) - return -errno; - - if (fstatat(fd, "", &b, AT_EMPTY_PATH) < 0) - return -errno; - - /* A directory with same device and inode as its parent? Must - * be the root directory */ - if (a.st_dev == b.st_dev && - a.st_ino == b.st_ino) - return 1; - - return check_st_dev && (a.st_dev != b.st_dev); -} - -/* flags can be AT_SYMLINK_FOLLOW or 0 */ -int path_is_mount_point(const char *t, int flags) { - _cleanup_close_ int fd = -1; - _cleanup_free_ char *canonical = NULL, *parent = NULL; - - assert(t); - - if (path_equal(t, "/")) - return 1; - - /* we need to resolve symlinks manually, we can't just rely on - * fd_is_mount_point() to do that for us; if we have a structure like - * /bin -> /usr/bin/ and /usr is a mount point, then the parent that we - * look at needs to be /usr, not /. */ - if (flags & AT_SYMLINK_FOLLOW) { - canonical = canonicalize_file_name(t); - if (!canonical) - return -errno; - - t = canonical; - } - - parent = dirname_malloc(t); - if (!parent) - return -ENOMEM; - - fd = openat(AT_FDCWD, parent, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_PATH); - if (fd < 0) - return -errno; - - return fd_is_mount_point(fd, basename(t), flags); -} - int path_is_read_only_fs(const char *path) { struct statvfs st; diff --git a/src/basic/path-util.h b/src/basic/path-util.h index 708cdc1707..1ff47ab193 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -52,8 +52,6 @@ int path_strv_make_absolute_cwd(char **l); char** path_strv_resolve(char **l, const char *prefix); char** path_strv_resolve_uniq(char **l, const char *prefix); -int fd_is_mount_point(int fd, const char *filename, int flags); -int path_is_mount_point(const char *path, int flags); int path_is_read_only_fs(const char *path); int path_is_os_tree(const char *path); diff --git a/src/basic/rm-rf.c b/src/basic/rm-rf.c index a5daa23f86..f1850ea8a3 100644 --- a/src/basic/rm-rf.c +++ b/src/basic/rm-rf.c @@ -21,6 +21,7 @@ #include "btrfs-util.h" #include "fd-util.h" +#include "mount-util.h" #include "path-util.h" #include "rm-rf.h" #include "string-util.h" diff --git a/src/basic/util.c b/src/basic/util.c index 607d9cd933..06fe307ba0 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -2137,237 +2137,6 @@ int update_reboot_param_file(const char *param) { return 0; } -int umount_recursive(const char *prefix, int flags) { - bool again; - int n = 0, r; - - /* Try to umount everything recursively below a - * directory. Also, take care of stacked mounts, and keep - * unmounting them until they are gone. */ - - do { - _cleanup_fclose_ FILE *proc_self_mountinfo = NULL; - - again = false; - r = 0; - - proc_self_mountinfo = fopen("/proc/self/mountinfo", "re"); - if (!proc_self_mountinfo) - return -errno; - - for (;;) { - _cleanup_free_ char *path = NULL, *p = NULL; - int k; - - k = fscanf(proc_self_mountinfo, - "%*s " /* (1) mount id */ - "%*s " /* (2) parent id */ - "%*s " /* (3) major:minor */ - "%*s " /* (4) root */ - "%ms " /* (5) mount point */ - "%*s" /* (6) mount options */ - "%*[^-]" /* (7) optional fields */ - "- " /* (8) separator */ - "%*s " /* (9) file system type */ - "%*s" /* (10) mount source */ - "%*s" /* (11) mount options 2 */ - "%*[^\n]", /* some rubbish at the end */ - &path); - if (k != 1) { - if (k == EOF) - break; - - continue; - } - - r = cunescape(path, UNESCAPE_RELAX, &p); - if (r < 0) - return r; - - if (!path_startswith(p, prefix)) - continue; - - if (umount2(p, flags) < 0) { - r = -errno; - continue; - } - - again = true; - n++; - - break; - } - - } while (again); - - return r ? r : n; -} - -static int get_mount_flags(const char *path, unsigned long *flags) { - struct statvfs buf; - - if (statvfs(path, &buf) < 0) - return -errno; - *flags = buf.f_flag; - return 0; -} - -int bind_remount_recursive(const char *prefix, bool ro) { - _cleanup_set_free_free_ Set *done = NULL; - _cleanup_free_ char *cleaned = NULL; - int r; - - /* Recursively remount a directory (and all its submounts) - * read-only or read-write. If the directory is already - * mounted, we reuse the mount and simply mark it - * MS_BIND|MS_RDONLY (or remove the MS_RDONLY for read-write - * operation). If it isn't we first make it one. Afterwards we - * apply MS_BIND|MS_RDONLY (or remove MS_RDONLY) to all - * submounts we can access, too. When mounts are stacked on - * the same mount point we only care for each individual - * "top-level" mount on each point, as we cannot - * influence/access the underlying mounts anyway. We do not - * have any effect on future submounts that might get - * propagated, they migt be writable. This includes future - * submounts that have been triggered via autofs. */ - - cleaned = strdup(prefix); - if (!cleaned) - return -ENOMEM; - - path_kill_slashes(cleaned); - - done = set_new(&string_hash_ops); - if (!done) - return -ENOMEM; - - for (;;) { - _cleanup_fclose_ FILE *proc_self_mountinfo = NULL; - _cleanup_set_free_free_ Set *todo = NULL; - bool top_autofs = false; - char *x; - unsigned long orig_flags; - - todo = set_new(&string_hash_ops); - if (!todo) - return -ENOMEM; - - proc_self_mountinfo = fopen("/proc/self/mountinfo", "re"); - if (!proc_self_mountinfo) - return -errno; - - for (;;) { - _cleanup_free_ char *path = NULL, *p = NULL, *type = NULL; - int k; - - k = fscanf(proc_self_mountinfo, - "%*s " /* (1) mount id */ - "%*s " /* (2) parent id */ - "%*s " /* (3) major:minor */ - "%*s " /* (4) root */ - "%ms " /* (5) mount point */ - "%*s" /* (6) mount options (superblock) */ - "%*[^-]" /* (7) optional fields */ - "- " /* (8) separator */ - "%ms " /* (9) file system type */ - "%*s" /* (10) mount source */ - "%*s" /* (11) mount options (bind mount) */ - "%*[^\n]", /* some rubbish at the end */ - &path, - &type); - if (k != 2) { - if (k == EOF) - break; - - continue; - } - - r = cunescape(path, UNESCAPE_RELAX, &p); - if (r < 0) - return r; - - /* Let's ignore autofs mounts. If they aren't - * triggered yet, we want to avoid triggering - * them, as we don't make any guarantees for - * future submounts anyway. If they are - * already triggered, then we will find - * another entry for this. */ - if (streq(type, "autofs")) { - top_autofs = top_autofs || path_equal(cleaned, p); - continue; - } - - if (path_startswith(p, cleaned) && - !set_contains(done, p)) { - - r = set_consume(todo, p); - p = NULL; - - if (r == -EEXIST) - continue; - if (r < 0) - return r; - } - } - - /* If we have no submounts to process anymore and if - * the root is either already done, or an autofs, we - * are done */ - if (set_isempty(todo) && - (top_autofs || set_contains(done, cleaned))) - return 0; - - if (!set_contains(done, cleaned) && - !set_contains(todo, cleaned)) { - /* The prefix directory itself is not yet a - * mount, make it one. */ - if (mount(cleaned, cleaned, NULL, MS_BIND|MS_REC, NULL) < 0) - return -errno; - - orig_flags = 0; - (void) get_mount_flags(cleaned, &orig_flags); - orig_flags &= ~MS_RDONLY; - - if (mount(NULL, prefix, NULL, orig_flags|MS_BIND|MS_REMOUNT|(ro ? MS_RDONLY : 0), NULL) < 0) - return -errno; - - x = strdup(cleaned); - if (!x) - return -ENOMEM; - - r = set_consume(done, x); - if (r < 0) - return r; - } - - while ((x = set_steal_first(todo))) { - - r = set_consume(done, x); - if (r == -EEXIST || r == 0) - continue; - if (r < 0) - return r; - - /* Try to reuse the original flag set, but - * don't care for errors, in case of - * obstructed mounts */ - orig_flags = 0; - (void) get_mount_flags(x, &orig_flags); - orig_flags &= ~MS_RDONLY; - - if (mount(NULL, x, NULL, orig_flags|MS_BIND|MS_REMOUNT|(ro ? MS_RDONLY : 0), NULL) < 0) { - - /* Deal with mount points that are - * obstructed by a later mount */ - - if (errno != ENOENT) - return -errno; - } - - } - } -} - int take_password_lock(const char *root) { struct flock flock = { @@ -2710,24 +2479,6 @@ int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char return 0; } -int mount_move_root(const char *path) { - assert(path); - - if (chdir(path) < 0) - return -errno; - - if (mount(path, "/", NULL, MS_MOVE, NULL) < 0) - return -errno; - - if (chroot(".") < 0) - return -errno; - - if (chdir("/") < 0) - return -errno; - - return 0; -} - int getxattr_malloc(const char *path, const char *name, char **value, bool allow_symlink) { char *v; size_t l; diff --git a/src/basic/util.h b/src/basic/util.h index c6c3ba99f2..9388ba7d74 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -279,12 +278,9 @@ static inline void umaskp(mode_t *u) { umask(*u); } -DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, endmntent); - #define _cleanup_free_ _cleanup_(freep) #define _cleanup_umask_ _cleanup_(umaskp) #define _cleanup_globfree_ _cleanup_(globfree) -#define _cleanup_endmntent_ _cleanup_(endmntentp) _malloc_ _alloc_(1, 2) static inline void *malloc_multiply(size_t a, size_t b) { if (_unlikely_(b != 0 && a > ((size_t) -1) / b)) @@ -525,10 +521,6 @@ union file_handle_union { int update_reboot_param_file(const char *param); -int umount_recursive(const char *target, int flags); - -int bind_remount_recursive(const char *prefix, bool ro); - int take_password_lock(const char *root); int is_symlink(const char *path); @@ -568,8 +560,6 @@ int syslog_parse_priority(const char **p, int *priority, bool with_facility); int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); -int mount_move_root(const char *path); - int getxattr_malloc(const char *path, const char *name, char **value, bool allow_symlink); int fgetxattr_malloc(int fd, const char *name, char **value); diff --git a/src/core/automount.c b/src/core/automount.c index df98711d96..00911118e6 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -39,6 +39,7 @@ #include "io-util.h" #include "label.h" #include "mkdir.h" +#include "mount-util.h" #include "mount.h" #include "parse-util.h" #include "path-util.h" diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c index ea4bdc5414..764728c804 100644 --- a/src/core/machine-id-setup.c +++ b/src/core/machine-id-setup.c @@ -31,12 +31,13 @@ #include "fd-util.h" #include "fileio.h" +#include "hexdecoct.h" #include "io-util.h" #include "log.h" #include "machine-id-setup.h" #include "macro.h" #include "mkdir.h" -#include "hexdecoct.h" +#include "mount-util.h" #include "path-util.h" #include "process-util.h" #include "string-util.h" diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c index 9b16eaa0e2..7486ec3985 100644 --- a/src/core/mount-setup.c +++ b/src/core/mount-setup.c @@ -25,22 +25,23 @@ #include #include -#include "mount-setup.h" -#include "dev-setup.h" #include "bus-util.h" +#include "cgroup-util.h" +#include "dev-setup.h" +#include "efivars.h" +#include "label.h" #include "log.h" #include "macro.h" -#include "util.h" -#include "label.h" -#include "set.h" -#include "strv.h" +#include "missing.h" #include "mkdir.h" +#include "mount-setup.h" +#include "mount-util.h" #include "path-util.h" -#include "missing.h" -#include "virt.h" -#include "efivars.h" +#include "set.h" #include "smack-util.h" -#include "cgroup-util.h" +#include "strv.h" +#include "util.h" +#include "virt.h" typedef enum MountMode { MNT_NONE = 0, diff --git a/src/core/namespace.c b/src/core/namespace.c index 4d11d54bfe..e6c381800b 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -33,6 +33,7 @@ #include "loopback-setup.h" #include "missing.h" #include "mkdir.h" +#include "mount-util.h" #include "namespace.h" #include "path-util.h" #include "selinux-util.h" diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 4c1d8a8e74..8531b6b125 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -32,6 +32,7 @@ #include "escape.h" #include "fileio.h" #include "log.h" +#include "mount-util.h" #include "parse-util.h" #include "path-util.h" #include "string-util.h" diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 732b3d1704..fd0d01153a 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -32,6 +32,7 @@ #include "log.h" #include "mkdir.h" #include "mount-setup.h" +#include "mount-util.h" #include "parse-util.h" #include "path-util.h" #include "special.h" diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index ac6d731753..6440fd654e 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -37,6 +37,7 @@ #include "gpt.h" #include "missing.h" #include "mkdir.h" +#include "mount-util.h" #include "parse-util.h" #include "path-util.h" #include "special.h" diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 9f3af59b54..5a7ae11ec1 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -36,6 +36,7 @@ #include "label.h" #include "logind-user.h" #include "mkdir.h" +#include "mount-util.h" #include "parse-util.h" #include "path-util.h" #include "rm-rf.h" diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c index 5d8172092a..ac9c31b931 100644 --- a/src/nspawn/nspawn-mount.c +++ b/src/nspawn/nspawn-mount.c @@ -26,6 +26,7 @@ #include "escape.h" #include "label.h" #include "mkdir.h" +#include "mount-util.h" #include "nspawn-mount.h" #include "parse-util.h" #include "path-util.h" diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index a4eefe5eb8..c34d52293d 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -69,6 +69,7 @@ #include "macro.h" #include "missing.h" #include "mkdir.h" +#include "mount-util.h" #include "netlink-util.h" #include "nspawn-cgroup.h" #include "nspawn-expose-ports.h" diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c index f904e48e75..57f99c9ef0 100644 --- a/src/remount-fs/remount-fs.c +++ b/src/remount-fs/remount-fs.c @@ -26,12 +26,13 @@ #include #include +#include "exit-status.h" #include "log.h" -#include "util.h" +#include "mount-setup.h" +#include "mount-util.h" #include "path-util.h" #include "signal-util.h" -#include "mount-setup.h" -#include "exit-status.h" +#include "util.h" /* Goes through /etc/fstab and remounts all API file systems, applying * options that are in /etc/fstab that systemd might not have diff --git a/src/shared/condition.c b/src/shared/condition.c index 145ea41095..700bc92438 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -36,6 +36,7 @@ #include "fd-util.h" #include "hostname-util.h" #include "ima-util.h" +#include "mount-util.h" #include "parse-util.h" #include "path-util.h" #include "selinux-util.h" diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c index 77faa7bc35..1ea11ea5a4 100644 --- a/src/shared/fstab-util.c +++ b/src/shared/fstab-util.c @@ -21,6 +21,7 @@ #include "device-nodes.h" #include "fstab-util.h" +#include "mount-util.h" #include "parse-util.h" #include "path-util.h" #include "string-util.h" diff --git a/src/shared/generator.c b/src/shared/generator.c index 0a8e282949..203e01318b 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -28,6 +28,7 @@ #include "fstab-util.h" #include "generator.h" #include "mkdir.h" +#include "mount-util.h" #include "path-util.h" #include "special.h" #include "string-util.h" diff --git a/src/shared/machine-pool.c b/src/shared/machine-pool.c index 6d726a687a..9270f22479 100644 --- a/src/shared/machine-pool.c +++ b/src/shared/machine-pool.c @@ -36,6 +36,7 @@ #include "signal-util.h" #include "string-util.h" #include "util.h" +#include "mount-util.h" #define VAR_LIB_MACHINES_SIZE_START (1024UL*1024UL*500UL) #define VAR_LIB_MACHINES_FREE_MIN (1024UL*1024UL*750UL) diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index 86d61b2efb..e2979a8710 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -25,6 +25,7 @@ #include "fd-util.h" #include "macro.h" +#include "mount-util.h" #include "path-util.h" #include "rm-rf.h" #include "string-util.h" -- cgit v1.2.3-54-g00ecf From b5efdb8af40ea759a1ea584c1bc44ecc81dd00ce Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 27 Oct 2015 03:01:06 +0100 Subject: util-lib: split out allocation calls into alloc-util.[ch] --- Makefile.am | 2 + src/activate/activate.c | 3 +- src/analyze/analyze-verify.c | 1 + src/analyze/analyze.c | 1 + src/backlight/backlight.c | 1 + src/basic/alloc-util.c | 81 +++++++++++++++ src/basic/alloc-util.h | 108 ++++++++++++++++++++ src/basic/audit-util.c | 1 + src/basic/bitmap.c | 4 +- src/basic/btrfs-util.c | 1 + src/basic/bus-label.c | 3 +- src/basic/calendarspec.c | 1 + src/basic/capability-util.c | 1 + src/basic/cgroup-util.c | 1 + src/basic/copy.c | 1 + src/basic/cpu-set-util.c | 1 + src/basic/env-util.c | 3 +- src/basic/escape.c | 1 + src/basic/extract-word.c | 1 + src/basic/fileio.c | 1 + src/basic/fs-util.c | 1 + src/basic/hashmap.c | 1 + src/basic/hexdecoct.c | 1 + src/basic/in-addr-util.c | 1 + src/basic/json.c | 1 + src/basic/lockfile-util.c | 1 + src/basic/log.c | 1 + src/basic/memfd-util.c | 1 + src/basic/mount-util.c | 1 + src/basic/path-util.c | 1 + src/basic/prioq.c | 3 +- src/basic/proc-cmdline.c | 1 + src/basic/process-util.c | 1 + src/basic/replace-var.c | 1 + src/basic/selinux-util.c | 1 + src/basic/smack-util.c | 1 + src/basic/socket-label.c | 1 + src/basic/socket-util.c | 1 + src/basic/strbuf.c | 3 +- src/basic/string-util.c | 1 + src/basic/strv.c | 1 + src/basic/terminal-util.c | 1 + src/basic/time-util.c | 1 + src/basic/unit-name.c | 1 + src/basic/user-util.c | 1 + src/basic/utf8.c | 1 + src/basic/util.c | 59 +---------- src/basic/util.h | 109 +++------------------ src/basic/virt.c | 3 +- src/basic/xattr-util.c | 1 + src/binfmt/binfmt.c | 1 + src/boot/bootctl.c | 1 + src/bootchart/bootchart.c | 1 + src/bootchart/store.c | 1 + src/bootchart/svg.c | 1 + src/bus-proxyd/bus-proxyd.c | 1 + src/bus-proxyd/bus-xml-policy.c | 1 + src/bus-proxyd/driver.c | 1 + src/bus-proxyd/proxy.c | 1 + src/bus-proxyd/stdio-bridge.c | 1 + src/bus-proxyd/test-bus-xml-policy.c | 1 + src/cgls/cgls.c | 1 + src/cgtop/cgtop.c | 1 + src/core/automount.c | 1 + src/core/bus-endpoint.c | 5 +- src/core/bus-policy.c | 1 + src/core/busname.c | 1 + src/core/cgroup.c | 1 + src/core/dbus-cgroup.c | 1 + src/core/dbus-execute.c | 1 + src/core/dbus-job.c | 3 +- src/core/dbus-manager.c | 1 + src/core/dbus-scope.c | 15 +-- src/core/dbus-service.c | 1 + src/core/dbus-socket.c | 3 +- src/core/dbus-timer.c | 7 +- src/core/dbus-unit.c | 1 + src/core/dbus.c | 1 + src/core/device.c | 1 + src/core/execute.c | 1 + src/core/hostname-setup.c | 1 + src/core/job.c | 1 + src/core/killall.c | 1 + src/core/load-fragment.c | 1 + src/core/machine-id-setup.c | 1 + src/core/main.c | 1 + src/core/manager.c | 1 + src/core/mount-setup.c | 1 + src/core/mount.c | 3 +- src/core/namespace.c | 1 + src/core/scope.c | 3 +- src/core/selinux-access.c | 1 + src/core/service.c | 1 + src/core/show-status.c | 1 + src/core/shutdown.c | 1 + src/core/slice.c | 1 + src/core/smack-setup.c | 1 + src/core/snapshot.c | 1 + src/core/socket.c | 1 + src/core/swap.c | 1 + src/core/timer.c | 1 + src/core/transaction.c | 3 +- src/core/umount.c | 1 + src/core/unit-printf.c | 1 + src/core/unit.c | 1 + src/cryptsetup/cryptsetup-generator.c | 1 + src/cryptsetup/cryptsetup.c | 1 + src/dbus1-generator/dbus1-generator.c | 1 + src/debug-generator/debug-generator.c | 1 + src/delta/delta.c | 1 + src/escape/escape.c | 1 + src/firstboot/firstboot.c | 1 + src/fsck/fsck.c | 1 + src/fstab-generator/fstab-generator.c | 1 + src/getty-generator/getty-generator.c | 1 + src/gpt-auto-generator/gpt-auto-generator.c | 1 + src/hibernate-resume/hibernate-resume-generator.c | 1 + src/hibernate-resume/hibernate-resume.c | 3 +- src/hostname/hostnamectl.c | 1 + src/hostname/hostnamed.c | 1 + src/hwdb/hwdb.c | 1 + src/import/curl-util.c | 1 + src/import/export-raw.c | 1 + src/import/export-tar.c | 1 + src/import/export.c | 1 + src/import/import-raw.c | 1 + src/import/import-tar.c | 1 + src/import/import.c | 1 + src/import/importd.c | 1 + src/import/pull-common.c | 1 + src/import/pull-dkr.c | 1 + src/import/pull-job.c | 1 + src/import/pull-raw.c | 1 + src/import/pull-tar.c | 1 + src/import/pull.c | 1 + src/import/qcow2-util.c | 7 +- src/initctl/initctl.c | 1 + src/journal-remote/journal-gatewayd.c | 1 + src/journal-remote/journal-remote-parse.c | 1 + src/journal-remote/journal-remote-write.c | 1 + src/journal-remote/journal-remote.c | 1 + src/journal-remote/journal-upload-journal.c | 26 ++++- src/journal-remote/journal-upload.c | 1 + src/journal-remote/microhttpd-util.c | 1 + src/journal/catalog.c | 1 + src/journal/compress.c | 1 + src/journal/coredump-vacuum.c | 1 + src/journal/coredump.c | 1 + src/journal/coredumpctl.c | 1 + src/journal/journal-file.c | 1 + src/journal/journal-send.c | 1 + src/journal/journal-vacuum.c | 1 + src/journal/journal-verify.c | 1 + src/journal/journalctl.c | 1 + src/journal/journald-audit.c | 1 + src/journal/journald-console.c | 1 + src/journal/journald-native.c | 1 + src/journal/journald-rate-limit.c | 1 + src/journal/journald-server.c | 1 + src/journal/journald-stream.c | 1 + src/journal/journald-syslog.c | 1 + src/journal/journald-wall.c | 1 + src/journal/mmap-cache.c | 1 + src/journal/sd-journal.c | 1 + src/journal/stacktrace.c | 1 + src/journal/test-catalog.c | 1 + src/journal/test-compress-benchmark.c | 1 + src/journal/test-compress.c | 1 + src/journal/test-journal-flush.c | 1 + src/journal/test-journal-interleaving.c | 1 + src/journal/test-journal-match.c | 1 + src/journal/test-journal-stream.c | 1 + src/journal/test-journal-syslog.c | 1 + src/libsystemd-network/dhcp6-option.c | 10 +- src/libsystemd-network/lldp-internal.c | 1 + src/libsystemd-network/lldp-port.c | 1 + src/libsystemd-network/lldp-tlv.c | 3 +- src/libsystemd-network/network-internal.c | 1 + src/libsystemd-network/sd-dhcp-client.c | 1 + src/libsystemd-network/sd-dhcp-lease.c | 1 + src/libsystemd-network/sd-dhcp-server.c | 1 + src/libsystemd-network/sd-dhcp6-client.c | 1 + src/libsystemd-network/sd-dhcp6-lease.c | 6 +- src/libsystemd-network/sd-ipv4acd.c | 1 + src/libsystemd-network/sd-ipv4ll.c | 1 + src/libsystemd-network/sd-lldp.c | 1 + src/libsystemd-network/sd-ndisc.c | 1 + src/libsystemd-network/sd-pppoe.c | 1 + src/libsystemd-network/test-dhcp-client.c | 1 + src/libsystemd-network/test-dhcp-option.c | 8 +- src/libsystemd-network/test-ipv4ll-manual.c | 1 + src/libsystemd-network/test-lldp.c | 1 + src/libsystemd/sd-bus/bus-control.c | 1 + src/libsystemd/sd-bus/bus-creds.c | 1 + src/libsystemd/sd-bus/bus-dump.c | 1 + src/libsystemd/sd-bus/bus-error.c | 1 + src/libsystemd/sd-bus/bus-internal.c | 1 + src/libsystemd/sd-bus/bus-kernel.c | 1 + src/libsystemd/sd-bus/bus-match.c | 1 + src/libsystemd/sd-bus/bus-message.c | 1 + src/libsystemd/sd-bus/bus-objects.c | 1 + src/libsystemd/sd-bus/bus-slot.c | 1 + src/libsystemd/sd-bus/bus-socket.c | 1 + src/libsystemd/sd-bus/bus-track.c | 1 + src/libsystemd/sd-bus/busctl-introspect.c | 3 +- src/libsystemd/sd-bus/busctl.c | 1 + src/libsystemd/sd-bus/sd-bus.c | 1 + src/libsystemd/sd-bus/test-bus-benchmark.c | 1 + src/libsystemd/sd-bus/test-bus-chat.c | 1 + src/libsystemd/sd-bus/test-bus-gvariant.c | 1 + src/libsystemd/sd-bus/test-bus-kernel-bloom.c | 1 + src/libsystemd/sd-bus/test-bus-kernel.c | 1 + src/libsystemd/sd-bus/test-bus-marshal.c | 1 + src/libsystemd/sd-bus/test-bus-objects.c | 1 + src/libsystemd/sd-bus/test-bus-proxy.c | 1 + src/libsystemd/sd-bus/test-bus-zero-copy.c | 1 + src/libsystemd/sd-daemon/sd-daemon.c | 1 + src/libsystemd/sd-device/device-enumerator.c | 1 + src/libsystemd/sd-device/device-private.c | 1 + src/libsystemd/sd-device/sd-device.c | 1 + src/libsystemd/sd-event/sd-event.c | 1 + src/libsystemd/sd-hwdb/sd-hwdb.c | 1 + src/libsystemd/sd-login/sd-login.c | 1 + src/libsystemd/sd-login/test-login.c | 1 + src/libsystemd/sd-netlink/local-addresses.c | 2 + src/libsystemd/sd-netlink/netlink-message.c | 1 + src/libsystemd/sd-netlink/netlink-socket.c | 1 + src/libsystemd/sd-netlink/sd-netlink.c | 1 + src/libsystemd/sd-netlink/test-local-addresses.c | 1 + src/libsystemd/sd-network/network-util.c | 1 + src/libsystemd/sd-network/sd-network.c | 1 + src/libsystemd/sd-path/sd-path.c | 1 + src/libsystemd/sd-resolve/sd-resolve.c | 1 + src/libsystemd/sd-resolve/test-resolve.c | 1 + src/libudev/libudev-device.c | 1 + src/libudev/libudev-enumerate.c | 1 + src/libudev/libudev-hwdb.c | 1 + src/libudev/libudev-list.c | 5 +- src/libudev/libudev-monitor.c | 1 + src/libudev/libudev-queue.c | 1 + src/libudev/libudev.c | 1 + src/locale/localed.c | 1 + src/login/inhibit.c | 1 + src/login/loginctl.c | 1 + src/login/logind-acl.c | 1 + src/login/logind-action.c | 1 + src/login/logind-button.c | 1 + src/login/logind-core.c | 1 + src/login/logind-dbus.c | 1 + src/login/logind-device.c | 3 +- src/login/logind-inhibit.c | 1 + src/login/logind-seat-dbus.c | 1 + src/login/logind-seat.c | 1 + src/login/logind-session-dbus.c | 1 + src/login/logind-session-device.c | 1 + src/login/logind-session.c | 1 + src/login/logind-user-dbus.c | 1 + src/login/logind-user.c | 1 + src/login/logind-utmp.c | 1 + src/login/logind.c | 1 + src/login/pam_systemd.c | 1 + src/login/sysfs-show.c | 1 + src/machine/image-dbus.c | 1 + src/machine/machine-dbus.c | 1 + src/machine/machine.c | 1 + src/machine/machinectl.c | 1 + src/machine/machined-dbus.c | 1 + src/machine/machined.c | 1 + src/network/networkctl.c | 1 + src/network/networkd-address-pool.c | 1 + src/network/networkd-address.c | 1 + src/network/networkd-dhcp4.c | 5 +- src/network/networkd-fdb.c | 6 +- src/network/networkd-link-bus.c | 1 + src/network/networkd-link.c | 1 + src/network/networkd-manager-bus.c | 2 +- src/network/networkd-manager.c | 1 + src/network/networkd-netdev-bond.c | 1 + src/network/networkd-netdev-tuntap.c | 1 + src/network/networkd-netdev.c | 1 + src/network/networkd-network-bus.c | 1 + src/network/networkd-network.c | 1 + src/network/networkd-route.c | 1 + src/network/networkd-wait-online-link.c | 1 + src/network/networkd-wait-online-manager.c | 5 +- src/network/test-network.c | 1 + src/notify/notify.c | 1 + src/nspawn/nspawn-cgroup.c | 1 + src/nspawn/nspawn-expose-ports.c | 1 + src/nspawn/nspawn-mount.c | 1 + src/nspawn/nspawn-network.c | 1 + src/nspawn/nspawn-settings.c | 1 + src/nspawn/nspawn-setuid.c | 1 + src/nspawn/nspawn.c | 1 + src/nss-myhostname/nss-myhostname.c | 1 + src/nss-mymachines/nss-mymachines.c | 1 + src/path/path.c | 1 + src/random-seed/random-seed.c | 1 + src/rc-local-generator/rc-local-generator.c | 1 + src/resolve-host/resolve-host.c | 1 + src/resolve/resolved-bus.c | 2 +- src/resolve/resolved-conf.c | 6 +- src/resolve/resolved-dns-answer.c | 1 + src/resolve/resolved-dns-cache.c | 1 + src/resolve/resolved-dns-packet.c | 1 + src/resolve/resolved-dns-query.c | 4 +- src/resolve/resolved-dns-question.c | 3 +- src/resolve/resolved-dns-rr.c | 1 + src/resolve/resolved-dns-scope.c | 1 + src/resolve/resolved-dns-server.c | 4 +- src/resolve/resolved-dns-stream.c | 1 + src/resolve/resolved-dns-transaction.c | 1 + src/resolve/resolved-dns-zone.c | 1 + src/resolve/resolved-link.c | 1 + src/resolve/resolved-manager.c | 1 + src/rfkill/rfkill.c | 1 + src/run/run.c | 1 + src/shared/acl-util.c | 1 + src/shared/acpi-fpdt.c | 1 + src/shared/apparmor-util.c | 1 + src/shared/ask-password-api.c | 1 + src/shared/base-filesystem.c | 1 + src/shared/bus-util.c | 1 + src/shared/cgroup-show.c | 1 + src/shared/condition.c | 1 + src/shared/conf-parser.c | 1 + src/shared/dev-setup.c | 1 + src/shared/dns-domain.c | 1 + src/shared/dropin.c | 1 + src/shared/efivars.c | 1 + src/shared/firewall-util.c | 3 +- src/shared/fstab-util.c | 1 + src/shared/generator.c | 1 + src/shared/import-util.c | 1 + src/shared/install-printf.c | 1 + src/shared/install.c | 1 + src/shared/logs-show.c | 1 + src/shared/machine-image.c | 1 + src/shared/machine-pool.c | 1 + src/shared/path-lookup.c | 1 + src/shared/ptyfwd.c | 1 + src/shared/sleep-config.c | 1 + src/shared/specifier.c | 3 +- src/shared/utmp-wtmp.c | 1 + src/socket-proxy/socket-proxyd.c | 1 + src/systemctl/systemctl.c | 1 + src/sysusers/sysusers.c | 1 + src/sysv-generator/sysv-generator.c | 1 + src/test/test-calendarspec.c | 1 + src/test/test-cap-list.c | 1 + src/test/test-cgroup-util.c | 1 + src/test/test-condition.c | 1 + src/test/test-conf-files.c | 1 + src/test/test-copy.c | 1 + src/test/test-date.c | 3 +- src/test/test-device-nodes.c | 1 + src/test/test-dns-domain.c | 1 + src/test/test-ellipsize.c | 1 + src/test/test-fileio.c | 1 + src/test/test-fstab-util.c | 1 + src/test/test-hashmap-plain.c | 1 + src/test/test-hostname-util.c | 3 +- src/test/test-id128.c | 1 + src/test/test-json.c | 1 + src/test/test-namespace.c | 1 + src/test/test-path-util.c | 1 + src/test/test-path.c | 1 + src/test/test-prioq.c | 5 +- src/test/test-process-util.c | 1 + src/test/test-socket-util.c | 1 + src/test/test-strv.c | 1 + src/test/test-tmpfiles.c | 1 + src/test/test-uid-range.c | 1 + src/test/test-unit-file.c | 1 + src/test/test-unit-name.c | 1 + src/test/test-user-util.c | 1 + src/test/test-utf8.c | 1 + src/test/test-util.c | 1 + src/test/test-xml.c | 1 + src/timedate/timedated.c | 1 + src/timesync/timesyncd-conf.c | 5 +- src/timesync/timesyncd-manager.c | 1 + src/timesync/timesyncd-server.c | 1 + src/tmpfiles/tmpfiles.c | 1 + .../tty-ask-password-agent.c | 1 + src/udev/collect/collect.c | 1 + src/udev/net/link-config.c | 1 + src/udev/udev-builtin-blkid.c | 1 + src/udev/udev-builtin-hwdb.c | 1 + src/udev/udev-builtin-net_setup_link.c | 3 +- src/udev/udev-builtin-path_id.c | 1 + src/udev/udev-builtin-usb_id.c | 1 + src/udev/udev-ctrl.c | 1 + src/udev/udev-event.c | 1 + src/udev/udev-rules.c | 1 + src/udev/udevadm-hwdb.c | 1 + src/udev/udevd.c | 1 + src/update-utmp/update-utmp.c | 11 ++- src/vconsole/vconsole-setup.c | 1 + 399 files changed, 691 insertions(+), 232 deletions(-) create mode 100644 src/basic/alloc-util.c create mode 100644 src/basic/alloc-util.h (limited to 'src/shared/fstab-util.c') diff --git a/Makefile.am b/Makefile.am index 3c4250a144..9250f8f2c5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -943,6 +943,8 @@ libbasic_la_SOURCES = \ src/basic/rm-rf.h \ src/basic/copy.c \ src/basic/copy.h \ + src/basic/alloc-util.h \ + src/basic/alloc-util.c \ src/basic/formats-util.h nodist_libbasic_la_SOURCES = \ diff --git a/src/activate/activate.c b/src/activate/activate.c index 0e6ead310e..b7e6255f49 100644 --- a/src/activate/activate.c +++ b/src/activate/activate.c @@ -28,13 +28,14 @@ #include "sd-daemon.h" +#include "alloc-util.h" +#include "fd-util.h" #include "log.h" #include "macro.h" #include "signal-util.h" #include "socket-util.h" #include "string-util.h" #include "strv.h" -#include "fd-util.h" static char** arg_listen = NULL; static bool arg_accept = false; diff --git a/src/analyze/analyze-verify.c b/src/analyze/analyze-verify.c index 2b6240232c..a377996a37 100644 --- a/src/analyze/analyze-verify.c +++ b/src/analyze/analyze-verify.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "analyze-verify.h" #include "bus-util.h" #include "log.h" diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 7e63bfa821..27ead903e9 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -27,6 +27,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "analyze-verify.h" #include "bus-error.h" #include "bus-util.h" diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c index 9112ed328d..08980fba82 100644 --- a/src/backlight/backlight.c +++ b/src/backlight/backlight.c @@ -21,6 +21,7 @@ #include "libudev.h" +#include "alloc-util.h" #include "def.h" #include "escape.h" #include "fileio.h" diff --git a/src/basic/alloc-util.c b/src/basic/alloc-util.c new file mode 100644 index 0000000000..48183e381f --- /dev/null +++ b/src/basic/alloc-util.c @@ -0,0 +1,81 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/*** + This file is part of systemd. + + Copyright 2010 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see . +***/ + +#include "alloc-util.h" +#include "util.h" + +void* memdup(const void *p, size_t l) { + void *r; + + assert(p); + + r = malloc(l); + if (!r) + return NULL; + + memcpy(r, p, l); + return r; +} + +void* greedy_realloc(void **p, size_t *allocated, size_t need, size_t size) { + size_t a, newalloc; + void *q; + + assert(p); + assert(allocated); + + if (*allocated >= need) + return *p; + + newalloc = MAX(need * 2, 64u / size); + a = newalloc * size; + + /* check for overflows */ + if (a < size * need) + return NULL; + + q = realloc(*p, a); + if (!q) + return NULL; + + *p = q; + *allocated = newalloc; + return q; +} + +void* greedy_realloc0(void **p, size_t *allocated, size_t need, size_t size) { + size_t prev; + uint8_t *q; + + assert(p); + assert(allocated); + + prev = *allocated; + + q = greedy_realloc(p, allocated, need, size); + if (!q) + return NULL; + + if (*allocated > prev) + memzero(q + prev * size, (*allocated - prev) * size); + + return q; +} diff --git a/src/basic/alloc-util.h b/src/basic/alloc-util.h new file mode 100644 index 0000000000..12b602e185 --- /dev/null +++ b/src/basic/alloc-util.h @@ -0,0 +1,108 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +#pragma once + +/*** + This file is part of systemd. + + Copyright 2010 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see . +***/ + +#include +#include +#include + +#include "macro.h" + +#define new(t, n) ((t*) malloc_multiply(sizeof(t), (n))) + +#define new0(t, n) ((t*) calloc((n), sizeof(t))) + +#define newa(t, n) ((t*) alloca(sizeof(t)*(n))) + +#define newa0(t, n) ((t*) alloca0(sizeof(t)*(n))) + +#define newdup(t, p, n) ((t*) memdup_multiply(p, sizeof(t), (n))) + +#define malloc0(n) (calloc(1, (n))) + +static inline void *mfree(void *memory) { + free(memory); + return NULL; +} + +void* memdup(const void *p, size_t l) _alloc_(2); + +static inline void freep(void *p) { + free(*(void**) p); +} + +#define _cleanup_free_ _cleanup_(freep) + +_malloc_ _alloc_(1, 2) static inline void *malloc_multiply(size_t a, size_t b) { + if (_unlikely_(b != 0 && a > ((size_t) -1) / b)) + return NULL; + + return malloc(a * b); +} + +_alloc_(2, 3) static inline void *realloc_multiply(void *p, size_t a, size_t b) { + if (_unlikely_(b != 0 && a > ((size_t) -1) / b)) + return NULL; + + return realloc(p, a * b); +} + +_alloc_(2, 3) static inline void *memdup_multiply(const void *p, size_t a, size_t b) { + if (_unlikely_(b != 0 && a > ((size_t) -1) / b)) + return NULL; + + return memdup(p, a * b); +} + +void* greedy_realloc(void **p, size_t *allocated, size_t need, size_t size); +void* greedy_realloc0(void **p, size_t *allocated, size_t need, size_t size); + +#define GREEDY_REALLOC(array, allocated, need) \ + greedy_realloc((void**) &(array), &(allocated), (need), sizeof((array)[0])) + +#define GREEDY_REALLOC0(array, allocated, need) \ + greedy_realloc0((void**) &(array), &(allocated), (need), sizeof((array)[0])) + +#define alloca0(n) \ + ({ \ + char *_new_; \ + size_t _len_ = n; \ + _new_ = alloca(_len_); \ + (void *) memset(_new_, 0, _len_); \ + }) + +/* It's not clear what alignment glibc/gcc alloca() guarantee, hence provide a guaranteed safe version */ +#define alloca_align(size, align) \ + ({ \ + void *_ptr_; \ + size_t _mask_ = (align) - 1; \ + _ptr_ = alloca((size) + _mask_); \ + (void*)(((uintptr_t)_ptr_ + _mask_) & ~_mask_); \ + }) + +#define alloca0_align(size, align) \ + ({ \ + void *_new_; \ + size_t _size_ = (size); \ + _new_ = alloca_align(_size_, (align)); \ + (void*)memset(_new_, 0, _size_); \ + }) diff --git a/src/basic/audit-util.c b/src/basic/audit-util.c index 93d1adaf99..4612297334 100644 --- a/src/basic/audit-util.c +++ b/src/basic/audit-util.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "audit-util.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/basic/bitmap.c b/src/basic/bitmap.c index 2eabf3e1c1..1449e2ea85 100644 --- a/src/basic/bitmap.c +++ b/src/basic/bitmap.c @@ -19,9 +19,9 @@ along with systemd; If not, see . ***/ -#include "util.h" - +#include "alloc-util.h" #include "bitmap.h" +#include "util.h" struct Bitmap { uint64_t *bitmaps; diff --git a/src/basic/btrfs-util.c b/src/basic/btrfs-util.c index 7457e9f218..4c90bc0c80 100644 --- a/src/basic/btrfs-util.c +++ b/src/basic/btrfs-util.c @@ -26,6 +26,7 @@ #include #endif +#include "alloc-util.h" #include "btrfs-ctree.h" #include "btrfs-util.h" #include "copy.h" diff --git a/src/basic/bus-label.c b/src/basic/bus-label.c index 6f39528f13..c1534657ac 100644 --- a/src/basic/bus-label.c +++ b/src/basic/bus-label.c @@ -21,9 +21,10 @@ #include +#include "alloc-util.h" #include "bus-label.h" -#include "macro.h" #include "hexdecoct.h" +#include "macro.h" #include "util.h" char *bus_label_escape(const char *s) { diff --git a/src/basic/calendarspec.c b/src/basic/calendarspec.c index 62b03a913c..a6a906f453 100644 --- a/src/basic/calendarspec.c +++ b/src/basic/calendarspec.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "string-util.h" #include "calendarspec.h" #include "fileio.h" diff --git a/src/basic/capability-util.c b/src/basic/capability-util.c index 3a6ceed6f5..4479200306 100644 --- a/src/basic/capability-util.c +++ b/src/basic/capability-util.c @@ -26,6 +26,7 @@ #include #include +#include "alloc-util.h" #include "capability-util.h" #include "fileio.h" #include "log.h" diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 0f0e144b5e..f7fc2c2c97 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -29,6 +29,7 @@ #include #include +#include "alloc-util.h" #include "cgroup-util.h" #include "dirent-util.h" #include "extract-word.h" diff --git a/src/basic/copy.c b/src/basic/copy.c index a3a4099b4d..a187ae08fe 100644 --- a/src/basic/copy.c +++ b/src/basic/copy.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "btrfs-util.h" #include "chattr-util.h" #include "copy.h" diff --git a/src/basic/cpu-set-util.c b/src/basic/cpu-set-util.c index cbeae0bf20..9122ea5d48 100644 --- a/src/basic/cpu-set-util.c +++ b/src/basic/cpu-set-util.c @@ -20,6 +20,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "cpu-set-util.h" #include "extract-word.h" #include "parse-util.h" diff --git a/src/basic/env-util.c b/src/basic/env-util.c index a392af737c..94cb251698 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -22,12 +22,13 @@ #include #include +#include "alloc-util.h" #include "def.h" +#include "env-util.h" #include "string-util.h" #include "strv.h" #include "utf8.h" #include "util.h" -#include "env-util.h" #define VALID_CHARS_ENV_NAME \ DIGITS LETTERS \ diff --git a/src/basic/escape.c b/src/basic/escape.c index e763b5dac2..add0d7795b 100644 --- a/src/basic/escape.c +++ b/src/basic/escape.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "escape.h" #include "hexdecoct.h" #include "utf8.h" diff --git a/src/basic/extract-word.c b/src/basic/extract-word.c index f2b74802fa..c0f9394fad 100644 --- a/src/basic/extract-word.c +++ b/src/basic/extract-word.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "escape.h" #include "utf8.h" #include "util.h" diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 3dfd3af8af..619dafb517 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "ctype.h" #include "escape.h" #include "fd-util.h" diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 6ad381afb4..7aee404bfc 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "dirent-util.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c index 015cc629b1..4109a08c6c 100644 --- a/src/basic/hashmap.c +++ b/src/basic/hashmap.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "hashmap.h" #include "macro.h" #include "mempool.h" diff --git a/src/basic/hexdecoct.c b/src/basic/hexdecoct.c index f958582e68..4eb566b15a 100644 --- a/src/basic/hexdecoct.c +++ b/src/basic/hexdecoct.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "hexdecoct.h" #include "util.h" diff --git a/src/basic/in-addr-util.c b/src/basic/in-addr-util.c index d88864b598..f4e24121e7 100644 --- a/src/basic/in-addr-util.c +++ b/src/basic/in-addr-util.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "in-addr-util.h" int in_addr_is_null(int family, const union in_addr_union *u) { diff --git a/src/basic/json.c b/src/basic/json.c index efe635e20e..716705e5ff 100644 --- a/src/basic/json.c +++ b/src/basic/json.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "json.h" #include "macro.h" #include "hexdecoct.h" diff --git a/src/basic/lockfile-util.c b/src/basic/lockfile-util.c index 60235cc972..87c3aef7af 100644 --- a/src/basic/lockfile-util.c +++ b/src/basic/lockfile-util.c @@ -27,6 +27,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" diff --git a/src/basic/log.c b/src/basic/log.c index 505c0d072c..1582fce61c 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -31,6 +31,7 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "fd-util.h" #include "formats-util.h" #include "io-util.h" diff --git a/src/basic/memfd-util.c b/src/basic/memfd-util.c index 9d638b27f0..92630f6b25 100644 --- a/src/basic/memfd-util.c +++ b/src/basic/memfd-util.c @@ -27,6 +27,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "memfd-util.h" #include "missing.h" diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c index 24e88babcd..fefa50709c 100644 --- a/src/basic/mount-util.c +++ b/src/basic/mount-util.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "escape.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 3783129f69..ec90c432a4 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -33,6 +33,7 @@ #include #undef basename +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" diff --git a/src/basic/prioq.c b/src/basic/prioq.c index d55b348c22..7590698911 100644 --- a/src/basic/prioq.c +++ b/src/basic/prioq.c @@ -29,8 +29,9 @@ * The underlying algorithm used in this implementation is a Heap. */ -#include "util.h" +#include "alloc-util.h" #include "prioq.h" +#include "util.h" struct prioq_item { void *data; diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c index dd0e18ed6e..dd91ce7dbc 100644 --- a/src/basic/proc-cmdline.c +++ b/src/basic/proc-cmdline.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "extract-word.h" #include "fileio.h" #include "macro.h" diff --git a/src/basic/process-util.c b/src/basic/process-util.c index c5d7dc3089..c534656c97 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -28,6 +28,7 @@ #include #include +#include "alloc-util.h" #include "escape.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/basic/replace-var.c b/src/basic/replace-var.c index 478fc43a38..18b49a9227 100644 --- a/src/basic/replace-var.c +++ b/src/basic/replace-var.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "macro.h" #include "util.h" #include "replace-var.h" diff --git a/src/basic/selinux-util.c b/src/basic/selinux-util.c index 7a7dc90e3c..a821a3d5bb 100644 --- a/src/basic/selinux-util.c +++ b/src/basic/selinux-util.c @@ -29,6 +29,7 @@ #include #endif +#include "alloc-util.h" #include "strv.h" #include "path-util.h" #include "selinux-util.h" diff --git a/src/basic/smack-util.c b/src/basic/smack-util.c index a96fb5b594..fcc046098d 100644 --- a/src/basic/smack-util.c +++ b/src/basic/smack-util.c @@ -23,6 +23,7 @@ #include +#include "alloc-util.h" #include "fileio.h" #include "path-util.h" #include "process-util.h" diff --git a/src/basic/socket-label.c b/src/basic/socket-label.c index 4099ea6f9f..e5d4efc719 100644 --- a/src/basic/socket-label.c +++ b/src/basic/socket-label.c @@ -25,6 +25,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "macro.h" #include "missing.h" diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index ef5b764e60..1acab1ef95 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -30,6 +30,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "formats-util.h" diff --git a/src/basic/strbuf.c b/src/basic/strbuf.c index 01a076c2ba..f4f702a05a 100644 --- a/src/basic/strbuf.c +++ b/src/basic/strbuf.c @@ -22,8 +22,9 @@ #include #include -#include "util.h" +#include "alloc-util.h" #include "strbuf.h" +#include "util.h" /* * Strbuf stores given strings in a single continuous allocated memory diff --git a/src/basic/string-util.c b/src/basic/string-util.c index a1781c505a..63b9b79df9 100644 --- a/src/basic/string-util.c +++ b/src/basic/string-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "gunicode.h" #include "utf8.h" #include "util.h" diff --git a/src/basic/strv.c b/src/basic/strv.c index f5df269006..ba6df716a7 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "escape.h" #include "string-util.h" #include "util.h" diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 7d694e4664..b96bfcb8ef 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -31,6 +31,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 867e7b2430..9dc280efc6 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c index 43f52ce7c8..0775ae7c14 100644 --- a/src/basic/unit-name.c +++ b/src/basic/unit-name.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "bus-label.h" #include "def.h" #include "hexdecoct.h" diff --git a/src/basic/user-util.c b/src/basic/user-util.c index bdee77a7d2..d6c936db37 100644 --- a/src/basic/user-util.c +++ b/src/basic/user-util.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "macro.h" #include "parse-util.h" diff --git a/src/basic/utf8.c b/src/basic/utf8.c index de124abbde..7600d99903 100644 --- a/src/basic/utf8.c +++ b/src/basic/utf8.c @@ -49,6 +49,7 @@ #include #include +#include "alloc-util.h" #include "hexdecoct.h" #include "utf8.h" #include "util.h" diff --git a/src/basic/util.c b/src/basic/util.c index 6da311ad1e..62d58c13fd 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -69,6 +69,7 @@ * otherwise conflicts with sys/mount.h. Yay, Linux is great! */ #include +#include "alloc-util.h" #include "build.h" #include "def.h" #include "device-nodes.h" @@ -487,19 +488,6 @@ int prot_from_flags(int flags) { } } -void* memdup(const void *p, size_t l) { - void *r; - - assert(p); - - r = malloc(l); - if (!r) - return NULL; - - memcpy(r, p, l); - return r; -} - int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...) { bool stdout_is_tty, stderr_is_tty; pid_t parent_pid, agent_pid; @@ -725,51 +713,6 @@ int on_ac_power(void) { return found_online || !found_offline; } -void* greedy_realloc(void **p, size_t *allocated, size_t need, size_t size) { - size_t a, newalloc; - void *q; - - assert(p); - assert(allocated); - - if (*allocated >= need) - return *p; - - newalloc = MAX(need * 2, 64u / size); - a = newalloc * size; - - /* check for overflows */ - if (a < size * need) - return NULL; - - q = realloc(*p, a); - if (!q) - return NULL; - - *p = q; - *allocated = newalloc; - return q; -} - -void* greedy_realloc0(void **p, size_t *allocated, size_t need, size_t size) { - size_t prev; - uint8_t *q; - - assert(p); - assert(allocated); - - prev = *allocated; - - q = greedy_realloc(p, allocated, need, size); - if (!q) - return NULL; - - if (*allocated > prev) - memzero(q + prev * size, (*allocated - prev) * size); - - return q; -} - bool id128_is_valid(const char *s) { size_t i, l; diff --git a/src/basic/util.h b/src/basic/util.h index 3074029f38..e2fceafd9a 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -54,23 +54,6 @@ size_t page_size(void) _pure_; #define PAGE_ALIGN(l) ALIGN_TO((l), page_size()) -#define new(t, n) ((t*) malloc_multiply(sizeof(t), (n))) - -#define new0(t, n) ((t*) calloc((n), sizeof(t))) - -#define newa(t, n) ((t*) alloca(sizeof(t)*(n))) - -#define newa0(t, n) ((t*) alloca0(sizeof(t)*(n))) - -#define newdup(t, p, n) ((t*) memdup_multiply(p, sizeof(t), (n))) - -#define malloc0(n) (calloc(1, (n))) - -static inline void *mfree(void *memory) { - free(memory); - return NULL; -} - static inline const char* yes_no(bool b) { return b ? "yes" : "no"; } @@ -118,60 +101,35 @@ bool kexec_loaded(void); int prot_from_flags(int flags) _const_; -void* memdup(const void *p, size_t l) _alloc_(2); - int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...); bool in_initrd(void); -static inline void freep(void *p) { - free(*(void**) p); -} - -#define _cleanup_free_ _cleanup_(freep) - -_malloc_ _alloc_(1, 2) static inline void *malloc_multiply(size_t a, size_t b) { - if (_unlikely_(b != 0 && a > ((size_t) -1) / b)) - return NULL; - - return malloc(a * b); -} - -_alloc_(2, 3) static inline void *realloc_multiply(void *p, size_t a, size_t b) { - if (_unlikely_(b != 0 && a > ((size_t) -1) / b)) - return NULL; - - return realloc(p, a * b); -} - -_alloc_(2, 3) static inline void *memdup_multiply(const void *p, size_t a, size_t b) { - if (_unlikely_(b != 0 && a > ((size_t) -1) / b)) - return NULL; - - return memdup(p, a * b); -} - void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, int (*compar) (const void *, const void *, void *), void *arg); -int on_ac_power(void); +/** + * Normal qsort requires base to be nonnull. Here were require + * that only if nmemb > 0. + */ +static inline void qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) { + if (nmemb <= 1) + return; -static inline void *mempset(void *s, int c, size_t n) { - memset(s, c, n); - return (uint8_t*)s + n; + assert(base); + qsort(base, nmemb, size, compar); } +int on_ac_power(void); + #define memzero(x,l) (memset((x), 0, (l))) #define zero(x) (memzero(&(x), sizeof(x))) -void* greedy_realloc(void **p, size_t *allocated, size_t need, size_t size); -void* greedy_realloc0(void **p, size_t *allocated, size_t need, size_t size); -#define GREEDY_REALLOC(array, allocated, need) \ - greedy_realloc((void**) &(array), &(allocated), (need), sizeof((array)[0])) - -#define GREEDY_REALLOC0(array, allocated, need) \ - greedy_realloc0((void**) &(array), &(allocated), (need), sizeof((array)[0])) +static inline void *mempset(void *s, int c, size_t n) { + memset(s, c, n); + return (uint8_t*)s + n; +} static inline void _reset_errno_(int *saved_errno) { errno = *saved_errno; @@ -225,45 +183,8 @@ static inline unsigned log2u_round_up(unsigned x) { return log2u(x - 1) + 1; } -#define alloca0(n) \ - ({ \ - char *_new_; \ - size_t _len_ = n; \ - _new_ = alloca(_len_); \ - (void *) memset(_new_, 0, _len_); \ - }) - -/* It's not clear what alignment glibc/gcc alloca() guarantee, hence provide a guaranteed safe version */ -#define alloca_align(size, align) \ - ({ \ - void *_ptr_; \ - size_t _mask_ = (align) - 1; \ - _ptr_ = alloca((size) + _mask_); \ - (void*)(((uintptr_t)_ptr_ + _mask_) & ~_mask_); \ - }) - -#define alloca0_align(size, align) \ - ({ \ - void *_new_; \ - size_t _size_ = (size); \ - _new_ = alloca_align(_size_, (align)); \ - (void*)memset(_new_, 0, _size_); \ - }) - bool id128_is_valid(const char *s) _pure_; -/** - * Normal qsort requires base to be nonnull. Here were require - * that only if nmemb > 0. - */ -static inline void qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) { - if (nmemb <= 1) - return; - - assert(base); - qsort(base, nmemb, size, compar); -} - int container_get_leader(const char *machine, pid_t *pid); int namespace_open(pid_t pid, int *pidns_fd, int *mntns_fd, int *netns_fd, int *userns_fd, int *root_fd); diff --git a/src/basic/virt.c b/src/basic/virt.c index 19f93b95aa..fb181e5b55 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -23,9 +23,10 @@ #include #include +#include "alloc-util.h" #include "fileio.h" -#include "stat-util.h" #include "process-util.h" +#include "stat-util.h" #include "string-table.h" #include "string-util.h" #include "util.h" diff --git a/src/basic/xattr-util.c b/src/basic/xattr-util.c index 7351337c6b..6abdaedc3e 100644 --- a/src/basic/xattr-util.c +++ b/src/basic/xattr-util.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "fd-util.h" #include "sparse-endian.h" #include "stdio-util.h" diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c index b96695c353..8e63153c92 100644 --- a/src/binfmt/binfmt.c +++ b/src/binfmt/binfmt.c @@ -27,6 +27,7 @@ #include #include +#include "alloc-util.h" #include "conf-files.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 332bb33545..4cf42d17f3 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -37,6 +37,7 @@ #include #include +#include "alloc-util.h" #include "blkid-util.h" #include "efivars.h" #include "fd-util.h" diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c index c0019174ab..6723fa5098 100644 --- a/src/bootchart/bootchart.c +++ b/src/bootchart/bootchart.c @@ -48,6 +48,7 @@ #include "sd-journal.h" +#include "alloc-util.h" #include "bootchart.h" #include "conf-parser.h" #include "fd-util.h" diff --git a/src/bootchart/store.c b/src/bootchart/store.c index e488c94b3b..c1b1e77e44 100644 --- a/src/bootchart/store.c +++ b/src/bootchart/store.c @@ -31,6 +31,7 @@ #include #include +#include "alloc-util.h" #include "bootchart.h" #include "cgroup-util.h" #include "dirent-util.h" diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c index 43eca90618..05330c0577 100644 --- a/src/bootchart/svg.c +++ b/src/bootchart/svg.c @@ -30,6 +30,7 @@ #include #include +#include "alloc-util.h" #include "architecture.h" #include "util.h" #include "fileio.h" diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c index fc8edaeb36..6a7134644f 100644 --- a/src/bus-proxyd/bus-proxyd.c +++ b/src/bus-proxyd/bus-proxyd.c @@ -33,6 +33,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "bus-internal.h" #include "bus-xml-policy.h" #include "capability-util.h" diff --git a/src/bus-proxyd/bus-xml-policy.c b/src/bus-proxyd/bus-xml-policy.c index 1b9fdedca3..f0834e9525 100644 --- a/src/bus-proxyd/bus-xml-policy.c +++ b/src/bus-proxyd/bus-xml-policy.c @@ -21,6 +21,7 @@ #include "sd-login.h" +#include "alloc-util.h" #include "bus-internal.h" #include "bus-xml-policy.h" #include "conf-files.h" diff --git a/src/bus-proxyd/driver.c b/src/bus-proxyd/driver.c index 4e859412f8..2e8bd83efd 100644 --- a/src/bus-proxyd/driver.c +++ b/src/bus-proxyd/driver.c @@ -27,6 +27,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-internal.h" #include "bus-message.h" #include "bus-util.h" diff --git a/src/bus-proxyd/proxy.c b/src/bus-proxyd/proxy.c index 6c251b5244..db399b24f2 100644 --- a/src/bus-proxyd/proxy.c +++ b/src/bus-proxyd/proxy.c @@ -31,6 +31,7 @@ #include "sd-bus.h" #include "sd-daemon.h" +#include "alloc-util.h" #include "bus-control.h" #include "bus-internal.h" #include "bus-message.h" diff --git a/src/bus-proxyd/stdio-bridge.c b/src/bus-proxyd/stdio-bridge.c index a009ea76c4..6e47884209 100644 --- a/src/bus-proxyd/stdio-bridge.c +++ b/src/bus-proxyd/stdio-bridge.c @@ -30,6 +30,7 @@ #include "sd-daemon.h" #include "sd-bus.h" +#include "alloc-util.h" #include "bus-internal.h" #include "bus-util.h" #include "def.h" diff --git a/src/bus-proxyd/test-bus-xml-policy.c b/src/bus-proxyd/test-bus-xml-policy.c index cb7ff6b970..1f465edd91 100644 --- a/src/bus-proxyd/test-bus-xml-policy.c +++ b/src/bus-proxyd/test-bus-xml-policy.c @@ -25,6 +25,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-xml-policy.h" #include "log.h" #include "string-util.h" diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c index 41c539a1bc..4e9a76a100 100644 --- a/src/cgls/cgls.c +++ b/src/cgls/cgls.c @@ -27,6 +27,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "cgroup-show.h" diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index 43b8af4420..eea8aea76b 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -30,6 +30,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "cgroup-util.h" diff --git a/src/core/automount.c b/src/core/automount.c index 50a7772753..715e52e794 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -29,6 +29,7 @@ #include #include +#include "alloc-util.h" #include "async.h" #include "automount.h" #include "bus-error.h" diff --git a/src/core/bus-endpoint.c b/src/core/bus-endpoint.c index 0c4b3e7c8b..d22a80c91f 100644 --- a/src/core/bus-endpoint.c +++ b/src/core/bus-endpoint.c @@ -19,10 +19,11 @@ #include -#include "kdbus.h" +#include "alloc-util.h" +#include "bus-endpoint.h" #include "bus-kernel.h" #include "bus-policy.h" -#include "bus-endpoint.h" +#include "kdbus.h" int bus_kernel_set_endpoint_policy(int fd, uid_t uid, BusEndpoint *ep) { diff --git a/src/core/bus-policy.c b/src/core/bus-policy.c index 7ad18fb28c..4907c268e8 100644 --- a/src/core/bus-policy.c +++ b/src/core/bus-policy.c @@ -19,6 +19,7 @@ #include +#include "alloc-util.h" #include "bus-kernel.h" #include "bus-policy.h" #include "kdbus.h" diff --git a/src/core/busname.c b/src/core/busname.c index 94674c99fa..9fed54ffc8 100644 --- a/src/core/busname.c +++ b/src/core/busname.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "bus-internal.h" #include "bus-kernel.h" #include "bus-policy.h" diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 0d37e69cd9..90cee12be7 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "cgroup-util.h" #include "cgroup.h" #include "fd-util.h" diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index f424909b46..3fd295baa9 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "bus-util.h" #include "cgroup-util.h" #include "cgroup.h" diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 67405a1672..882a76e988 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -26,6 +26,7 @@ #endif #include "af-list.h" +#include "alloc-util.h" #include "bus-util.h" #include "capability-util.h" #include "dbus-execute.h" diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c index e95ec5c0cb..8c30d66250 100644 --- a/src/core/dbus-job.c +++ b/src/core/dbus-job.c @@ -21,12 +21,13 @@ #include "sd-bus.h" +#include "alloc-util.h" +#include "dbus-job.h" #include "dbus.h" #include "job.h" #include "log.h" #include "selinux-access.h" #include "string-util.h" -#include "dbus-job.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, job_type, JobType); static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_state, job_state, JobState); diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 3f631bd9a0..1f9f25093d 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "architecture.h" #include "build.h" #include "bus-common-errors.h" diff --git a/src/core/dbus-scope.c b/src/core/dbus-scope.c index f8fb373bf0..16375b2311 100644 --- a/src/core/dbus-scope.c +++ b/src/core/dbus-scope.c @@ -19,17 +19,18 @@ along with systemd; If not, see . ***/ -#include "selinux-access.h" -#include "unit.h" -#include "scope.h" -#include "dbus.h" -#include "bus-util.h" -#include "bus-internal.h" +#include "alloc-util.h" #include "bus-common-errors.h" -#include "dbus-unit.h" +#include "bus-internal.h" +#include "bus-util.h" #include "dbus-cgroup.h" #include "dbus-kill.h" #include "dbus-scope.h" +#include "dbus-unit.h" +#include "dbus.h" +#include "scope.h" +#include "selinux-access.h" +#include "unit.h" static int bus_scope_abandon(sd_bus_message *message, void *userdata, sd_bus_error *error) { Scope *s = userdata; diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c index 91cdeb1f30..c41b3e1723 100644 --- a/src/core/dbus-service.c +++ b/src/core/dbus-service.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "async.h" #include "bus-util.h" #include "dbus-cgroup.h" diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c index 5941b72bc0..be5ef261a6 100644 --- a/src/core/dbus-socket.c +++ b/src/core/dbus-socket.c @@ -19,13 +19,14 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "bus-util.h" #include "dbus-cgroup.h" #include "dbus-execute.h" +#include "dbus-socket.h" #include "socket.h" #include "string-util.h" #include "unit.h" -#include "dbus-socket.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, socket_result, SocketResult); static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only); diff --git a/src/core/dbus-timer.c b/src/core/dbus-timer.c index 8ea2cf84a4..a8a280d961 100644 --- a/src/core/dbus-timer.c +++ b/src/core/dbus-timer.c @@ -19,11 +19,12 @@ along with systemd; If not, see . ***/ -#include "unit.h" -#include "timer.h" -#include "dbus-timer.h" +#include "alloc-util.h" #include "bus-util.h" +#include "dbus-timer.h" #include "strv.h" +#include "timer.h" +#include "unit.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, timer_result, TimerResult); diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 10cd80389b..6320cd1aa9 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -21,6 +21,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-common-errors.h" #include "cgroup-util.h" #include "dbus-unit.h" diff --git a/src/core/dbus.c b/src/core/dbus.c index bbab0aeddb..834745aeb5 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -25,6 +25,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-error.h" #include "bus-internal.h" diff --git a/src/core/device.c b/src/core/device.c index 90bb2c45fd..23ee7aee7e 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -24,6 +24,7 @@ #include "libudev.h" +#include "alloc-util.h" #include "dbus-device.h" #include "device.h" #include "log.h" diff --git a/src/core/execute.c b/src/core/execute.c index bf13e29bd9..d751065af0 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -53,6 +53,7 @@ #include "sd-messages.h" #include "af-list.h" +#include "alloc-util.h" #ifdef HAVE_APPARMOR #include "apparmor-util.h" #endif diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c index f1563afff9..cc7515905d 100644 --- a/src/core/hostname-setup.c +++ b/src/core/hostname-setup.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "fileio.h" #include "hostname-util.h" #include "log.h" diff --git a/src/core/job.c b/src/core/job.c index 44532d0d5a..120381fc3b 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -24,6 +24,7 @@ #include "sd-id128.h" #include "sd-messages.h" +#include "alloc-util.h" #include "async.h" #include "dbus-job.h" #include "dbus.h" diff --git a/src/core/killall.c b/src/core/killall.c index dbfa90ebac..77f145b4d1 100644 --- a/src/core/killall.c +++ b/src/core/killall.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "formats-util.h" #include "killall.h" diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 72e918ed54..c1d09e8e5a 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -32,6 +32,7 @@ #include #include +#include "alloc-util.h" #include "af-list.h" #include "bus-error.h" #include "bus-internal.h" diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c index d00d3e94bb..145ba2a28d 100644 --- a/src/core/machine-id-setup.c +++ b/src/core/machine-id-setup.c @@ -29,6 +29,7 @@ #include "sd-id128.h" +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" diff --git a/src/core/main.c b/src/core/main.c index d9c888d747..593b974566 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -40,6 +40,7 @@ #include "sd-daemon.h" #include "sd-bus.h" +#include "alloc-util.h" #include "architecture.h" #include "build.h" #include "bus-error.h" diff --git a/src/core/manager.c b/src/core/manager.c index bf0cf069ca..04111091e7 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -40,6 +40,7 @@ #include "sd-daemon.h" #include "sd-messages.h" +#include "alloc-util.h" #include "audit-fd.h" #include "boot-timestamps.h" #include "bus-common-errors.h" diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c index 1ab4ee5b1a..b2596d1cd1 100644 --- a/src/core/mount-setup.c +++ b/src/core/mount-setup.c @@ -25,6 +25,7 @@ #include #include +#include "alloc-util.h" #include "bus-util.h" #include "cgroup-util.h" #include "dev-setup.h" diff --git a/src/core/mount.c b/src/core/mount.c index f04f386930..68cf312fca 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -26,6 +26,7 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "dbus-mount.h" #include "escape.h" #include "exit-status.h" @@ -40,8 +41,8 @@ #include "path-util.h" #include "smack-util.h" #include "special.h" -#include "string-util.h" #include "string-table.h" +#include "string-util.h" #include "strv.h" #include "unit-name.h" #include "unit.h" diff --git a/src/core/namespace.c b/src/core/namespace.c index 6c49ff32fe..81ba09ea5d 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -28,6 +28,7 @@ #include #include +#include "alloc-util.h" #include "dev-setup.h" #include "fd-util.h" #include "loopback-setup.h" diff --git a/src/core/scope.c b/src/core/scope.c index 13de02cf16..6bacb226e8 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -22,16 +22,17 @@ #include #include +#include "alloc-util.h" #include "dbus-scope.h" #include "load-dropin.h" #include "log.h" +#include "scope.h" #include "special.h" #include "string-table.h" #include "string-util.h" #include "strv.h" #include "unit-name.h" #include "unit.h" -#include "scope.h" static const UnitActiveState state_translation_table[_SCOPE_STATE_MAX] = { [SCOPE_DEAD] = UNIT_INACTIVE, diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c index a9368ead22..4bcdd27389 100644 --- a/src/core/selinux-access.c +++ b/src/core/selinux-access.c @@ -33,6 +33,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "audit-fd.h" #include "bus-util.h" #include "log.h" diff --git a/src/core/service.c b/src/core/service.c index 54a420d6f0..2d92799fec 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "async.h" #include "bus-error.h" #include "bus-kernel.h" diff --git a/src/core/show-status.c b/src/core/show-status.c index 81166abf23..e4e12a3365 100644 --- a/src/core/show-status.c +++ b/src/core/show-status.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "fd-util.h" #include "io-util.h" #include "parse-util.h" diff --git a/src/core/shutdown.c b/src/core/shutdown.c index 93bbc315d3..3a95b5fd72 100644 --- a/src/core/shutdown.c +++ b/src/core/shutdown.c @@ -31,6 +31,7 @@ #include #include +#include "alloc-util.h" #include "cgroup-util.h" #include "def.h" #include "fileio.h" diff --git a/src/core/slice.c b/src/core/slice.c index 8fb6d28a3c..4602144150 100644 --- a/src/core/slice.c +++ b/src/core/slice.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "dbus-slice.h" #include "log.h" #include "special.h" diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c index b8cb9964a6..0661ff9ecd 100644 --- a/src/core/smack-setup.c +++ b/src/core/smack-setup.c @@ -28,6 +28,7 @@ #include #include +#include "alloc-util.h" #include "dirent-util.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/core/snapshot.c b/src/core/snapshot.c index da1c99ad12..ba3135f401 100644 --- a/src/core/snapshot.c +++ b/src/core/snapshot.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "bus-common-errors.h" #include "dbus-snapshot.h" #include "parse-util.h" diff --git a/src/core/socket.c b/src/core/socket.c index c145aa6081..d8b8cf576a 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -31,6 +31,7 @@ #include "sd-event.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "copy.h" diff --git a/src/core/swap.c b/src/core/swap.c index cb2da1cb5c..5be3c709bf 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -26,6 +26,7 @@ #include "libudev.h" +#include "alloc-util.h" #include "dbus-swap.h" #include "escape.h" #include "exit-status.h" diff --git a/src/core/timer.c b/src/core/timer.c index 47e501815a..cc2afedabf 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "dbus-timer.h" diff --git a/src/core/transaction.c b/src/core/transaction.c index d1c1b9a3cd..69f28c902f 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -22,10 +22,11 @@ #include #include +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-error.h" -#include "transaction.h" #include "terminal-util.h" +#include "transaction.h" static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies); diff --git a/src/core/umount.c b/src/core/umount.c index 8735bed7b1..9d1f7660db 100644 --- a/src/core/umount.c +++ b/src/core/umount.c @@ -29,6 +29,7 @@ #include "libudev.h" +#include "alloc-util.h" #include "escape.h" #include "fd-util.h" #include "fstab-util.h" diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c index 4a5c7efdb0..721c8ccce9 100644 --- a/src/core/unit-printf.c +++ b/src/core/unit-printf.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "cgroup-util.h" #include "formats-util.h" #include "macro.h" diff --git a/src/core/unit.c b/src/core/unit.c index 11d3bb9633..8d56401231 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -28,6 +28,7 @@ #include "sd-id128.h" #include "sd-messages.h" +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-util.h" #include "cgroup-util.h" diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index 54a89452a3..ae53bac600 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "dropin.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 8531b6b125..98fe52a81b 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -27,6 +27,7 @@ #include "sd-device.h" +#include "alloc-util.h" #include "ask-password-api.h" #include "device-util.h" #include "escape.h" diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c index 66a0fe9ea2..b57bf9a57d 100644 --- a/src/dbus1-generator/dbus1-generator.c +++ b/src/dbus1-generator/dbus1-generator.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "bus-internal.h" #include "bus-util.h" #include "cgroup-util.h" diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c index 1a98cbaef8..e16c3b9453 100644 --- a/src/debug-generator/debug-generator.c +++ b/src/debug-generator/debug-generator.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "mkdir.h" #include "parse-util.h" #include "proc-cmdline.h" diff --git a/src/delta/delta.c b/src/delta/delta.c index 4ade23ffab..6c25b185ed 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -26,6 +26,7 @@ #include #include +#include "alloc-util.h" #include "dirent-util.h" #include "fd-util.h" #include "fs-util.h" diff --git a/src/escape/escape.c b/src/escape/escape.c index 9390558554..e857affbc4 100644 --- a/src/escape/escape.c +++ b/src/escape/escape.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "log.h" #include "string-util.h" #include "strv.h" diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 30ea942d14..46cfe9f851 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "ask-password-api.h" #include "copy.h" #include "fd-util.h" diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index 4119edde30..5b806a1e69 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -32,6 +32,7 @@ #include "sd-bus.h" #include "sd-device.h" +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-error.h" #include "bus-util.h" diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index a51ecd9f7a..f7c8d11ace 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -25,6 +25,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "fstab-util.h" diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c index 0997cc5fae..03df7365b5 100644 --- a/src/getty-generator/getty-generator.c +++ b/src/getty-generator/getty-generator.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "log.h" diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index cc1bd3f50e..5ea6c86898 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -27,6 +27,7 @@ #include "libudev.h" #include "sd-id128.h" +#include "alloc-util.h" #include "blkid-util.h" #include "btrfs-util.h" #include "dirent-util.h" diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c index 8c3a09501f..da719f2a30 100644 --- a/src/hibernate-resume/hibernate-resume-generator.c +++ b/src/hibernate-resume/hibernate-resume-generator.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "fstab-util.h" #include "log.h" #include "mkdir.h" diff --git a/src/hibernate-resume/hibernate-resume.c b/src/hibernate-resume/hibernate-resume.c index 1f3b169905..316a2803d3 100644 --- a/src/hibernate-resume/hibernate-resume.c +++ b/src/hibernate-resume/hibernate-resume.c @@ -23,9 +23,10 @@ #include #include +#include "alloc-util.h" +#include "fileio.h" #include "log.h" #include "util.h" -#include "fileio.h" int main(int argc, char *argv[]) { struct stat st; diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c index 0724fcc16d..bf09fb8fbb 100644 --- a/src/hostname/hostnamectl.c +++ b/src/hostname/hostnamectl.c @@ -28,6 +28,7 @@ #include "sd-bus.h" #include "sd-id128.h" +#include "alloc-util.h" #include "architecture.h" #include "bus-error.h" #include "bus-util.h" diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index 5c63a025a3..92061532b8 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "bus-util.h" #include "def.h" #include "env-util.h" diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c index 48d0883a3a..de59b797a6 100644 --- a/src/hwdb/hwdb.c +++ b/src/hwdb/hwdb.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "conf-files.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/import/curl-util.c b/src/import/curl-util.c index 455fa1e07d..4278466df1 100644 --- a/src/import/curl-util.c +++ b/src/import/curl-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "curl-util.h" #include "fd-util.h" #include "string-util.h" diff --git a/src/import/export-raw.c b/src/import/export-raw.c index 85e781a308..103d45bf21 100644 --- a/src/import/export-raw.c +++ b/src/import/export-raw.c @@ -25,6 +25,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "btrfs-util.h" #include "copy.h" #include "export-raw.h" diff --git a/src/import/export-tar.c b/src/import/export-tar.c index 38e659a517..2bbec661e6 100644 --- a/src/import/export-tar.c +++ b/src/import/export-tar.c @@ -21,6 +21,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "btrfs-util.h" #include "export-tar.h" #include "fd-util.h" diff --git a/src/import/export.c b/src/import/export.c index 6ff732d73f..2b33d778d3 100644 --- a/src/import/export.c +++ b/src/import/export.c @@ -23,6 +23,7 @@ #include "sd-event.h" +#include "alloc-util.h" #include "event-util.h" #include "export-raw.h" #include "export-tar.h" diff --git a/src/import/import-raw.c b/src/import/import-raw.c index 87f4a3935d..2193d1d7f1 100644 --- a/src/import/import-raw.c +++ b/src/import/import-raw.c @@ -24,6 +24,7 @@ #include "sd-daemon.h" #include "sd-event.h" +#include "alloc-util.h" #include "btrfs-util.h" #include "chattr-util.h" #include "copy.h" diff --git a/src/import/import-tar.c b/src/import/import-tar.c index 64eb5ccd83..2ae1d88168 100644 --- a/src/import/import-tar.c +++ b/src/import/import-tar.c @@ -24,6 +24,7 @@ #include "sd-daemon.h" #include "sd-event.h" +#include "alloc-util.h" #include "btrfs-util.h" #include "copy.h" #include "fd-util.h" diff --git a/src/import/import.c b/src/import/import.c index 76b38e4903..018b94d4c4 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -23,6 +23,7 @@ #include "sd-event.h" +#include "alloc-util.h" #include "event-util.h" #include "fd-util.h" #include "fs-util.h" diff --git a/src/import/importd.c b/src/import/importd.c index 65e2354640..4228681cea 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -23,6 +23,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-util.h" #include "def.h" diff --git a/src/import/pull-common.c b/src/import/pull-common.c index c235848821..d6567ba7ee 100644 --- a/src/import/pull-common.c +++ b/src/import/pull-common.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "btrfs-util.h" #include "capability-util.h" #include "copy.h" diff --git a/src/import/pull-dkr.c b/src/import/pull-dkr.c index 786651d581..831470ff13 100644 --- a/src/import/pull-dkr.c +++ b/src/import/pull-dkr.c @@ -24,6 +24,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "aufs-util.h" #include "btrfs-util.h" #include "curl-util.h" diff --git a/src/import/pull-job.c b/src/import/pull-job.c index 3cc7ea10b7..824fa246ec 100644 --- a/src/import/pull-job.c +++ b/src/import/pull-job.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "fd-util.h" #include "hexdecoct.h" #include "io-util.h" diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c index c3476714c8..394131680d 100644 --- a/src/import/pull-raw.c +++ b/src/import/pull-raw.c @@ -25,6 +25,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "btrfs-util.h" #include "chattr-util.h" #include "copy.h" diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c index 43b7b65586..26c0bc5866 100644 --- a/src/import/pull-tar.c +++ b/src/import/pull-tar.c @@ -24,6 +24,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "btrfs-util.h" #include "copy.h" #include "curl-util.h" diff --git a/src/import/pull.c b/src/import/pull.c index 5e6cd50688..39f5b2d8e4 100644 --- a/src/import/pull.c +++ b/src/import/pull.c @@ -23,6 +23,7 @@ #include "sd-event.h" +#include "alloc-util.h" #include "event-util.h" #include "hostname-util.h" #include "import-util.h" diff --git a/src/import/qcow2-util.c b/src/import/qcow2-util.c index fd3cf1b0e3..47dabaa86e 100644 --- a/src/import/qcow2-util.c +++ b/src/import/qcow2-util.c @@ -21,10 +21,11 @@ #include -#include "util.h" -#include "sparse-endian.h" -#include "qcow2-util.h" +#include "alloc-util.h" #include "btrfs-util.h" +#include "qcow2-util.h" +#include "sparse-endian.h" +#include "util.h" #define QCOW2_MAGIC 0x514649fb diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c index 2b374c0288..f1cf31a4a8 100644 --- a/src/initctl/initctl.c +++ b/src/initctl/initctl.c @@ -28,6 +28,7 @@ #include "sd-bus.h" #include "sd-daemon.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "def.h" diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c index b8a513bb74..6b93a758f6 100644 --- a/src/journal-remote/journal-gatewayd.c +++ b/src/journal-remote/journal-gatewayd.c @@ -33,6 +33,7 @@ #include "sd-daemon.h" #include "sd-journal.h" +#include "alloc-util.h" #include "bus-util.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c index db1636ac3e..3ff40228a0 100644 --- a/src/journal-remote/journal-remote-parse.c +++ b/src/journal-remote/journal-remote-parse.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "fd-util.h" #include "journal-remote-parse.h" #include "journald-native.h" diff --git a/src/journal-remote/journal-remote-write.c b/src/journal-remote/journal-remote-write.c index 40f4ff8e58..d8250378b0 100644 --- a/src/journal-remote/journal-remote-write.c +++ b/src/journal-remote/journal-remote-write.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "journal-remote.h" int iovw_put(struct iovec_wrapper *iovw, void* data, size_t len) { diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index f70d278e1c..a2c49b8b4d 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -35,6 +35,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "conf-parser.h" #include "escape.h" #include "fd-util.h" diff --git a/src/journal-remote/journal-upload-journal.c b/src/journal-remote/journal-upload-journal.c index 6b3ad924a7..3ee6d32bf7 100644 --- a/src/journal-remote/journal-upload-journal.c +++ b/src/journal-remote/journal-upload-journal.c @@ -1,11 +1,33 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/*** + This file is part of systemd. + + Copyright 2014 Zbigniew Jędrzejewski-Szmek + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see . +***/ + #include #include -#include "util.h" +#include "alloc-util.h" +#include "journal-upload.h" #include "log.h" #include "utf8.h" -#include "journal-upload.h" +#include "util.h" /** * Write up to size bytes to buf. Return negative on error, and number of diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 1925475db8..7d274d2fc9 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -27,6 +27,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "conf-parser.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c index df068a089c..b2c398a845 100644 --- a/src/journal-remote/microhttpd-util.c +++ b/src/journal-remote/microhttpd-util.c @@ -29,6 +29,7 @@ #include #endif +#include "alloc-util.h" #include "log.h" #include "macro.h" #include "string-util.h" diff --git a/src/journal/catalog.c b/src/journal/catalog.c index 72d2bedc26..95a6857472 100644 --- a/src/journal/catalog.c +++ b/src/journal/catalog.c @@ -29,6 +29,7 @@ #include "sd-id128.h" +#include "alloc-util.h" #include "catalog.h" #include "conf-files.h" #include "fd-util.h" diff --git a/src/journal/compress.c b/src/journal/compress.c index 196d6ff425..e1ca0a8818 100644 --- a/src/journal/compress.c +++ b/src/journal/compress.c @@ -33,6 +33,7 @@ #include #endif +#include "alloc-util.h" #include "compress.h" #include "fd-util.h" #include "io-util.h" diff --git a/src/journal/coredump-vacuum.c b/src/journal/coredump-vacuum.c index 9635db19e1..39bc2e4270 100644 --- a/src/journal/coredump-vacuum.c +++ b/src/journal/coredump-vacuum.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "coredump-vacuum.h" #include "dirent-util.h" #include "fd-util.h" diff --git a/src/journal/coredump.c b/src/journal/coredump.c index f32e2d4a9f..2e543537f6 100644 --- a/src/journal/coredump.c +++ b/src/journal/coredump.c @@ -34,6 +34,7 @@ #include "sd-login.h" #include "acl-util.h" +#include "alloc-util.h" #include "capability-util.h" #include "cgroup-util.h" #include "compress.h" diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c index 07ca8dde0a..af4d051138 100644 --- a/src/journal/coredumpctl.c +++ b/src/journal/coredumpctl.c @@ -28,6 +28,7 @@ #include "sd-journal.h" +#include "alloc-util.h" #include "compress.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 6f9b8a2915..12b39dbb27 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -28,6 +28,7 @@ #include #include +#include "alloc-util.h" #include "btrfs-util.h" #include "chattr-util.h" #include "compress.h" diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c index 8fe99fae99..fa5dee73c3 100644 --- a/src/journal/journal-send.c +++ b/src/journal/journal-send.c @@ -31,6 +31,7 @@ #include "sd-journal.h" +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "io-util.h" diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c index 87646922fb..4b5fc76eb1 100644 --- a/src/journal/journal-vacuum.c +++ b/src/journal/journal-vacuum.c @@ -25,6 +25,7 @@ #include "sd-id128.h" +#include "alloc-util.h" #include "dirent-util.h" #include "fd-util.h" #include "journal-def.h" diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c index 5d000aedbb..b78ce98b17 100644 --- a/src/journal/journal-verify.c +++ b/src/journal/journal-verify.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "compress.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 2782ac0329..a35783e3ff 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -39,6 +39,7 @@ #include "sd-journal.h" #include "acl-util.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "catalog.h" diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c index 6a8ef7dd40..3c13fe0d67 100644 --- a/src/journal/journald-audit.c +++ b/src/journal/journald-audit.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "audit-type.h" #include "fd-util.h" #include "hexdecoct.h" diff --git a/src/journal/journald-console.c b/src/journal/journald-console.c index 72c4ba5879..860832cfc8 100644 --- a/src/journal/journald-console.c +++ b/src/journal/journald-console.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "formats-util.h" diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c index 9f3b1e3b16..6fff4fe473 100644 --- a/src/journal/journald-native.c +++ b/src/journal/journald-native.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fs-util.h" #include "io-util.h" diff --git a/src/journal/journald-rate-limit.c b/src/journal/journald-rate-limit.c index 6e9557c06e..434ddc8ac9 100644 --- a/src/journal/journald-rate-limit.c +++ b/src/journal/journald-rate-limit.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "hashmap.h" #include "list.h" #include "random-util.h" diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 03cc074e7a..ecf7b7a476 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -34,6 +34,7 @@ #include "sd-messages.h" #include "acl-util.h" +#include "alloc-util.h" #include "audit-util.h" #include "cgroup-util.h" #include "conf-parser.h" diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index 0dd6d54d68..5300c61c02 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -29,6 +29,7 @@ #include "sd-daemon.h" #include "sd-event.h" +#include "alloc-util.h" #include "dirent-util.h" #include "escape.h" #include "fd-util.h" diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index 3553e9cc1d..f3ac1a7ae0 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -25,6 +25,7 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "fd-util.h" #include "formats-util.h" #include "io-util.h" diff --git a/src/journal/journald-wall.c b/src/journal/journald-wall.c index 5284914941..69540f1141 100644 --- a/src/journal/journald-wall.c +++ b/src/journal/journald-wall.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "formats-util.h" #include "journald-server.h" #include "process-util.h" diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c index 22f75540b8..3cb1dfa986 100644 --- a/src/journal/mmap-cache.c +++ b/src/journal/mmap-cache.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "hashmap.h" #include "list.h" #include "log.h" diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index bd93d90776..6eda5162c7 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -30,6 +30,7 @@ #include "sd-journal.h" +#include "alloc-util.h" #include "catalog.h" #include "compress.h" #include "dirent-util.h" diff --git a/src/journal/stacktrace.c b/src/journal/stacktrace.c index e32550d644..4305462f80 100644 --- a/src/journal/stacktrace.c +++ b/src/journal/stacktrace.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "formats-util.h" #include "macro.h" diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c index c942df46a8..aea8fd15e6 100644 --- a/src/journal/test-catalog.c +++ b/src/journal/test-catalog.c @@ -27,6 +27,7 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "catalog.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c index 5a2f0564ca..93ea9c6318 100644 --- a/src/journal/test-compress-benchmark.c +++ b/src/journal/test-compress-benchmark.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "compress.h" #include "macro.h" #include "parse-util.h" diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c index db4fa15554..b9d90a8988 100644 --- a/src/journal/test-compress.c +++ b/src/journal/test-compress.c @@ -17,6 +17,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "compress.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/journal/test-journal-flush.c b/src/journal/test-journal-flush.c index 6061623ae7..03d1522e23 100644 --- a/src/journal/test-journal-flush.c +++ b/src/journal/test-journal-flush.c @@ -23,6 +23,7 @@ #include "sd-journal.h" +#include "alloc-util.h" #include "journal-file.h" #include "journal-internal.h" #include "macro.h" diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c index 3c8b0268a4..4ad89fe4b6 100644 --- a/src/journal/test-journal-interleaving.c +++ b/src/journal/test-journal-interleaving.c @@ -25,6 +25,7 @@ #include "sd-journal.h" +#include "alloc-util.h" #include "journal-file.h" #include "journal-vacuum.h" #include "log.h" diff --git a/src/journal/test-journal-match.c b/src/journal/test-journal-match.c index 476477055a..abefedb992 100644 --- a/src/journal/test-journal-match.c +++ b/src/journal/test-journal-match.c @@ -23,6 +23,7 @@ #include "sd-journal.h" +#include "alloc-util.h" #include "journal-internal.h" #include "log.h" #include "string-util.h" diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c index b8482743a2..0cbef4b8c5 100644 --- a/src/journal/test-journal-stream.c +++ b/src/journal/test-journal-stream.c @@ -24,6 +24,7 @@ #include "sd-journal.h" +#include "alloc-util.h" #include "journal-file.h" #include "journal-internal.h" #include "log.h" diff --git a/src/journal/test-journal-syslog.c b/src/journal/test-journal-syslog.c index de942c50cc..1784187fe9 100644 --- a/src/journal/test-journal-syslog.c +++ b/src/journal/test-journal-syslog.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "journald-syslog.h" #include "macro.h" #include "string-util.h" diff --git a/src/libsystemd-network/dhcp6-option.c b/src/libsystemd-network/dhcp6-option.c index f41bebced0..076bb2dac0 100644 --- a/src/libsystemd-network/dhcp6-option.c +++ b/src/libsystemd-network/dhcp6-option.c @@ -23,14 +23,14 @@ #include #include -#include "sparse-endian.h" -#include "unaligned.h" -#include "util.h" -#include "strv.h" - +#include "alloc-util.h" #include "dhcp6-internal.h" #include "dhcp6-protocol.h" #include "dns-domain.h" +#include "sparse-endian.h" +#include "strv.h" +#include "unaligned.h" +#include "util.h" #define DHCP6_OPTION_IA_NA_LEN 12 #define DHCP6_OPTION_IA_TA_LEN 4 diff --git a/src/libsystemd-network/lldp-internal.c b/src/libsystemd-network/lldp-internal.c index 70061e914f..583be2f55d 100644 --- a/src/libsystemd-network/lldp-internal.c +++ b/src/libsystemd-network/lldp-internal.c @@ -22,6 +22,7 @@ #include "sd-lldp.h" +#include "alloc-util.h" #include "lldp-internal.h" /* We store maximum 1K chassis entries */ diff --git a/src/libsystemd-network/lldp-port.c b/src/libsystemd-network/lldp-port.c index 7486b4c38f..97b6b485d2 100644 --- a/src/libsystemd-network/lldp-port.c +++ b/src/libsystemd-network/lldp-port.c @@ -20,6 +20,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "async.h" #include "lldp-port.h" #include "lldp-network.h" diff --git a/src/libsystemd-network/lldp-tlv.c b/src/libsystemd-network/lldp-tlv.c index 66af22e37d..0851957ab4 100644 --- a/src/libsystemd-network/lldp-tlv.c +++ b/src/libsystemd-network/lldp-tlv.c @@ -23,8 +23,9 @@ #include #include -#include "macro.h" +#include "alloc-util.h" #include "lldp-tlv.h" +#include "macro.h" int tlv_section_new(tlv_section **ret) { tlv_section *s; diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index d86977be17..52d76e443e 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -25,6 +25,7 @@ #include "sd-ndisc.h" +#include "alloc-util.h" #include "condition.h" #include "conf-parser.h" #include "dhcp-lease-internal.h" diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index a6d6a176e4..57fc8216c3 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -28,6 +28,7 @@ #include "sd-dhcp-client.h" +#include "alloc-util.h" #include "async.h" #include "dhcp-identifier.h" #include "dhcp-internal.h" diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index 3411f6ec91..c850538d74 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -26,6 +26,7 @@ #include "sd-dhcp-lease.h" +#include "alloc-util.h" #include "dhcp-lease-internal.h" #include "dhcp-protocol.h" #include "dns-domain.h" diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index a2a8c16fc8..8d0d9955c3 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -24,6 +24,7 @@ #include "sd-dhcp-server.h" +#include "alloc-util.h" #include "dhcp-internal.h" #include "dhcp-server-internal.h" #include "fd-util.h" diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index 559c5e4df4..e29de60d24 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -26,6 +26,7 @@ #include "sd-dhcp6-client.h" +#include "alloc-util.h" #include "dhcp-identifier.h" #include "dhcp6-internal.h" #include "dhcp6-lease-internal.h" diff --git a/src/libsystemd-network/sd-dhcp6-lease.c b/src/libsystemd-network/sd-dhcp6-lease.c index f34af6eaba..3f32ba35e7 100644 --- a/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/libsystemd-network/sd-dhcp6-lease.c @@ -22,11 +22,11 @@ #include -#include "strv.h" -#include "util.h" - +#include "alloc-util.h" #include "dhcp6-lease-internal.h" #include "dhcp6-protocol.h" +#include "strv.h" +#include "util.h" int dhcp6_lease_clear_timers(DHCP6IA *ia) { assert_return(ia, -EINVAL); diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c index 3053724ea2..5340fdc0c1 100644 --- a/src/libsystemd-network/sd-ipv4acd.c +++ b/src/libsystemd-network/sd-ipv4acd.c @@ -26,6 +26,7 @@ #include "sd-ipv4acd.h" +#include "alloc-util.h" #include "arp-util.h" #include "event-util.h" #include "fd-util.h" diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c index 68ec58da90..0d915e20e7 100644 --- a/src/libsystemd-network/sd-ipv4ll.c +++ b/src/libsystemd-network/sd-ipv4ll.c @@ -27,6 +27,7 @@ #include "sd-ipv4acd.h" #include "sd-ipv4ll.h" +#include "alloc-util.h" #include "event-util.h" #include "in-addr-util.h" #include "list.h" diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c index bc06f48386..4ebe8053fa 100644 --- a/src/libsystemd-network/sd-lldp.c +++ b/src/libsystemd-network/sd-lldp.c @@ -24,6 +24,7 @@ #include "sd-lldp.h" +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "hashmap.h" diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c index ca4bb6325b..c494b9d6d8 100644 --- a/src/libsystemd-network/sd-ndisc.c +++ b/src/libsystemd-network/sd-ndisc.c @@ -26,6 +26,7 @@ #include "sd-ndisc.h" +#include "alloc-util.h" #include "async.h" #include "icmp6-util.h" #include "list.h" diff --git a/src/libsystemd-network/sd-pppoe.c b/src/libsystemd-network/sd-pppoe.c index 03a88973bf..045decc46c 100644 --- a/src/libsystemd-network/sd-pppoe.c +++ b/src/libsystemd-network/sd-pppoe.c @@ -30,6 +30,7 @@ #include "sd-pppoe.h" +#include "alloc-util.h" #include "async.h" #include "event-util.h" #include "fd-util.h" diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c index 40a85eb25e..5b52c1cbb9 100644 --- a/src/libsystemd-network/test-dhcp-client.c +++ b/src/libsystemd-network/test-dhcp-client.c @@ -27,6 +27,7 @@ #include "sd-dhcp-client.h" #include "sd-event.h" +#include "alloc-util.h" #include "dhcp-identifier.h" #include "dhcp-internal.h" #include "dhcp-protocol.h" diff --git a/src/libsystemd-network/test-dhcp-option.c b/src/libsystemd-network/test-dhcp-option.c index b1ef174849..2d29e28f16 100644 --- a/src/libsystemd-network/test-dhcp-option.c +++ b/src/libsystemd-network/test-dhcp-option.c @@ -5,11 +5,11 @@ #include #include -#include "util.h" -#include "macro.h" - -#include "dhcp-protocol.h" +#include "alloc-util.h" #include "dhcp-internal.h" +#include "dhcp-protocol.h" +#include "macro.h" +#include "util.h" struct option_desc { uint8_t sname[64]; diff --git a/src/libsystemd-network/test-ipv4ll-manual.c b/src/libsystemd-network/test-ipv4ll-manual.c index 9485a7df64..913a929069 100644 --- a/src/libsystemd-network/test-ipv4ll-manual.c +++ b/src/libsystemd-network/test-ipv4ll-manual.c @@ -29,6 +29,7 @@ #include "sd-ipv4ll.h" #include "sd-netlink.h" +#include "alloc-util.h" #include "event-util.h" #include "in-addr-util.h" #include "netlink-util.h" diff --git a/src/libsystemd-network/test-lldp.c b/src/libsystemd-network/test-lldp.c index 109462662f..931df7c170 100644 --- a/src/libsystemd-network/test-lldp.c +++ b/src/libsystemd-network/test-lldp.c @@ -28,6 +28,7 @@ #include "sd-event.h" #include "sd-lldp.h" +#include "alloc-util.h" #include "event-util.h" #include "fd-util.h" #include "lldp-network.h" diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c index 5951db483d..d5bc32e757 100644 --- a/src/libsystemd/sd-bus/bus-control.c +++ b/src/libsystemd/sd-bus/bus-control.c @@ -28,6 +28,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-bloom.h" #include "bus-control.h" #include "bus-internal.h" diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index 7c99904c64..2922da3763 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "audit-util.h" #include "bus-creds.h" #include "bus-label.h" diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c index ab4e9cbc06..43a7e67a6d 100644 --- a/src/libsystemd/sd-bus/bus-dump.c +++ b/src/libsystemd/sd-bus/bus-dump.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "bus-dump.h" #include "bus-internal.h" #include "bus-message.h" diff --git a/src/libsystemd/sd-bus/bus-error.c b/src/libsystemd/sd-bus/bus-error.c index 831ceb86b9..84229c2964 100644 --- a/src/libsystemd/sd-bus/bus-error.c +++ b/src/libsystemd/sd-bus/bus-error.c @@ -28,6 +28,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "errno-list.h" #include "string-util.h" #include "util.h" diff --git a/src/libsystemd/sd-bus/bus-internal.c b/src/libsystemd/sd-bus/bus-internal.c index 8cab1bf219..d9f9cd1c5e 100644 --- a/src/libsystemd/sd-bus/bus-internal.c +++ b/src/libsystemd/sd-bus/bus-internal.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "bus-internal.h" #include "bus-message.h" #include "hexdecoct.h" diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index a32b0ef221..6716f6daca 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -34,6 +34,7 @@ #include #undef basename +#include "alloc-util.h" #include "bus-bloom.h" #include "bus-internal.h" #include "bus-kernel.h" diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c index 6a37f22c1f..55dc7caa53 100644 --- a/src/libsystemd/sd-bus/bus-match.c +++ b/src/libsystemd/sd-bus/bus-match.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "bus-internal.h" #include "bus-match.h" #include "bus-message.h" diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index d5a6ad581f..5c80095bf0 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -25,6 +25,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-gvariant.h" #include "bus-internal.h" #include "bus-message.h" diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index d3679800b5..8c472626a8 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "bus-internal.h" #include "bus-introspect.h" #include "bus-message.h" diff --git a/src/libsystemd/sd-bus/bus-slot.c b/src/libsystemd/sd-bus/bus-slot.c index 63f10eba2c..550bad27ba 100644 --- a/src/libsystemd/sd-bus/bus-slot.c +++ b/src/libsystemd/sd-bus/bus-slot.c @@ -21,6 +21,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-control.h" #include "bus-objects.h" #include "string-util.h" diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c index 2c46d84cd0..a5cb667630 100644 --- a/src/libsystemd/sd-bus/bus-socket.c +++ b/src/libsystemd/sd-bus/bus-socket.c @@ -27,6 +27,7 @@ #include "sd-bus.h" #include "sd-daemon.h" +#include "alloc-util.h" #include "bus-internal.h" #include "bus-message.h" #include "bus-socket.h" diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c index 0911156e19..fd7e58fcfa 100644 --- a/src/libsystemd/sd-bus/bus-track.c +++ b/src/libsystemd/sd-bus/bus-track.c @@ -21,6 +21,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-internal.h" #include "bus-track.h" #include "bus-util.h" diff --git a/src/libsystemd/sd-bus/busctl-introspect.c b/src/libsystemd/sd-bus/busctl-introspect.c index 5604db9716..71f962b00c 100644 --- a/src/libsystemd/sd-bus/busctl-introspect.c +++ b/src/libsystemd/sd-bus/busctl-introspect.c @@ -21,10 +21,11 @@ #include "sd-bus.h" +#include "alloc-util.h" +#include "busctl-introspect.h" #include "string-util.h" #include "util.h" #include "xml.h" -#include "busctl-introspect.h" #define NODE_DEPTH_MAX 16 diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c index 4fa60bb185..452ac7c407 100644 --- a/src/libsystemd/sd-bus/busctl.c +++ b/src/libsystemd/sd-bus/busctl.c @@ -23,6 +23,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-dump.h" #include "bus-internal.h" #include "bus-signature.h" diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 0d92a0d461..a8d79b01b0 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -29,6 +29,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-container.h" #include "bus-control.h" #include "bus-internal.h" diff --git a/src/libsystemd/sd-bus/test-bus-benchmark.c b/src/libsystemd/sd-bus/test-bus-benchmark.c index 549c88cd2d..96a0929a14 100644 --- a/src/libsystemd/sd-bus/test-bus-benchmark.c +++ b/src/libsystemd/sd-bus/test-bus-benchmark.c @@ -23,6 +23,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-internal.h" #include "bus-kernel.h" #include "bus-util.h" diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c index e9e5e4a8e3..767aef63ff 100644 --- a/src/libsystemd/sd-bus/test-bus-chat.c +++ b/src/libsystemd/sd-bus/test-bus-chat.c @@ -26,6 +26,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-internal.h" #include "bus-match.h" diff --git a/src/libsystemd/sd-bus/test-bus-gvariant.c b/src/libsystemd/sd-bus/test-bus-gvariant.c index f94da4cccd..931c001788 100644 --- a/src/libsystemd/sd-bus/test-bus-gvariant.c +++ b/src/libsystemd/sd-bus/test-bus-gvariant.c @@ -25,6 +25,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-dump.h" #include "bus-gvariant.h" #include "bus-internal.h" diff --git a/src/libsystemd/sd-bus/test-bus-kernel-bloom.c b/src/libsystemd/sd-bus/test-bus-kernel-bloom.c index ff7f9cdafa..dbdaa69fbe 100644 --- a/src/libsystemd/sd-bus/test-bus-kernel-bloom.c +++ b/src/libsystemd/sd-bus/test-bus-kernel-bloom.c @@ -21,6 +21,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-kernel.h" #include "bus-util.h" #include "fd-util.h" diff --git a/src/libsystemd/sd-bus/test-bus-kernel.c b/src/libsystemd/sd-bus/test-bus-kernel.c index 7d05953cd0..0080f71d3b 100644 --- a/src/libsystemd/sd-bus/test-bus-kernel.c +++ b/src/libsystemd/sd-bus/test-bus-kernel.c @@ -23,6 +23,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-dump.h" #include "bus-kernel.h" #include "bus-util.h" diff --git a/src/libsystemd/sd-bus/test-bus-marshal.c b/src/libsystemd/sd-bus/test-bus-marshal.c index 7da1dacd81..0747d6a37c 100644 --- a/src/libsystemd/sd-bus/test-bus-marshal.c +++ b/src/libsystemd/sd-bus/test-bus-marshal.c @@ -32,6 +32,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-dump.h" #include "bus-label.h" #include "bus-message.h" diff --git a/src/libsystemd/sd-bus/test-bus-objects.c b/src/libsystemd/sd-bus/test-bus-objects.c index 138db910ea..5bc72e2355 100644 --- a/src/libsystemd/sd-bus/test-bus-objects.c +++ b/src/libsystemd/sd-bus/test-bus-objects.c @@ -24,6 +24,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-dump.h" #include "bus-internal.h" #include "bus-message.h" diff --git a/src/libsystemd/sd-bus/test-bus-proxy.c b/src/libsystemd/sd-bus/test-bus-proxy.c index ae04ff5b0d..428e185769 100644 --- a/src/libsystemd/sd-bus/test-bus-proxy.c +++ b/src/libsystemd/sd-bus/test-bus-proxy.c @@ -25,6 +25,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-dump.h" #include "bus-kernel.h" #include "bus-util.h" diff --git a/src/libsystemd/sd-bus/test-bus-zero-copy.c b/src/libsystemd/sd-bus/test-bus-zero-copy.c index 1be0dbcd82..ff8df61a9e 100644 --- a/src/libsystemd/sd-bus/test-bus-zero-copy.c +++ b/src/libsystemd/sd-bus/test-bus-zero-copy.c @@ -23,6 +23,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-dump.h" #include "bus-kernel.h" #include "bus-message.h" diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c index 49fac7bdcc..77b5dd52f6 100644 --- a/src/libsystemd/sd-daemon/sd-daemon.c +++ b/src/libsystemd/sd-daemon/sd-daemon.c @@ -35,6 +35,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "fd-util.h" #include "fs-util.h" #include "parse-util.h" diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index e1eb5b26b3..ae3157ee5e 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -20,6 +20,7 @@ #include "sd-device.h" +#include "alloc-util.h" #include "device-enumerator-private.h" #include "device-util.h" #include "dirent-util.h" diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index 69288b833e..a13477e753 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -24,6 +24,7 @@ #include "sd-device.h" +#include "alloc-util.h" #include "device-internal.h" #include "device-private.h" #include "device-util.h" diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 3b964de56b..0d40bc5c00 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -24,6 +24,7 @@ #include "sd-device.h" +#include "alloc-util.h" #include "device-internal.h" #include "device-private.h" #include "device-util.h" diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index b3f8881714..ee4886700e 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -27,6 +27,7 @@ #include "sd-event.h" #include "sd-id128.h" +#include "alloc-util.h" #include "fd-util.h" #include "hashmap.h" #include "list.h" diff --git a/src/libsystemd/sd-hwdb/sd-hwdb.c b/src/libsystemd/sd-hwdb/sd-hwdb.c index 9304fd376e..0e034863d6 100644 --- a/src/libsystemd/sd-hwdb/sd-hwdb.c +++ b/src/libsystemd/sd-hwdb/sd-hwdb.c @@ -29,6 +29,7 @@ #include "sd-hwdb.h" +#include "alloc-util.h" #include "fd-util.h" #include "hashmap.h" #include "hwdb-internal.h" diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c index 6b98a7c178..cd766c3f91 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -27,6 +27,7 @@ #include "sd-login.h" +#include "alloc-util.h" #include "cgroup-util.h" #include "dirent-util.h" #include "escape.h" diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c index 46aa73b38a..b0f94c9522 100644 --- a/src/libsystemd/sd-login/test-login.c +++ b/src/libsystemd/sd-login/test-login.c @@ -24,6 +24,7 @@ #include "sd-login.h" +#include "alloc-util.h" #include "fd-util.h" #include "formats-util.h" #include "string-util.h" diff --git a/src/libsystemd/sd-netlink/local-addresses.c b/src/libsystemd/sd-netlink/local-addresses.c index e2f637f7f9..a00865b56b 100644 --- a/src/libsystemd/sd-netlink/local-addresses.c +++ b/src/libsystemd/sd-netlink/local-addresses.c @@ -21,6 +21,8 @@ ***/ #include "sd-netlink.h" + +#include "alloc-util.h" #include "netlink-util.h" #include "macro.h" #include "local-addresses.h" diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c index 80ad70cfee..03971b3596 100644 --- a/src/libsystemd/sd-netlink/netlink-message.c +++ b/src/libsystemd/sd-netlink/netlink-message.c @@ -25,6 +25,7 @@ #include "sd-netlink.h" +#include "alloc-util.h" #include "formats-util.h" #include "missing.h" #include "netlink-internal.h" diff --git a/src/libsystemd/sd-netlink/netlink-socket.c b/src/libsystemd/sd-netlink/netlink-socket.c index 68a4d3c0d1..13945202e4 100644 --- a/src/libsystemd/sd-netlink/netlink-socket.c +++ b/src/libsystemd/sd-netlink/netlink-socket.c @@ -25,6 +25,7 @@ #include "sd-netlink.h" +#include "alloc-util.h" #include "formats-util.h" #include "missing.h" #include "netlink-internal.h" diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c index ba1f2a5a42..7c24e053cf 100644 --- a/src/libsystemd/sd-netlink/sd-netlink.c +++ b/src/libsystemd/sd-netlink/sd-netlink.c @@ -24,6 +24,7 @@ #include "sd-netlink.h" +#include "alloc-util.h" #include "fd-util.h" #include "hashmap.h" #include "macro.h" diff --git a/src/libsystemd/sd-netlink/test-local-addresses.c b/src/libsystemd/sd-netlink/test-local-addresses.c index 9867eec065..7180175970 100644 --- a/src/libsystemd/sd-netlink/test-local-addresses.c +++ b/src/libsystemd/sd-netlink/test-local-addresses.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "in-addr-util.h" #include "local-addresses.h" #include "af-list.h" diff --git a/src/libsystemd/sd-network/network-util.c b/src/libsystemd/sd-network/network-util.c index 8070ff07c4..a2d6c59314 100644 --- a/src/libsystemd/sd-network/network-util.c +++ b/src/libsystemd/sd-network/network-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "fd-util.h" #include "network-util.h" #include "strv.h" diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index 6cc3321f42..2eaa2626f7 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -27,6 +27,7 @@ #include "sd-network.h" +#include "alloc-util.h" #include "fileio.h" #include "macro.h" #include "string-util.h" diff --git a/src/libsystemd/sd-path/sd-path.c b/src/libsystemd/sd-path/sd-path.c index c1d42e96e5..480f1ad065 100644 --- a/src/libsystemd/sd-path/sd-path.c +++ b/src/libsystemd/sd-path/sd-path.c @@ -19,6 +19,7 @@ #include "sd-path.h" +#include "alloc-util.h" #include "architecture.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c index 724405d534..48767600c9 100644 --- a/src/libsystemd/sd-resolve/sd-resolve.c +++ b/src/libsystemd/sd-resolve/sd-resolve.c @@ -33,6 +33,7 @@ #include "sd-resolve.h" +#include "alloc-util.h" #include "fd-util.h" #include "io-util.h" #include "list.h" diff --git a/src/libsystemd/sd-resolve/test-resolve.c b/src/libsystemd/sd-resolve/test-resolve.c index 87e6e47041..05544a584c 100644 --- a/src/libsystemd/sd-resolve/test-resolve.c +++ b/src/libsystemd/sd-resolve/test-resolve.c @@ -30,6 +30,7 @@ #include "sd-resolve.h" +#include "alloc-util.h" #include "macro.h" #include "resolve-util.h" #include "socket-util.h" diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index bd349e3f64..814e016800 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -37,6 +37,7 @@ #include "libudev.h" #include "sd-device.h" +#include "alloc-util.h" #include "device-private.h" #include "device-util.h" #include "libudev-device-internal.h" diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c index 56436772b0..442f9615f2 100644 --- a/src/libudev/libudev-enumerate.c +++ b/src/libudev/libudev-enumerate.c @@ -31,6 +31,7 @@ #include "libudev.h" #include "sd-device.h" +#include "alloc-util.h" #include "device-enumerator-private.h" #include "device-util.h" #include "libudev-device-internal.h" diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c index 6dc2b0533e..eba698d163 100644 --- a/src/libudev/libudev-hwdb.c +++ b/src/libudev/libudev-hwdb.c @@ -19,6 +19,7 @@ #include "sd-hwdb.h" +#include "alloc-util.h" #include "hwdb-util.h" #include "libudev-private.h" diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c index 19e9130be0..da496ed456 100644 --- a/src/libudev/libudev-list.c +++ b/src/libudev/libudev-list.c @@ -17,11 +17,12 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include +#include #include +#include "alloc-util.h" #include "libudev-private.h" /** diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c index 0059c09e77..fedaea6118 100644 --- a/src/libudev/libudev-monitor.c +++ b/src/libudev/libudev-monitor.c @@ -30,6 +30,7 @@ #include "libudev.h" +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "formats-util.h" diff --git a/src/libudev/libudev-queue.c b/src/libudev/libudev-queue.c index a22994c8a2..58410b1b8f 100644 --- a/src/libudev/libudev-queue.c +++ b/src/libudev/libudev-queue.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "io-util.h" #include "libudev-private.h" diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c index afadfe6993..63fb05547d 100644 --- a/src/libudev/libudev.c +++ b/src/libudev/libudev.c @@ -26,6 +26,7 @@ #include "libudev.h" +#include "alloc-util.h" #include "fd-util.h" #include "libudev-private.h" #include "missing.h" diff --git a/src/locale/localed.c b/src/locale/localed.c index 1f25d232d2..720cbbaaba 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -30,6 +30,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-message.h" #include "bus-util.h" diff --git a/src/login/inhibit.c b/src/login/inhibit.c index f79f89af7e..70fef332f7 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -27,6 +27,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "fd-util.h" diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 92443c8190..aff68a49fe 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -27,6 +27,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "cgroup-show.h" diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c index acb2bd5765..d0dd569a03 100644 --- a/src/login/logind-acl.c +++ b/src/login/logind-acl.c @@ -23,6 +23,7 @@ #include #include "acl-util.h" +#include "alloc-util.h" #include "dirent-util.h" #include "escape.h" #include "fd-util.h" diff --git a/src/login/logind-action.c b/src/login/logind-action.c index 8c452456a0..185108f8f1 100644 --- a/src/login/logind-action.c +++ b/src/login/logind-action.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "conf-parser.h" diff --git a/src/login/logind-button.c b/src/login/logind-button.c index b98035be21..b08b69dbfc 100644 --- a/src/login/logind-button.c +++ b/src/login/logind-button.c @@ -28,6 +28,7 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "fd-util.h" #include "logind-button.h" #include "string-util.h" diff --git a/src/login/logind-core.c b/src/login/logind-core.c index c2541e490b..b3f30c8dc9 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -25,6 +25,7 @@ #include #include +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "cgroup-util.h" diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 4204732e7d..7890d68aa0 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -26,6 +26,7 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "audit-util.h" #include "bus-common-errors.h" #include "bus-error.h" diff --git a/src/login/logind-device.c b/src/login/logind-device.c index ee4c45fb8d..ffb9162e56 100644 --- a/src/login/logind-device.c +++ b/src/login/logind-device.c @@ -21,8 +21,9 @@ #include -#include "util.h" +#include "alloc-util.h" #include "logind-device.h" +#include "util.h" Device* device_new(Manager *m, const char *sysfs, bool master) { Device *d; diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 92b5807094..33fbdde557 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "escape.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/login/logind-seat-dbus.c b/src/login/logind-seat-dbus.c index 66626b5871..43b578f364 100644 --- a/src/login/logind-seat-dbus.c +++ b/src/login/logind-seat-dbus.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-label.h" #include "bus-util.h" diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index 2dcf8ddc62..1f4936cebe 100644 --- a/src/login/logind-seat.c +++ b/src/login/logind-seat.c @@ -26,6 +26,7 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "formats-util.h" diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c index fe398a5eb6..7810199a54 100644 --- a/src/login/logind-session-dbus.c +++ b/src/login/logind-session-dbus.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-label.h" #include "bus-util.h" diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index 3a0bb720f9..9bf3ca0995 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -27,6 +27,7 @@ #include "libudev.h" +#include "alloc-util.h" #include "bus-util.h" #include "fd-util.h" #include "logind-session-device.h" diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 26c135b2ca..a53dcb9960 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -30,6 +30,7 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "audit-util.h" #include "bus-error.h" #include "bus-util.h" diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c index 5975b579e9..df901f6558 100644 --- a/src/login/logind-user-dbus.c +++ b/src/login/logind-user-dbus.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "bus-util.h" #include "formats-util.h" #include "logind-user.h" diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 1cf9be7441..56bc5a010c 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "clean-ipc.h" diff --git a/src/login/logind-utmp.c b/src/login/logind-utmp.c index 3f4a629be3..3e7a935a34 100644 --- a/src/login/logind-utmp.c +++ b/src/login/logind-utmp.c @@ -26,6 +26,7 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "audit-util.h" #include "bus-common-errors.h" #include "bus-error.h" diff --git a/src/login/logind.c b/src/login/logind.c index 957ea1fd7e..4b8c834269 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -27,6 +27,7 @@ #include "libudev.h" #include "sd-daemon.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "conf-parser.h" diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c index c37cfdb68b..0d61f528db 100644 --- a/src/login/pam_systemd.c +++ b/src/login/pam_systemd.c @@ -30,6 +30,7 @@ #include #include +#include "alloc-util.h" #include "audit-util.h" #include "bus-common-errors.h" #include "bus-error.h" diff --git a/src/login/sysfs-show.c b/src/login/sysfs-show.c index 0f671ac90e..e9ca4bb03d 100644 --- a/src/login/sysfs-show.c +++ b/src/login/sysfs-show.c @@ -24,6 +24,7 @@ #include "libudev.h" +#include "alloc-util.h" #include "locale-util.h" #include "path-util.h" #include "string-util.h" diff --git a/src/machine/image-dbus.c b/src/machine/image-dbus.c index a287b9697a..4ec1766033 100644 --- a/src/machine/image-dbus.c +++ b/src/machine/image-dbus.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "bus-label.h" #include "bus-util.h" #include "image-dbus.h" diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c index 1132d75823..452130a29c 100644 --- a/src/machine/machine-dbus.c +++ b/src/machine/machine-dbus.c @@ -29,6 +29,7 @@ #include #undef basename +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-internal.h" #include "bus-label.h" diff --git a/src/machine/machine.c b/src/machine/machine.c index 2889cb3205..fa6b70f788 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -25,6 +25,7 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "escape.h" diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index b8b9e0f519..7e17c7a41c 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -33,6 +33,7 @@ #include "sd-bus.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "cgroup-show.h" diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 182dedda89..7827f063c1 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -25,6 +25,7 @@ #include "sd-id128.h" +#include "alloc-util.h" #include "btrfs-util.h" #include "bus-common-errors.h" #include "bus-util.h" diff --git a/src/machine/machined.c b/src/machine/machined.c index 1a61da041d..d6e7ce67fc 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -25,6 +25,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "cgroup-util.h" diff --git a/src/network/networkctl.c b/src/network/networkctl.c index d0d7669c87..97c1fe6560 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -28,6 +28,7 @@ #include "sd-netlink.h" #include "sd-network.h" +#include "alloc-util.h" #include "arphrd-list.h" #include "device-util.h" #include "ether-addr-util.h" diff --git a/src/network/networkd-address-pool.c b/src/network/networkd-address-pool.c index 08e0b9a64b..889fe1e30d 100644 --- a/src/network/networkd-address-pool.c +++ b/src/network/networkd-address-pool.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "networkd-address-pool.h" #include "networkd.h" #include "set.h" diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 1beb7ffae4..e550ee5701 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "conf-parser.h" #include "firewall-util.h" #include "netlink-util.h" diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 22594a9415..c412a2cc31 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -22,10 +22,11 @@ #include #include +#include "alloc-util.h" +#include "dhcp-lease-internal.h" #include "hostname-util.h" -#include "networkd-link.h" #include "network-internal.h" -#include "dhcp-lease-internal.h" +#include "networkd-link.h" static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c index 9cb63cb79f..c9222b8cb8 100644 --- a/src/network/networkd-fdb.c +++ b/src/network/networkd-fdb.c @@ -22,12 +22,12 @@ #include #include +#include "alloc-util.h" #include "conf-parser.h" -#include "util.h" #include "netlink-util.h" - -#include "networkd.h" #include "networkd-fdb.h" +#include "networkd.h" +#include "util.h" /* create a new FDB entry or get an existing one. */ int fdb_entry_new_static(Network *const network, diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c index f40a01fd78..7fc4510ac9 100644 --- a/src/network/networkd-link-bus.c +++ b/src/network/networkd-link-bus.c @@ -22,6 +22,7 @@ #include "bus-util.h" #include "strv.h" +#include "alloc-util.h" #include "networkd-link.h" #include "networkd.h" #include "parse-util.h" diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index ab37c43dcb..dcc2569660 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "bus-util.h" #include "dhcp-lease-internal.h" #include "fd-util.h" diff --git a/src/network/networkd-manager-bus.c b/src/network/networkd-manager-bus.c index b281f4fdb6..dafaf2daea 100644 --- a/src/network/networkd-manager-bus.c +++ b/src/network/networkd-manager-bus.c @@ -19,8 +19,8 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "bus-util.h" - #include "networkd.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_operational_state, link_operstate, LinkOperationalState); diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index af243c9a70..6b2a661ca7 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -25,6 +25,7 @@ #include "sd-daemon.h" #include "sd-netlink.h" +#include "alloc-util.h" #include "bus-util.h" #include "conf-parser.h" #include "def.h" diff --git a/src/network/networkd-netdev-bond.c b/src/network/networkd-netdev-bond.c index ce9c18d654..70105b8aa0 100644 --- a/src/network/networkd-netdev-bond.c +++ b/src/network/networkd-netdev-bond.c @@ -25,6 +25,7 @@ #include "sd-netlink.h" +#include "alloc-util.h" #include "conf-parser.h" #include "missing.h" #include "networkd-netdev-bond.h" diff --git a/src/network/networkd-netdev-tuntap.c b/src/network/networkd-netdev-tuntap.c index d04bb9bd9f..851e83537e 100644 --- a/src/network/networkd-netdev-tuntap.c +++ b/src/network/networkd-netdev-tuntap.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "networkd-netdev-tuntap.h" #include "user-util.h" diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c index 5060888a2f..dd0b400c6a 100644 --- a/src/network/networkd-netdev.c +++ b/src/network/networkd-netdev.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "conf-files.h" #include "conf-parser.h" #include "fd-util.h" diff --git a/src/network/networkd-network-bus.c b/src/network/networkd-network-bus.c index 2199b93baa..120760a986 100644 --- a/src/network/networkd-network-bus.c +++ b/src/network/networkd-network-bus.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "networkd.h" #include "string-util.h" #include "strv.h" diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index c8c6f5df11..cc8d019017 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "conf-files.h" #include "conf-parser.h" #include "dns-domain.h" diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 7ae6ca2600..4a74bc69f3 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "conf-parser.h" #include "in-addr-util.h" #include "netlink-util.h" diff --git a/src/network/networkd-wait-online-link.c b/src/network/networkd-wait-online-link.c index cc4b46d5b0..c2779ff773 100644 --- a/src/network/networkd-wait-online-link.c +++ b/src/network/networkd-wait-online-link.c @@ -22,6 +22,7 @@ #include "sd-network.h" +#include "alloc-util.h" #include "networkd-wait-online-link.h" #include "string-util.h" diff --git a/src/network/networkd-wait-online-manager.c b/src/network/networkd-wait-online-manager.c index 112d92a568..0c40ab2bb8 100644 --- a/src/network/networkd-wait-online-manager.c +++ b/src/network/networkd-wait-online-manager.c @@ -23,14 +23,13 @@ #include #include +#include "alloc-util.h" #include "netlink-util.h" - #include "network-internal.h" #include "networkd-wait-online-link.h" #include "networkd-wait-online.h" - -#include "util.h" #include "time-util.h" +#include "util.h" bool manager_ignore_link(Manager *m, Link *link) { char **ignore; diff --git a/src/network/test-network.c b/src/network/test-network.c index bac1d6781d..dbed3795e3 100644 --- a/src/network/test-network.c +++ b/src/network/test-network.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "networkd.h" #include "network-internal.h" #include "dhcp-lease-internal.h" diff --git a/src/notify/notify.c b/src/notify/notify.c index 77f017dbac..b144554702 100644 --- a/src/notify/notify.c +++ b/src/notify/notify.c @@ -27,6 +27,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "env-util.h" #include "formats-util.h" #include "log.h" diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c index 4e86ed13cb..270bcf010f 100644 --- a/src/nspawn/nspawn-cgroup.c +++ b/src/nspawn/nspawn-cgroup.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "cgroup-util.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/nspawn/nspawn-expose-ports.c b/src/nspawn/nspawn-expose-ports.c index 89c8240399..38245434da 100644 --- a/src/nspawn/nspawn-expose-ports.c +++ b/src/nspawn/nspawn-expose-ports.c @@ -21,6 +21,7 @@ #include "sd-netlink.h" +#include "alloc-util.h" #include "fd-util.h" #include "firewall-util.h" #include "in-addr-util.h" diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c index 81003dff89..ee61306aa5 100644 --- a/src/nspawn/nspawn-mount.c +++ b/src/nspawn/nspawn-mount.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "cgroup-util.h" #include "escape.h" #include "fs-util.h" diff --git a/src/nspawn/nspawn-network.c b/src/nspawn/nspawn-network.c index 4af18a4e94..29384b60b2 100644 --- a/src/nspawn/nspawn-network.c +++ b/src/nspawn/nspawn-network.c @@ -26,6 +26,7 @@ #include "sd-id128.h" #include "sd-netlink.h" +#include "alloc-util.h" #include "ether-addr-util.h" #include "netlink-util.h" #include "siphash24.h" diff --git a/src/nspawn/nspawn-settings.c b/src/nspawn/nspawn-settings.c index f088884776..ee9e70acec 100644 --- a/src/nspawn/nspawn-settings.c +++ b/src/nspawn/nspawn-settings.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "util.h" #include "conf-parser.h" #include "strv.h" diff --git a/src/nspawn/nspawn-setuid.c b/src/nspawn/nspawn-setuid.c index 6b4ca5a3f3..aa6a16309c 100644 --- a/src/nspawn/nspawn-setuid.c +++ b/src/nspawn/nspawn-setuid.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "mkdir.h" #include "nspawn-setuid.h" diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 1ce219b844..8140cda141 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -46,6 +46,7 @@ #include "sd-daemon.h" #include "sd-id128.h" +#include "alloc-util.h" #include "barrier.h" #include "base-filesystem.h" #include "blkid-util.h" diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c index 009a9ad886..ee10b105ea 100644 --- a/src/nss-myhostname/nss-myhostname.c +++ b/src/nss-myhostname/nss-myhostname.c @@ -26,6 +26,7 @@ #include #include +#include "alloc-util.h" #include "hostname-util.h" #include "local-addresses.h" #include "macro.h" diff --git a/src/nss-mymachines/nss-mymachines.c b/src/nss-mymachines/nss-mymachines.c index b98bde676b..969fa9619e 100644 --- a/src/nss-mymachines/nss-mymachines.c +++ b/src/nss-mymachines/nss-mymachines.c @@ -25,6 +25,7 @@ #include "sd-bus.h" #include "sd-login.h" +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-util.h" #include "hostname-util.h" diff --git a/src/path/path.c b/src/path/path.c index 97e8323de1..0ece72f6fe 100644 --- a/src/path/path.c +++ b/src/path/path.c @@ -26,6 +26,7 @@ #include "sd-path.h" +#include "alloc-util.h" #include "log.h" #include "macro.h" #include "string-util.h" diff --git a/src/random-seed/random-seed.c b/src/random-seed/random-seed.c index fbfd3a3eba..d857ade36a 100644 --- a/src/random-seed/random-seed.c +++ b/src/random-seed/random-seed.c @@ -25,6 +25,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "io-util.h" #include "log.h" diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c index 1007de3959..8e5cf0908c 100644 --- a/src/rc-local-generator/rc-local-generator.c +++ b/src/rc-local-generator/rc-local-generator.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "log.h" #include "mkdir.h" #include "string-util.h" diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c index 9b808ff110..57739d1f3e 100644 --- a/src/resolve-host/resolve-host.c +++ b/src/resolve-host/resolve-host.c @@ -25,6 +25,7 @@ #include "sd-bus.h" #include "af-list.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "in-addr-util.h" diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c index bf1b7c8ab4..f0a3b607d4 100644 --- a/src/resolve/resolved-bus.c +++ b/src/resolve/resolved-bus.c @@ -19,9 +19,9 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-util.h" - #include "dns-domain.h" #include "resolved-bus.h" #include "resolved-def.h" diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index 17eafec2fa..c9919ced67 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -19,10 +19,11 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "conf-parser.h" +#include "extract-word.h" #include "parse-util.h" #include "resolved-conf.h" -#include "extract-word.h" #include "string-util.h" int manager_parse_dns_server(Manager *m, DnsServerType type, const char *string) { @@ -35,7 +36,7 @@ int manager_parse_dns_server(Manager *m, DnsServerType type, const char *string) first = type == DNS_SERVER_FALLBACK ? m->fallback_dns_servers : m->dns_servers; for(;;) { - _cleanup_free_ char *word; + _cleanup_free_ char *word = NULL; union in_addr_union addr; bool found = false; DnsServer *s; @@ -44,7 +45,6 @@ int manager_parse_dns_server(Manager *m, DnsServerType type, const char *string) r = extract_first_word(&string, &word, NULL, 0); if (r < 0) return log_error_errno(r, "Failed to parse resolved dns server syntax \"%s\": %m", string); - if (r == 0) break; diff --git a/src/resolve/resolved-dns-answer.c b/src/resolve/resolved-dns-answer.c index e1a2865007..3cf9c68074 100644 --- a/src/resolve/resolved-dns-answer.c +++ b/src/resolve/resolved-dns-answer.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "dns-domain.h" #include "resolved-dns-answer.h" #include "string-util.h" diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c index ab13636bc1..04f64022e0 100644 --- a/src/resolve/resolved-dns-cache.c +++ b/src/resolve/resolved-dns-cache.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "resolved-dns-cache.h" #include "resolved-dns-packet.h" diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c index f7f936d343..f23b3cf893 100644 --- a/src/resolve/resolved-dns-packet.c +++ b/src/resolve/resolved-dns-packet.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "dns-domain.h" #include "resolved-dns-packet.h" #include "string-table.h" diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c index 4b1d18b2ef..f7cb84e2a6 100644 --- a/src/resolve/resolved-dns-query.c +++ b/src/resolve/resolved-dns-query.c @@ -19,10 +19,10 @@ along with systemd; If not, see . ***/ -#include "hostname-util.h" +#include "alloc-util.h" #include "dns-domain.h" +#include "hostname-util.h" #include "local-addresses.h" - #include "resolved-dns-query.h" /* How long to wait for the query in total */ diff --git a/src/resolve/resolved-dns-question.c b/src/resolve/resolved-dns-question.c index 1507f22da0..48951221dc 100644 --- a/src/resolve/resolved-dns-question.c +++ b/src/resolve/resolved-dns-question.c @@ -19,8 +19,9 @@ along with systemd; If not, see . ***/ -#include "resolved-dns-question.h" +#include "alloc-util.h" #include "dns-domain.h" +#include "resolved-dns-question.h" DnsQuestion *dns_question_new(unsigned n) { DnsQuestion *q; diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index 63edee1fd1..ba2ea686f3 100644 --- a/src/resolve/resolved-dns-rr.c +++ b/src/resolve/resolved-dns-rr.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "dns-domain.h" #include "dns-type.h" #include "hexdecoct.h" diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c index 7c63c63b63..b15370b017 100644 --- a/src/resolve/resolved-dns-scope.c +++ b/src/resolve/resolved-dns-scope.c @@ -22,6 +22,7 @@ #include #include "af-list.h" +#include "alloc-util.h" #include "dns-domain.h" #include "fd-util.h" #include "hostname-util.h" diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c index 8693911e65..e803f635ab 100644 --- a/src/resolve/resolved-dns-server.c +++ b/src/resolve/resolved-dns-server.c @@ -19,9 +19,9 @@ along with systemd; If not, see . ***/ -#include "siphash24.h" - +#include "alloc-util.h" #include "resolved-dns-server.h" +#include "siphash24.h" /* After how much time to repeat classic DNS requests */ #define DNS_TIMEOUT_MIN_USEC (500 * USEC_PER_MSEC) diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c index 1150c30677..1c501182fb 100644 --- a/src/resolve/resolved-dns-stream.c +++ b/src/resolve/resolved-dns-stream.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "fd-util.h" #include "io-util.h" #include "missing.h" diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c index c60197cf8d..6545f6cd8a 100644 --- a/src/resolve/resolved-dns-transaction.c +++ b/src/resolve/resolved-dns-transaction.c @@ -20,6 +20,7 @@ ***/ #include "af-list.h" +#include "alloc-util.h" #include "dns-domain.h" #include "fd-util.h" #include "random-util.h" diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c index 8a6086a4de..48dcf76daa 100644 --- a/src/resolve/resolved-dns-zone.c +++ b/src/resolve/resolved-dns-zone.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "dns-domain.h" #include "list.h" #include "resolved-dns-packet.h" diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c index 8c88e2dbf1..2892641075 100644 --- a/src/resolve/resolved-link.c +++ b/src/resolve/resolved-link.c @@ -23,6 +23,7 @@ #include "sd-network.h" +#include "alloc-util.h" #include "missing.h" #include "parse-util.h" #include "resolved-link.h" diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index b9c625b9cf..a588538b52 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -25,6 +25,7 @@ #include #include "af-list.h" +#include "alloc-util.h" #include "dns-domain.h" #include "fd-util.h" #include "fileio-label.h" diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c index 5ba1e3d4a8..bb00f99ecf 100644 --- a/src/rfkill/rfkill.c +++ b/src/rfkill/rfkill.c @@ -25,6 +25,7 @@ #include "libudev.h" #include "sd-daemon.h" +#include "alloc-util.h" #include "escape.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/run/run.c b/src/run/run.c index dbcb29546f..38a482bb11 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -25,6 +25,7 @@ #include "sd-bus.h" #include "sd-event.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" #include "calendarspec.h" diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c index e8931daee2..79f5a60579 100644 --- a/src/shared/acl-util.c +++ b/src/shared/acl-util.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "acl-util.h" #include "string-util.h" #include "strv.h" diff --git a/src/shared/acpi-fpdt.c b/src/shared/acpi-fpdt.c index b3d2f96885..8e36067f74 100644 --- a/src/shared/acpi-fpdt.c +++ b/src/shared/acpi-fpdt.c @@ -25,6 +25,7 @@ #include #include +#include "alloc-util.h" #include "acpi-fpdt.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/shared/apparmor-util.c b/src/shared/apparmor-util.c index 48d0f84995..f6ac43adfe 100644 --- a/src/shared/apparmor-util.c +++ b/src/shared/apparmor-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "apparmor-util.h" #include "fileio.h" #include "parse-util.h" diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c index b2dbf98b8e..c96dbf877a 100644 --- a/src/shared/ask-password-api.c +++ b/src/shared/ask-password-api.c @@ -32,6 +32,7 @@ #include #include +#include "alloc-util.h" #include "ask-password-api.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c index ff91c6bdc5..e605490c32 100644 --- a/src/shared/base-filesystem.c +++ b/src/shared/base-filesystem.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "base-filesystem.h" #include "fd-util.h" #include "log.h" diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index 8f6278191a..f4a918063d 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -25,6 +25,7 @@ #include "sd-daemon.h" #include "sd-event.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-internal.h" #include "bus-label.h" diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c index 9e70713ce8..129ffc7056 100644 --- a/src/shared/cgroup-show.c +++ b/src/shared/cgroup-show.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "cgroup-show.h" #include "cgroup-util.h" #include "fd-util.h" diff --git a/src/shared/condition.c b/src/shared/condition.c index 2929e3e821..a69719116c 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -27,6 +27,7 @@ #include "sd-id128.h" +#include "alloc-util.h" #include "apparmor-util.h" #include "architecture.h" #include "audit-util.h" diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index fa13eb8075..163a83518b 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -26,6 +26,7 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "conf-files.h" #include "conf-parser.h" #include "fd-util.h" diff --git a/src/shared/dev-setup.c b/src/shared/dev-setup.c index 0d321af967..ad3c17d5bd 100644 --- a/src/shared/dev-setup.c +++ b/src/shared/dev-setup.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "dev-setup.h" #include "label.h" #include "path-util.h" diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c index b6587306a5..7af15e0098 100644 --- a/src/shared/dns-domain.c +++ b/src/shared/dns-domain.c @@ -24,6 +24,7 @@ #include #endif +#include "alloc-util.h" #include "dns-domain.h" #include "hexdecoct.h" #include "parse-util.h" diff --git a/src/shared/dropin.c b/src/shared/dropin.c index 25400277ff..0d44401cc2 100644 --- a/src/shared/dropin.c +++ b/src/shared/dropin.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "conf-files.h" #include "dropin.h" #include "escape.h" diff --git a/src/shared/efivars.c b/src/shared/efivars.c index e7972d1574..86bb0b57c3 100644 --- a/src/shared/efivars.c +++ b/src/shared/efivars.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "dirent-util.h" #include "efivars.h" #include "fd-util.h" diff --git a/src/shared/firewall-util.c b/src/shared/firewall-util.c index effc6e8e70..e178287872 100644 --- a/src/shared/firewall-util.c +++ b/src/shared/firewall-util.c @@ -27,8 +27,9 @@ #include #include -#include "util.h" +#include "alloc-util.h" #include "firewall-util.h" +#include "util.h" DEFINE_TRIVIAL_CLEANUP_FUNC(struct xtc_handle*, iptc_free); diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c index 1ea11ea5a4..eb2845cddf 100644 --- a/src/shared/fstab-util.c +++ b/src/shared/fstab-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "device-nodes.h" #include "fstab-util.h" #include "mount-util.h" diff --git a/src/shared/generator.c b/src/shared/generator.c index 203e01318b..cb4ebc606e 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "dropin.h" #include "escape.h" #include "fd-util.h" diff --git a/src/shared/import-util.c b/src/shared/import-util.c index bf5395dee8..ddc8c00a2d 100644 --- a/src/shared/import-util.c +++ b/src/shared/import-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "btrfs-util.h" #include "import-util.h" #include "path-util.h" diff --git a/src/shared/install-printf.c b/src/shared/install-printf.c index 224874f65c..e1cb5d27ff 100644 --- a/src/shared/install-printf.c +++ b/src/shared/install-printf.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "formats-util.h" #include "install-printf.h" #include "specifier.h" diff --git a/src/shared/install.c b/src/shared/install.c index 1f63ae9ce0..c74efede76 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -25,6 +25,7 @@ #include #include +#include "alloc-util.h" #include "conf-files.h" #include "conf-parser.h" #include "dirent-util.h" diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 5b4a220e5f..0313b0946f 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -25,6 +25,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "formats-util.h" #include "hashmap.h" diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c index a4e77fb8d8..2c1da0a40d 100644 --- a/src/shared/machine-image.c +++ b/src/shared/machine-image.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "btrfs-util.h" #include "chattr-util.h" #include "copy.h" diff --git a/src/shared/machine-pool.c b/src/shared/machine-pool.c index 1c7e0ef2c1..60b1b3092d 100644 --- a/src/shared/machine-pool.c +++ b/src/shared/machine-pool.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "btrfs-util.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index 1e63c72047..d71f379e76 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "util.h" #include "strv.h" #include "path-util.h" diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c index e5e0f37adf..786752ea94 100644 --- a/src/shared/ptyfwd.c +++ b/src/shared/ptyfwd.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "ptyfwd.h" #include "util.h" diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 0e232e6aa6..bbbb3460d4 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "conf-parser.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/shared/specifier.c b/src/shared/specifier.c index 610aec0df5..c5c4a4d7d7 100644 --- a/src/shared/specifier.c +++ b/src/shared/specifier.c @@ -22,11 +22,12 @@ #include #include +#include "alloc-util.h" #include "hostname-util.h" #include "macro.h" +#include "specifier.h" #include "string-util.h" #include "util.h" -#include "specifier.h" /* * Generic infrastructure for replacing %x style specifiers in diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c index 1e6ac2f27d..13b32a0509 100644 --- a/src/shared/utmp-wtmp.c +++ b/src/shared/utmp-wtmp.c @@ -27,6 +27,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "hostname-util.h" #include "macro.h" diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c index e82fb06417..ba82adadb4 100644 --- a/src/socket-proxy/socket-proxyd.c +++ b/src/socket-proxy/socket-proxyd.c @@ -34,6 +34,7 @@ #include "sd-event.h" #include "sd-resolve.h" +#include "alloc-util.h" #include "fd-util.h" #include "log.h" #include "path-util.h" diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 2faa93ef88..f5efa1a064 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -37,6 +37,7 @@ #include "sd-daemon.h" #include "sd-login.h" +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-error.h" #include "bus-message.h" diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 5d2cbe1225..36d310b4c4 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -26,6 +26,7 @@ #include #include +#include "alloc-util.h" #include "conf-files.h" #include "copy.h" #include "fileio-label.h" diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index e4b02ca990..0a0b9269b3 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -25,6 +25,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "hashmap.h" #include "hexdecoct.h" diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c index 12f366a34c..70819b0371 100644 --- a/src/test/test-calendarspec.c +++ b/src/test/test-calendarspec.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "calendarspec.h" #include "string-util.h" #include "util.h" diff --git a/src/test/test-cap-list.c b/src/test/test-cap-list.c index f43f737951..4418bafda6 100644 --- a/src/test/test-cap-list.c +++ b/src/test/test-cap-list.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "cap-list.h" #include "capability-util.h" #include "fileio.h" diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index e4f6d5168d..a48b324e26 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "cgroup-util.h" #include "dirent-util.h" #include "fd-util.h" diff --git a/src/test/test-condition.c b/src/test/test-condition.c index 365f5794d4..f224c6cdd8 100644 --- a/src/test/test-condition.c +++ b/src/test/test-condition.c @@ -19,6 +19,7 @@ #include "sd-id128.h" +#include "alloc-util.h" #include "apparmor-util.h" #include "architecture.h" #include "audit-util.h" diff --git a/src/test/test-conf-files.c b/src/test/test-conf-files.c index f4b23355fc..a69698d4ea 100644 --- a/src/test/test-conf-files.c +++ b/src/test/test-conf-files.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "conf-files.h" #include "fs-util.h" #include "macro.h" diff --git a/src/test/test-copy.c b/src/test/test-copy.c index 4ccf729e80..ad57cb0202 100644 --- a/src/test/test-copy.c +++ b/src/test/test-copy.c @@ -19,6 +19,7 @@ #include +#include "alloc-util.h" #include "copy.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/test/test-date.c b/src/test/test-date.c index e1c6ecb2ef..c6d8bf82ea 100644 --- a/src/test/test-date.c +++ b/src/test/test-date.c @@ -21,8 +21,9 @@ #include -#include "util.h" +#include "alloc-util.h" #include "string-util.h" +#include "util.h" static void test_should_pass(const char *p) { usec_t t, q; diff --git a/src/test/test-device-nodes.c b/src/test/test-device-nodes.c index 1c745d6e5b..646b168cc0 100644 --- a/src/test/test-device-nodes.c +++ b/src/test/test-device-nodes.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "device-nodes.h" #include "string-util.h" #include "util.h" diff --git a/src/test/test-dns-domain.c b/src/test/test-dns-domain.c index 1a8541e1cc..d5778748a0 100644 --- a/src/test/test-dns-domain.c +++ b/src/test/test-dns-domain.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "dns-domain.h" #include "macro.h" #include "string-util.h" diff --git a/src/test/test-ellipsize.c b/src/test/test-ellipsize.c index 033d5af719..c597d5aecd 100644 --- a/src/test/test-ellipsize.c +++ b/src/test/test-ellipsize.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "def.h" #include "string-util.h" #include "terminal-util.h" diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index 1c1fed4660..e588681b86 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "ctype.h" #include "def.h" #include "env-util.h" diff --git a/src/test/test-fstab-util.c b/src/test/test-fstab-util.c index b02f3a6e7c..27816ac779 100644 --- a/src/test/test-fstab-util.c +++ b/src/test/test-fstab-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "fstab-util.h" #include "log.h" #include "string-util.h" diff --git a/src/test/test-hashmap-plain.c b/src/test/test-hashmap-plain.c index 2da6446961..6bf33306a9 100644 --- a/src/test/test-hashmap-plain.c +++ b/src/test/test-hashmap-plain.c @@ -17,6 +17,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "hashmap.h" #include "string-util.h" #include "strv.h" diff --git a/src/test/test-hostname-util.c b/src/test/test-hostname-util.c index ac8f4ecc68..590175433c 100644 --- a/src/test/test-hostname-util.c +++ b/src/test/test-hostname-util.c @@ -21,10 +21,11 @@ along with systemd; If not, see . ***/ -#include "util.h" +#include "alloc-util.h" #include "fileio.h" #include "hostname-util.h" #include "string-util.h" +#include "util.h" static void test_hostname_is_valid(void) { assert_se(hostname_is_valid("foobar", false)); diff --git a/src/test/test-id128.c b/src/test/test-id128.c index 2c8ba70ffb..32cf3f80ca 100644 --- a/src/test/test-id128.c +++ b/src/test/test-id128.c @@ -24,6 +24,7 @@ #include "sd-daemon.h" #include "sd-id128.h" +#include "alloc-util.h" #include "macro.h" #include "string-util.h" #include "util.h" diff --git a/src/test/test-json.c b/src/test/test-json.c index ba4d75c0c8..3995224eea 100644 --- a/src/test/test-json.c +++ b/src/test/test-json.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "json.h" #include "string-util.h" #include "util.h" diff --git a/src/test/test-namespace.c b/src/test/test-namespace.c index a060a7ba6f..5a12e959d4 100644 --- a/src/test/test-namespace.c +++ b/src/test/test-namespace.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "fd-util.h" #include "namespace.h" #include "process-util.h" diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index e2979a8710..3f0f0264ab 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "macro.h" #include "mount-util.h" diff --git a/src/test/test-path.c b/src/test/test-path.c index 405434c1ff..ff0f044958 100644 --- a/src/test/test-path.c +++ b/src/test/test-path.c @@ -20,6 +20,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fs-util.h" #include "macro.h" diff --git a/src/test/test-prioq.c b/src/test/test-prioq.c index 1e2e42cbca..07273ffe79 100644 --- a/src/test/test-prioq.c +++ b/src/test/test-prioq.c @@ -21,10 +21,11 @@ #include -#include "util.h" -#include "set.h" +#include "alloc-util.h" #include "prioq.h" +#include "set.h" #include "siphash24.h" +#include "util.h" #define SET_SIZE 1024*4 diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c index 16a7148b19..fa448348da 100644 --- a/src/test/test-process-util.c +++ b/src/test/test-process-util.c @@ -23,6 +23,7 @@ #include #include +#include "alloc-util.h" #include "log.h" #include "macro.h" #include "process-util.h" diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c index 4a2d952c86..b9699b2028 100644 --- a/src/test/test-socket-util.c +++ b/src/test/test-socket-util.c @@ -17,6 +17,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "async.h" #include "fd-util.h" #include "in-addr-util.h" diff --git a/src/test/test-strv.c b/src/test/test-strv.c index c676893719..c27f15283e 100644 --- a/src/test/test-strv.c +++ b/src/test/test-strv.c @@ -22,6 +22,7 @@ #include +#include "alloc-util.h" #include "specifier.h" #include "string-util.h" #include "strv.h" diff --git a/src/test/test-tmpfiles.c b/src/test/test-tmpfiles.c index 683fbe217c..a8bd722e44 100644 --- a/src/test/test-tmpfiles.c +++ b/src/test/test-tmpfiles.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "formats-util.h" diff --git a/src/test/test-uid-range.c b/src/test/test-uid-range.c index 9f69d71203..4dcf10e26d 100644 --- a/src/test/test-uid-range.c +++ b/src/test/test-uid-range.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "uid-range.h" #include "user-util.h" #include "util.h" diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c index 226453d06e..c58c48af3c 100644 --- a/src/test/test-unit-file.c +++ b/src/test/test-unit-file.c @@ -26,6 +26,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "hashmap.h" diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c index 5aff771af5..9db7853dd4 100644 --- a/src/test/test-unit-name.c +++ b/src/test/test-unit-name.c @@ -26,6 +26,7 @@ #include #include +#include "alloc-util.h" #include "hostname-util.h" #include "macro.h" #include "manager.h" diff --git a/src/test/test-user-util.c b/src/test/test-user-util.c index dfd2031998..09d37087e5 100644 --- a/src/test/test-user-util.c +++ b/src/test/test-user-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "macro.h" #include "string-util.h" #include "user-util.h" diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c index a8e15b7cf1..0af8349732 100644 --- a/src/test/test-utf8.c +++ b/src/test/test-utf8.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "utf8.h" #include "util.h" #include "string-util.h" diff --git a/src/test/test-util.c b/src/test/test-util.c index 647eff0496..ffde10c7e1 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -31,6 +31,7 @@ #include #include +#include "alloc-util.h" #include "conf-parser.h" #include "cpu-set-util.h" #include "def.h" diff --git a/src/test/test-xml.c b/src/test/test-xml.c index 93b0e7c3fb..548d75a3c3 100644 --- a/src/test/test-xml.c +++ b/src/test/test-xml.c @@ -21,6 +21,7 @@ #include +#include "alloc-util.h" #include "string-util.h" #include "util.h" #include "xml.h" diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 507a83b2a1..968ef8a788 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -27,6 +27,7 @@ #include "sd-event.h" #include "sd-messages.h" +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-error.h" #include "bus-util.h" diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c index ad6fd180e4..be651fc636 100644 --- a/src/timesync/timesyncd-conf.c +++ b/src/timesync/timesyncd-conf.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "string-util.h" #include "timesyncd-manager.h" #include "timesyncd-server.h" @@ -35,16 +36,16 @@ int manager_parse_server_string(Manager *m, ServerType type, const char *string) first = type == SERVER_FALLBACK ? m->fallback_servers : m->system_servers; for (;;) { - _cleanup_free_ char *word; + _cleanup_free_ char *word = NULL; bool found = false; ServerName *n; r = extract_first_word(&string, &word, NULL, 0); if (r < 0) return log_error_errno(r, "Failed to parse timesyncd server syntax \"%s\": %m", string); - if (r == 0) break; + /* Filter out duplicates */ LIST_FOREACH(names, n, first) if (streq_ptr(n->string, word)) { diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index 15ca006deb..b4995c3064 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -33,6 +33,7 @@ #include "sd-daemon.h" +#include "alloc-util.h" #include "fd-util.h" #include "fs-util.h" #include "list.h" diff --git a/src/timesync/timesyncd-server.c b/src/timesync/timesyncd-server.c index ec3fe1fc4e..f98e6b4cf0 100644 --- a/src/timesync/timesyncd-server.c +++ b/src/timesync/timesyncd-server.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "timesyncd-server.h" int server_address_new( diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 5196447963..3c0b9993e3 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -39,6 +39,7 @@ #include #include "acl-util.h" +#include "alloc-util.h" #include "btrfs-util.h" #include "capability-util.h" #include "chattr-util.h" diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index a6240ae89a..d2938f0872 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -32,6 +32,7 @@ #include #include +#include "alloc-util.h" #include "ask-password-api.h" #include "conf-parser.h" #include "def.h" diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c index b234792e23..b6c95cd452 100644 --- a/src/udev/collect/collect.c +++ b/src/udev/collect/collect.c @@ -24,6 +24,7 @@ #include #include +#include "alloc-util.h" #include "libudev-private.h" #include "macro.h" #include "string-util.h" diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index 972841b6d9..776674e994 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -24,6 +24,7 @@ #include "sd-netlink.h" +#include "alloc-util.h" #include "conf-files.h" #include "conf-parser.h" #include "ethtool-util.h" diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 0976525eb3..d0e47ec6d8 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -29,6 +29,7 @@ #include "sd-id128.h" +#include "alloc-util.h" #include "efivars.h" #include "fd-util.h" #include "gpt.h" diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c index 97a5a9c77f..f4a065a97d 100644 --- a/src/udev/udev-builtin-hwdb.c +++ b/src/udev/udev-builtin-hwdb.c @@ -24,6 +24,7 @@ #include "sd-hwdb.h" +#include "alloc-util.h" #include "hwdb-util.h" #include "string-util.h" #include "udev-util.h" diff --git a/src/udev/udev-builtin-net_setup_link.c b/src/udev/udev-builtin-net_setup_link.c index d4589470fb..f72894b5c5 100644 --- a/src/udev/udev-builtin-net_setup_link.c +++ b/src/udev/udev-builtin-net_setup_link.c @@ -19,9 +19,10 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "link-config.h" -#include "udev.h" #include "log.h" +#include "udev.h" static link_config_ctx *ctx = NULL; diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c index 2c40988c7a..1e190140b2 100644 --- a/src/udev/udev-builtin-path_id.c +++ b/src/udev/udev-builtin-path_id.c @@ -30,6 +30,7 @@ #include #include +#include "alloc-util.h" #include "string-util.h" #include "udev.h" diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index cb531bd168..587649eff0 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -29,6 +29,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "string-util.h" #include "udev.h" diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c index 937fc4ecd8..1e05be51a5 100644 --- a/src/udev/udev-ctrl.c +++ b/src/udev/udev-ctrl.c @@ -18,6 +18,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "formats-util.h" #include "socket-util.h" diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index bf122f85c7..6b4bd31281 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -30,6 +30,7 @@ #include #include +#include "alloc-util.h" #include "event-util.h" #include "fd-util.h" #include "formats-util.h" diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 7d5f473d45..c06ace09cf 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -29,6 +29,7 @@ #include #include +#include "alloc-util.h" #include "conf-files.h" #include "escape.h" #include "fd-util.h" diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 87468c43ae..031a099d77 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -22,6 +22,7 @@ #include #include +#include "alloc-util.h" #include "conf-files.h" #include "fileio.h" #include "fs-util.h" diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 60fc3179b0..2c152129cc 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -43,6 +43,7 @@ #include "sd-daemon.h" #include "sd-event.h" +#include "alloc-util.h" #include "cgroup-util.h" #include "cpu-set-util.h" #include "dev-setup.h" diff --git a/src/update-utmp/update-utmp.c b/src/update-utmp/update-utmp.c index bcabf65a36..d50063cbcd 100644 --- a/src/update-utmp/update-utmp.c +++ b/src/update-utmp/update-utmp.c @@ -29,15 +29,16 @@ #include "sd-bus.h" +#include "alloc-util.h" +#include "bus-error.h" +#include "bus-util.h" +#include "formats-util.h" #include "log.h" #include "macro.h" -#include "util.h" #include "special.h" -#include "utmp-wtmp.h" -#include "bus-util.h" -#include "bus-error.h" #include "unit-name.h" -#include "formats-util.h" +#include "util.h" +#include "utmp-wtmp.h" typedef struct Context { sd_bus *bus; diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c index 2da28f8be0..2298f1c2a9 100644 --- a/src/vconsole/vconsole-setup.c +++ b/src/vconsole/vconsole-setup.c @@ -31,6 +31,7 @@ #include #include +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "io-util.h" -- cgit v1.2.3-54-g00ecf