summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/basic/af-list.c6
-rw-r--r--src/basic/arphrd-list.c4
-rw-r--r--src/basic/async.c4
-rw-r--r--src/basic/calendarspec.c2
-rw-r--r--src/basic/cap-list.c2
-rw-r--r--src/basic/errno-list.c4
-rw-r--r--src/basic/exit-status.c4
-rw-r--r--src/basic/fd-util.h4
-rw-r--r--src/basic/fdset.c6
-rw-r--r--src/basic/fileio-label.c4
-rw-r--r--src/basic/hashmap.c2
-rw-r--r--src/basic/json.c2
-rw-r--r--src/basic/label.c2
-rw-r--r--src/basic/lockfile-util.c8
-rw-r--r--src/basic/login-util.c2
-rw-r--r--src/basic/mempool.c2
-rw-r--r--src/basic/mkdir-label.c2
-rw-r--r--src/basic/mkdir.c2
-rw-r--r--src/basic/selinux-util.c6
-rw-r--r--src/basic/sigbus.c2
-rw-r--r--src/basic/siphash24.c109
-rw-r--r--src/basic/siphash24.h16
-rw-r--r--src/basic/strv.c2
-rw-r--r--src/basic/strxcpyx.c1
-rw-r--r--src/basic/user-util.c2
-rw-r--r--src/basic/utf8.c4
-rw-r--r--src/basic/util.c12
-rw-r--r--src/boot/efi/boot.c6
-rw-r--r--src/boot/efi/console.c2
-rw-r--r--src/boot/efi/graphics.c2
-rw-r--r--src/boot/efi/linux.c2
-rw-r--r--src/boot/efi/pefile.c2
-rw-r--r--src/boot/efi/splash.c2
-rw-r--r--src/boot/efi/stub.c6
-rw-r--r--src/bootchart/svg.c14
-rw-r--r--src/bus-proxyd/bus-xml-policy.c14
-rw-r--r--src/bus-proxyd/stdio-bridge.c2
-rw-r--r--src/core/.gitignore1
-rw-r--r--src/core/audit-fd.c5
-rw-r--r--src/core/cgroup.c24
-rw-r--r--src/core/dbus-automount.c2
-rw-r--r--src/core/dbus-busname.c2
-rw-r--r--src/core/dbus-device.c4
-rw-r--r--src/core/dbus-kill.c5
-rw-r--r--src/core/dbus-mount.c2
-rw-r--r--src/core/dbus-path.c2
-rw-r--r--src/core/dbus-slice.c4
-rw-r--r--src/core/dbus-swap.c2
-rw-r--r--src/core/dbus-target.c2
-rw-r--r--src/core/hostname-setup.c2
-rw-r--r--src/core/ima-setup.c2
-rw-r--r--src/core/kmod-setup.c6
-rw-r--r--src/core/load-dropin.c6
-rw-r--r--src/core/load-fragment.c2
-rw-r--r--src/core/locale-setup.c2
-rw-r--r--src/core/macros.systemd.in12
-rw-r--r--src/core/main.c2
-rw-r--r--src/core/mount-setup.c4
-rw-r--r--src/core/selinux-access.c4
-rw-r--r--src/core/selinux-setup.c2
-rw-r--r--src/core/slice.c2
-rw-r--r--src/core/transaction.c2
-rw-r--r--src/core/triggers.systemd.in26
-rw-r--r--src/fsck/fsck.c8
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c4
-rw-r--r--src/hibernate-resume/hibernate-resume.c2
-rw-r--r--src/hostname/hostnamed.c2
-rw-r--r--src/import/aufs-util.c2
-rw-r--r--src/import/curl-util.c18
-rw-r--r--src/import/export-raw.c4
-rw-r--r--src/import/pull-common.c2
-rw-r--r--src/import/pull-tar.c2
-rw-r--r--src/initctl/initctl.c6
-rw-r--r--src/journal-remote/journal-upload-journal.c3
-rw-r--r--src/journal-remote/microhttpd-util.c2
-rw-r--r--src/journal/audit-type.c5
-rw-r--r--src/journal/coredump-vacuum.c15
-rw-r--r--src/journal/journal-authenticate.c2
-rw-r--r--src/journal/journal-qrcode.c7
-rw-r--r--src/journal/journal-verify.c4
-rw-r--r--src/journal/journalctl.c3
-rw-r--r--src/journal/journald-console.c2
-rw-r--r--src/journal/journald-rate-limit.c6
-rw-r--r--src/journal/journald-server.c10
-rw-r--r--src/journal/journald-wall.c2
-rw-r--r--src/journal/journald.c7
-rw-r--r--src/journal/lookup3.c4
-rw-r--r--src/journal/mmap-cache.c17
-rw-r--r--src/journal/test-catalog.c4
-rw-r--r--src/journal/test-journal-enum.c2
-rw-r--r--src/journal/test-journal-interleaving.c2
-rw-r--r--src/journal/test-journal-verify.c2
-rw-r--r--src/journal/test-journal.c6
-rw-r--r--src/libsystemd-network/dhcp-identifier.c8
-rw-r--r--src/libsystemd-network/dhcp-option.c4
-rw-r--r--src/libsystemd-network/dhcp-packet.c5
-rw-r--r--src/libsystemd-network/dhcp6-option.c2
-rw-r--r--src/libsystemd-network/lldp-port.c4
-rw-r--r--src/libsystemd-network/lldp-tlv.c2
-rw-r--r--src/libsystemd-network/network-internal.c4
-rw-r--r--src/libsystemd-network/sd-dhcp-server.c2
-rw-r--r--src/libsystemd-network/sd-ipv4ll.c9
-rw-r--r--src/libsystemd-network/test-acd.c8
-rw-r--r--src/libsystemd-network/test-dhcp-client.c2
-rw-r--r--src/libsystemd-network/test-dhcp-option.c4
-rw-r--r--src/libsystemd-network/test-dhcp-server.c4
-rw-r--r--src/libsystemd/sd-bus/bus-bloom.c6
-rw-r--r--src/libsystemd/sd-bus/bus-bloom.h1
-rw-r--r--src/libsystemd/sd-bus/bus-common-errors.c3
-rw-r--r--src/libsystemd/sd-bus/bus-container.c2
-rw-r--r--src/libsystemd/sd-bus/bus-control.c2
-rw-r--r--src/libsystemd/sd-bus/bus-error.c2
-rw-r--r--src/libsystemd/sd-bus/bus-gvariant.c2
-rw-r--r--src/libsystemd/sd-bus/bus-objects.c2
-rw-r--r--src/libsystemd/sd-bus/bus-slot.c2
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c8
-rw-r--r--src/libsystemd/sd-bus/test-bus-chat.c6
-rw-r--r--src/libsystemd/sd-bus/test-bus-creds.c1
-rw-r--r--src/libsystemd/sd-bus/test-bus-error.c3
-rw-r--r--src/libsystemd/sd-bus/test-bus-introspect.c2
-rw-r--r--src/libsystemd/sd-bus/test-bus-marshal.c4
-rw-r--r--src/libsystemd/sd-bus/test-bus-match.c7
-rw-r--r--src/libsystemd/sd-bus/test-bus-objects.c2
-rw-r--r--src/libsystemd/sd-bus/test-bus-signature.c6
-rw-r--r--src/libsystemd/sd-bus/test-bus-zero-copy.c2
-rw-r--r--src/libsystemd/sd-event/sd-event.c7
-rw-r--r--src/libsystemd/sd-id128/sd-id128.c2
-rw-r--r--src/libsystemd/sd-netlink/local-addresses.c4
-rw-r--r--src/libsystemd/sd-netlink/netlink-types.h2
-rw-r--r--src/libsystemd/sd-netlink/netlink-util.c2
-rw-r--r--src/libsystemd/sd-netlink/test-local-addresses.c2
-rw-r--r--src/libsystemd/sd-utf8/sd-utf8.c2
-rw-r--r--src/libudev/libudev-queue.c6
-rw-r--r--src/login/logind-core.c4
-rw-r--r--src/login/logind-session.c1
-rw-r--r--src/login/logind-utmp.c2
-rw-r--r--src/login/pam_systemd.c2
-rw-r--r--src/login/test-login-shared.c2
-rw-r--r--src/login/test-login-tables.c1
-rw-r--r--src/machine-id-setup/machine-id-setup-main.c2
-rw-r--r--src/machine/machine.c7
-rw-r--r--src/machine/machined-dbus.c2
-rw-r--r--src/machine/test-machine-tables.c1
-rw-r--r--src/network/networkctl.c1
-rw-r--r--src/network/networkd-fdb.c2
-rw-r--r--src/network/networkd-ipv4ll.c2
-rw-r--r--src/network/networkd-link-bus.c5
-rw-r--r--src/network/networkd-ndisc.c4
-rw-r--r--src/network/networkd-netdev-bond.c2
-rw-r--r--src/network/networkd-netdev-bridge.c2
-rw-r--r--src/network/networkd-netdev-tuntap.c2
-rw-r--r--src/network/networkd-netdev-veth.c1
-rw-r--r--src/network/networkd-netdev-vxlan.c5
-rw-r--r--src/network/networkd-netdev.c2
-rw-r--r--src/network/test-network-tables.c9
-rw-r--r--src/network/test-network.c4
-rw-r--r--src/nspawn/nspawn-network.c4
-rw-r--r--src/nspawn/nspawn.c6
-rw-r--r--src/quotacheck/quotacheck.c2
-rw-r--r--src/remount-fs/remount-fs.c70
-rw-r--r--src/resolve-host/resolve-host.c2
-rw-r--r--src/resolve/resolved-llmnr.c2
-rw-r--r--src/run/run.c2
-rw-r--r--src/shared/acl-util.c2
-rw-r--r--src/shared/acpi-fpdt.c2
-rw-r--r--src/shared/architecture.c2
-rw-r--r--src/shared/boot-timestamps.c2
-rw-r--r--src/shared/clean-ipc.c2
-rw-r--r--src/shared/efivars.c4
-rw-r--r--src/shared/firewall-util.c2
-rw-r--r--src/shared/path-lookup.c12
-rw-r--r--src/shared/ptyfwd.c2
-rw-r--r--src/shared/seccomp-util.c2
-rw-r--r--src/shared/spawn-ask-password-agent.c2
-rw-r--r--src/shared/spawn-polkit-agent.c6
-rw-r--r--src/shared/sysctl-util.c2
-rw-r--r--src/shared/watchdog.c6
-rw-r--r--src/test/test-architecture.c4
-rw-r--r--src/test/test-boot-timestamps.c6
-rw-r--r--src/test/test-cgroup-mask.c4
-rw-r--r--src/test/test-engine.c4
-rw-r--r--src/test/test-fileio.c2
-rw-r--r--src/test/test-firewall-util.c2
-rw-r--r--src/test/test-hashmap.c2
-rw-r--r--src/test/test-install.c2
-rw-r--r--src/test/test-job-type.c2
-rw-r--r--src/test/test-locale-util.c2
-rw-r--r--src/test/test-log.c2
-rw-r--r--src/test/test-loopback.c4
-rw-r--r--src/test/test-ns.c2
-rw-r--r--src/test/test-ratelimit.c2
-rw-r--r--src/test/test-sched-prio.c2
-rw-r--r--src/test/test-siphash24.c8
-rw-r--r--src/test/test-sleep.c2
-rw-r--r--src/test/test-tables.c5
-rw-r--r--src/test/test-terminal-util.c2
-rw-r--r--src/test/test-time.c2
-rw-r--r--src/test/test-unaligned.c2
-rw-r--r--src/test/test-utf8.c2
-rw-r--r--src/test/test-watchdog.c2
-rw-r--r--src/udev/mtd_probe/mtd_probe.c8
-rw-r--r--src/udev/mtd_probe/probe_smartmedia.c9
-rw-r--r--src/udev/udev-builtin-uaccess.c2
-rw-r--r--src/udev/udev-ctrl.c6
-rw-r--r--src/udev/udev-watch.c6
-rw-r--r--src/udev/udevadm-control.c6
-rw-r--r--src/udev/udevadm-monitor.c12
-rw-r--r--src/udev/udevadm-settle.c10
-rw-r--r--src/udev/udevd.c8
-rw-r--r--src/udev/v4l_id/v4l_id.c14
210 files changed, 537 insertions, 512 deletions
diff --git a/src/basic/af-list.c b/src/basic/af-list.c
index f396115a34..07dfff6ad4 100644
--- a/src/basic/af-list.c
+++ b/src/basic/af-list.c
@@ -19,16 +19,16 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <sys/socket.h>
#include <string.h>
+#include <sys/socket.h>
-#include "util.h"
#include "af-list.h"
+#include "util.h"
static const struct af_name* lookup_af(register const char *str, register unsigned int len);
-#include "af-to-name.h"
#include "af-from-name.h"
+#include "af-to-name.h"
const char *af_to_name(int id) {
diff --git a/src/basic/arphrd-list.c b/src/basic/arphrd-list.c
index 284043cd90..03d8ad7403 100644
--- a/src/basic/arphrd-list.c
+++ b/src/basic/arphrd-list.c
@@ -22,13 +22,13 @@
#include <net/if_arp.h>
#include <string.h>
-#include "util.h"
#include "arphrd-list.h"
+#include "util.h"
static const struct arphrd_name* lookup_arphrd(register const char *str, register unsigned int len);
-#include "arphrd-to-name.h"
#include "arphrd-from-name.h"
+#include "arphrd-to-name.h"
const char *arphrd_to_name(int id) {
diff --git a/src/basic/async.c b/src/basic/async.c
index c3135f0efe..cfc5d224e1 100644
--- a/src/basic/async.c
+++ b/src/basic/async.c
@@ -68,7 +68,7 @@ int asynchronous_sync(void) {
}
static void *close_thread(void *p) {
- assert_se(close_nointr(PTR_TO_INT(p)) != -EBADF);
+ assert_se(close_nointr(PTR_TO_FD(p)) != -EBADF);
return NULL;
}
@@ -84,7 +84,7 @@ int asynchronous_close(int fd) {
if (fd >= 0) {
PROTECT_ERRNO;
- r = asynchronous_job(close_thread, INT_TO_PTR(fd));
+ r = asynchronous_job(close_thread, FD_TO_PTR(fd));
if (r < 0)
assert_se(close_nointr(fd) != -EBADF);
}
diff --git a/src/basic/calendarspec.c b/src/basic/calendarspec.c
index 7151fc3d0c..157ae1fb74 100644
--- a/src/basic/calendarspec.c
+++ b/src/basic/calendarspec.c
@@ -23,9 +23,9 @@
#include <string.h>
#include "alloc-util.h"
-#include "string-util.h"
#include "calendarspec.h"
#include "fileio.h"
+#include "string-util.h"
#define BITS_WEEKDAYS 127
diff --git a/src/basic/cap-list.c b/src/basic/cap-list.c
index 4d391510bc..f0974900cd 100644
--- a/src/basic/cap-list.c
+++ b/src/basic/cap-list.c
@@ -28,8 +28,8 @@
static const struct capability_name* lookup_capability(register const char *str, register unsigned int len);
-#include "cap-to-name.h"
#include "cap-from-name.h"
+#include "cap-to-name.h"
const char *capability_to_name(int id) {
diff --git a/src/basic/errno-list.c b/src/basic/errno-list.c
index 34d1331486..22869e4136 100644
--- a/src/basic/errno-list.c
+++ b/src/basic/errno-list.c
@@ -21,14 +21,14 @@
#include <string.h>
-#include "util.h"
#include "errno-list.h"
+#include "util.h"
static const struct errno_name* lookup_errno(register const char *str,
register unsigned int len);
-#include "errno-to-name.h"
#include "errno-from-name.h"
+#include "errno-to-name.h"
const char *errno_to_name(int id) {
diff --git a/src/basic/exit-status.c b/src/basic/exit-status.c
index fcff753ada..4c83731540 100644
--- a/src/basic/exit-status.c
+++ b/src/basic/exit-status.c
@@ -19,12 +19,12 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdlib.h>
#include <signal.h>
+#include <stdlib.h>
#include "exit-status.h"
-#include "set.h"
#include "macro.h"
+#include "set.h"
const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h
index 1ca10f0383..0e9182d75b 100644
--- a/src/basic/fd-util.h
+++ b/src/basic/fd-util.h
@@ -28,6 +28,10 @@
#include "macro.h"
+/* Make sure we can distinguish fd 0 and NULL */
+#define FD_TO_PTR(fd) INT_TO_PTR((fd)+1)
+#define PTR_TO_FD(p) (PTR_TO_INT(p)-1)
+
int close_nointr(int fd);
int safe_close(int fd);
void safe_close_pair(int p[]);
diff --git a/src/basic/fdset.c b/src/basic/fdset.c
index 42b0b2b98f..e5452f3bb0 100644
--- a/src/basic/fdset.c
+++ b/src/basic/fdset.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <errno.h>
#include <dirent.h>
+#include <errno.h>
#include <fcntl.h>
#include "sd-daemon.h"
@@ -36,10 +36,6 @@
#define MAKE_SET(s) ((Set*) s)
#define MAKE_FDSET(s) ((FDSet*) s)
-/* Make sure we can distinguish fd 0 and NULL */
-#define FD_TO_PTR(fd) INT_TO_PTR((fd)+1)
-#define PTR_TO_FD(p) (PTR_TO_INT(p)-1)
-
FDSet *fdset_new(void) {
return MAKE_FDSET(set_new(NULL));
}
diff --git a/src/basic/fileio-label.c b/src/basic/fileio-label.c
index f596f1d11f..0405822ce0 100644
--- a/src/basic/fileio-label.c
+++ b/src/basic/fileio-label.c
@@ -20,9 +20,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "util.h"
-#include "selinux-util.h"
#include "fileio-label.h"
+#include "selinux-util.h"
+#include "util.h"
int write_string_file_atomic_label(const char *fn, const char *line) {
int r;
diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c
index d88ceb40aa..6e501ef6ff 100644
--- a/src/basic/hashmap.c
+++ b/src/basic/hashmap.c
@@ -380,7 +380,7 @@ static unsigned base_bucket_hash(HashmapBase *h, const void *p) {
h->hash_ops->hash(p, &state);
- siphash24_finalize(&hash, &state);
+ hash = siphash24_finalize(&state);
return (unsigned) (hash % n_buckets(h));
}
diff --git a/src/basic/json.c b/src/basic/json.c
index 716705e5ff..9d5dedb934 100644
--- a/src/basic/json.c
+++ b/src/basic/json.c
@@ -23,9 +23,9 @@
#include <sys/types.h>
#include "alloc-util.h"
+#include "hexdecoct.h"
#include "json.h"
#include "macro.h"
-#include "hexdecoct.h"
#include "string-util.h"
#include "utf8.h"
diff --git a/src/basic/label.c b/src/basic/label.c
index 82f10b21bd..f33502f90f 100644
--- a/src/basic/label.c
+++ b/src/basic/label.c
@@ -19,10 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "label.h"
#include "selinux-util.h"
#include "smack-util.h"
#include "util.h"
-#include "label.h"
int label_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
int r, q;
diff --git a/src/basic/lockfile-util.c b/src/basic/lockfile-util.c
index 87c3aef7af..0bdbae480b 100644
--- a/src/basic/lockfile-util.c
+++ b/src/basic/lockfile-util.c
@@ -19,12 +19,12 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdlib.h>
-#include <stdbool.h>
#include <errno.h>
-#include <string.h>
-#include <stdio.h>
#include <limits.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/file.h>
#include "alloc-util.h"
diff --git a/src/basic/login-util.c b/src/basic/login-util.c
index 832f477bd2..41cef14e73 100644
--- a/src/basic/login-util.c
+++ b/src/basic/login-util.c
@@ -20,8 +20,8 @@
***/
#include "def.h"
-#include "string-util.h"
#include "login-util.h"
+#include "string-util.h"
bool session_id_valid(const char *id) {
diff --git a/src/basic/mempool.c b/src/basic/mempool.c
index d5d98d8829..9ee6e6a76d 100644
--- a/src/basic/mempool.c
+++ b/src/basic/mempool.c
@@ -20,8 +20,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "mempool.h"
#include "macro.h"
+#include "mempool.h"
#include "util.h"
struct pool {
diff --git a/src/basic/mkdir-label.c b/src/basic/mkdir-label.c
index 76bbc1edda..c241ef6064 100644
--- a/src/basic/mkdir-label.c
+++ b/src/basic/mkdir-label.c
@@ -20,8 +20,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
#include <stdio.h>
+#include <unistd.h>
#include "label.h"
#include "mkdir.h"
diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c
index 0214c4627e..5d7fb9a12d 100644
--- a/src/basic/mkdir.c
+++ b/src/basic/mkdir.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <string.h>
#include <errno.h>
+#include <string.h>
#include "fs-util.h"
#include "mkdir.h"
diff --git a/src/basic/selinux-util.c b/src/basic/selinux-util.c
index a821a3d5bb..e8ce5cfd96 100644
--- a/src/basic/selinux-util.c
+++ b/src/basic/selinux-util.c
@@ -24,15 +24,15 @@
#include <sys/un.h>
#ifdef HAVE_SELINUX
-#include <selinux/selinux.h>
-#include <selinux/label.h>
#include <selinux/context.h>
+#include <selinux/label.h>
+#include <selinux/selinux.h>
#endif
#include "alloc-util.h"
-#include "strv.h"
#include "path-util.h"
#include "selinux-util.h"
+#include "strv.h"
#ifdef HAVE_SELINUX
DEFINE_TRIVIAL_CLEANUP_FUNC(security_context_t, freecon);
diff --git a/src/basic/sigbus.c b/src/basic/sigbus.c
index 0108603fe8..c535c89d52 100644
--- a/src/basic/sigbus.c
+++ b/src/basic/sigbus.c
@@ -23,8 +23,8 @@
#include <sys/mman.h>
#include "macro.h"
-#include "util.h"
#include "sigbus.h"
+#include "util.h"
#define SIGBUS_QUEUE_MAX 64
diff --git a/src/basic/siphash24.c b/src/basic/siphash24.c
index d7640d395d..10fc56da69 100644
--- a/src/basic/siphash24.c
+++ b/src/basic/siphash24.c
@@ -17,9 +17,8 @@
coding style)
*/
-#include "sparse-endian.h"
-
#include "siphash24.h"
+#include "sparse-endian.h"
#include "unaligned.h"
#include "util.h"
@@ -54,37 +53,40 @@ void siphash24_init(struct siphash *state, const uint8_t k[16]) {
assert(state);
assert(k);
- k0 = le64toh(*(le64_t*) k);
- k1 = le64toh(*(le64_t*) (k + 8));
-
- /* "somepseudorandomlygeneratedbytes" */
- state->v0 = 0x736f6d6570736575ULL ^ k0;
- state->v1 = 0x646f72616e646f6dULL ^ k1;
- state->v2 = 0x6c7967656e657261ULL ^ k0;
- state->v3 = 0x7465646279746573ULL ^ k1;
- state->padding = 0;
- state->inlen = 0;
+ k0 = unaligned_read_le64(k);
+ k1 = unaligned_read_le64(k + 8);
+
+ *state = (struct siphash) {
+ /* "somepseudorandomlygeneratedbytes" */
+ .v0 = 0x736f6d6570736575ULL ^ k0,
+ .v1 = 0x646f72616e646f6dULL ^ k1,
+ .v2 = 0x6c7967656e657261ULL ^ k0,
+ .v3 = 0x7465646279746573ULL ^ k1,
+ .padding = 0,
+ .inlen = 0,
+ };
}
void siphash24_compress(const void *_in, size_t inlen, struct siphash *state) {
- uint64_t m;
+
const uint8_t *in = _in;
const uint8_t *end = in + inlen;
- unsigned left = state->inlen & 7;
+ size_t left = state->inlen & 7;
+ uint64_t m;
assert(in);
assert(state);
- /* update total length */
+ /* Update total length */
state->inlen += inlen;
- /* if padding exists, fill it out */
+ /* If padding exists, fill it out */
if (left > 0) {
- for ( ; in < end && left < 8; in ++, left ++ )
- state->padding |= ( ( uint64_t )*in ) << (left * 8);
+ for ( ; in < end && left < 8; in ++, left ++)
+ state->padding |= ((uint64_t) *in) << (left * 8);
if (in == end && left < 8)
- /* we did not have enough input to fill out the padding completely */
+ /* We did not have enough input to fill out the padding completely */
return;
#ifdef DEBUG
@@ -94,6 +96,7 @@ void siphash24_compress(const void *_in, size_t inlen, struct siphash *state) {
printf("(%3zu) v3 %08x %08x\n", state->inlen, (uint32_t) (state->v3 >> 32), (uint32_t) state->v3);
printf("(%3zu) compress padding %08x %08x\n", state->inlen, (uint32_t) (state->padding >> 32), (uint32_t)state->padding);
#endif
+
state->v3 ^= state->padding;
sipround(state);
sipround(state);
@@ -102,9 +105,9 @@ void siphash24_compress(const void *_in, size_t inlen, struct siphash *state) {
state->padding = 0;
}
- end -= ( state->inlen % sizeof (uint64_t) );
+ end -= (state->inlen % sizeof(uint64_t));
- for ( ; in < end; in += 8 ) {
+ for ( ; in < end; in += 8) {
m = unaligned_read_le64(in);
#ifdef DEBUG
printf("(%3zu) v0 %08x %08x\n", state->inlen, (uint32_t) (state->v0 >> 32), (uint32_t) state->v0);
@@ -120,38 +123,41 @@ void siphash24_compress(const void *_in, size_t inlen, struct siphash *state) {
}
left = state->inlen & 7;
-
- switch(left)
- {
- case 7: state->padding |= ((uint64_t) in[6]) << 48;
-
- case 6: state->padding |= ((uint64_t) in[5]) << 40;
-
- case 5: state->padding |= ((uint64_t) in[4]) << 32;
-
- case 4: state->padding |= ((uint64_t) in[3]) << 24;
-
- case 3: state->padding |= ((uint64_t) in[2]) << 16;
-
- case 2: state->padding |= ((uint64_t) in[1]) << 8;
-
- case 1: state->padding |= ((uint64_t) in[0]); break;
-
- case 0: break;
+ switch (left) {
+ case 7:
+ state->padding |= ((uint64_t) in[6]) << 48;
+ case 6:
+ state->padding |= ((uint64_t) in[5]) << 40;
+ case 5:
+ state->padding |= ((uint64_t) in[4]) << 32;
+ case 4:
+ state->padding |= ((uint64_t) in[3]) << 24;
+ case 3:
+ state->padding |= ((uint64_t) in[2]) << 16;
+ case 2:
+ state->padding |= ((uint64_t) in[1]) << 8;
+ case 1:
+ state->padding |= ((uint64_t) in[0]);
+ case 0:
+ break;
}
}
-void siphash24_finalize(uint64_t *out, struct siphash *state) {
+uint64_t siphash24_finalize(struct siphash *state) {
uint64_t b;
- b = state->padding | (( ( uint64_t )state->inlen ) << 56);
+ assert(state);
+
+ b = state->padding | (((uint64_t) state->inlen) << 56);
+
#ifdef DEBUG
- printf("(%3zu) v0 %08x %08x\n", state->inlen, (uint32_t) (state->v0 >> 32), (uint32_t)state->v0);
- printf("(%3zu) v1 %08x %08x\n", state->inlen, (uint32_t) (state->v1 >> 32), (uint32_t)state->v1);
- printf("(%3zu) v2 %08x %08x\n", state->inlen, (uint32_t) (state->v2 >> 32), (uint32_t)state->v2);
- printf("(%3zu) v3 %08x %08x\n", state->inlen, (uint32_t) (state->v3 >> 32), (uint32_t)state->v3);
+ printf("(%3zu) v0 %08x %08x\n", state->inlen, (uint32_t) (state->v0 >> 32), (uint32_t) state->v0);
+ printf("(%3zu) v1 %08x %08x\n", state->inlen, (uint32_t) (state->v1 >> 32), (uint32_t) state->v1);
+ printf("(%3zu) v2 %08x %08x\n", state->inlen, (uint32_t) (state->v2 >> 32), (uint32_t) state->v2);
+ printf("(%3zu) v3 %08x %08x\n", state->inlen, (uint32_t) (state->v3 >> 32), (uint32_t) state->v3);
printf("(%3zu) padding %08x %08x\n", state->inlen, (uint32_t) (state->padding >> 32), (uint32_t) state->padding);
#endif
+
state->v3 ^= b;
sipround(state);
sipround(state);
@@ -170,14 +176,17 @@ void siphash24_finalize(uint64_t *out, struct siphash *state) {
sipround(state);
sipround(state);
- *(le64_t*)out = htole64(state->v0 ^ state->v1 ^ state->v2 ^ state->v3);
+ return state->v0 ^ state->v1 ^ state->v2 ^ state->v3;
}
-/* SipHash-2-4 */
-void siphash24(uint64_t *out, const void *_in, size_t inlen, const uint8_t k[16]) {
+uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[16]) {
struct siphash state;
+ assert(in);
+ assert(k);
+
siphash24_init(&state, k);
- siphash24_compress(_in, inlen, &state);
- siphash24_finalize(out, &state);
+ siphash24_compress(in, inlen, &state);
+
+ return siphash24_finalize(&state);
}
diff --git a/src/basic/siphash24.h b/src/basic/siphash24.h
index dc08077d53..ba4f7d01b6 100644
--- a/src/basic/siphash24.h
+++ b/src/basic/siphash24.h
@@ -4,16 +4,16 @@
#include <sys/types.h>
struct siphash {
- uint64_t v0;
- uint64_t v1;
- uint64_t v2;
- uint64_t v3;
- uint64_t padding;
- size_t inlen;
+ uint64_t v0;
+ uint64_t v1;
+ uint64_t v2;
+ uint64_t v3;
+ uint64_t padding;
+ size_t inlen;
};
void siphash24_init(struct siphash *state, const uint8_t k[16]);
void siphash24_compress(const void *in, size_t inlen, struct siphash *state);
-void siphash24_finalize(uint64_t *out, struct siphash *state);
+uint64_t siphash24_finalize(struct siphash *state);
-void siphash24(uint64_t *out, const void *in, size_t inlen, const uint8_t k[16]);
+uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[16]);
diff --git a/src/basic/strv.c b/src/basic/strv.c
index ba6df716a7..771781f9fc 100644
--- a/src/basic/strv.c
+++ b/src/basic/strv.c
@@ -27,8 +27,8 @@
#include "alloc-util.h"
#include "escape.h"
#include "string-util.h"
-#include "util.h"
#include "strv.h"
+#include "util.h"
char *strv_find(char **l, const char *name) {
char **i;
diff --git a/src/basic/strxcpyx.c b/src/basic/strxcpyx.c
index 6542c0abf5..088ba53c29 100644
--- a/src/basic/strxcpyx.c
+++ b/src/basic/strxcpyx.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
+
#include "strxcpyx.h"
size_t strpcpy(char **dest, size_t size, const char *src) {
diff --git a/src/basic/user-util.c b/src/basic/user-util.c
index d6c936db37..397880b0b1 100644
--- a/src/basic/user-util.c
+++ b/src/basic/user-util.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <pwd.h>
#include <grp.h>
+#include <pwd.h>
#include "alloc-util.h"
#include "fd-util.h"
diff --git a/src/basic/utf8.c b/src/basic/utf8.c
index 7600d99903..b4063a4cec 100644
--- a/src/basic/utf8.c
+++ b/src/basic/utf8.c
@@ -44,10 +44,10 @@
*/
#include <errno.h>
-#include <stdlib.h>
#include <inttypes.h>
-#include <string.h>
#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
#include "alloc-util.h"
#include "hexdecoct.h"
diff --git a/src/basic/util.c b/src/basic/util.c
index 08bdcd28f2..58617b354a 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -73,6 +73,7 @@
#include "build.h"
#include "def.h"
#include "device-nodes.h"
+#include "dirent-util.h"
#include "env-util.h"
#include "escape.h"
#include "exit-status.h"
@@ -81,19 +82,20 @@
#include "formats-util.h"
#include "gunicode.h"
#include "hashmap.h"
+#include "hexdecoct.h"
#include "hostname-util.h"
#include "ioprio.h"
#include "log.h"
#include "macro.h"
#include "missing.h"
#include "mkdir.h"
-#include "hexdecoct.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
#include "random-util.h"
#include "signal-util.h"
#include "sparse-endian.h"
+#include "stat-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
@@ -102,8 +104,6 @@
#include "utf8.h"
#include "util.h"
#include "virt.h"
-#include "dirent-util.h"
-#include "stat-util.h"
/* Put this test here for a lack of better place */
assert_cc(EAGAIN == EWOULDBLOCK);
@@ -206,7 +206,7 @@ static int do_execute(char **directories, usec_t timeout, char *argv[]) {
log_debug("Spawned %s as " PID_FMT ".", path, pid);
- r = hashmap_put(pids, UINT_TO_PTR(pid), path);
+ r = hashmap_put(pids, PID_TO_PTR(pid), path);
if (r < 0)
return log_oom();
path = NULL;
@@ -224,10 +224,10 @@ static int do_execute(char **directories, usec_t timeout, char *argv[]) {
_cleanup_free_ char *path = NULL;
pid_t pid;
- pid = PTR_TO_UINT(hashmap_first_key(pids));
+ pid = PTR_TO_PID(hashmap_first_key(pids));
assert(pid > 0);
- path = hashmap_remove(pids, UINT_TO_PTR(pid));
+ path = hashmap_remove(pids, PID_TO_PTR(pid));
assert(path);
wait_for_terminate_and_warn(path, pid, true);
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
index 38b79da886..6d35adc0e2 100644
--- a/src/boot/efi/boot.c
+++ b/src/boot/efi/boot.c
@@ -18,12 +18,12 @@
#include <efi.h>
#include <efilib.h>
-#include "util.h"
#include "console.h"
-#include "graphics.h"
-#include "pefile.h"
#include "disk.h"
+#include "graphics.h"
#include "linux.h"
+#include "pefile.h"
+#include "util.h"
#ifndef EFI_OS_INDICATIONS_BOOT_TO_FW_UI
#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001ULL
diff --git a/src/boot/efi/console.c b/src/boot/efi/console.c
index 66aa88f32e..2151d34432 100644
--- a/src/boot/efi/console.c
+++ b/src/boot/efi/console.c
@@ -18,8 +18,8 @@
#include <efi.h>
#include <efilib.h>
-#include "util.h"
#include "console.h"
+#include "util.h"
#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
{ 0xdd9e7534, 0x7762, 0x4698, { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } }
diff --git a/src/boot/efi/graphics.c b/src/boot/efi/graphics.c
index f732428216..efa91fa7ac 100644
--- a/src/boot/efi/graphics.c
+++ b/src/boot/efi/graphics.c
@@ -20,8 +20,8 @@
#include <efi.h>
#include <efilib.h>
-#include "util.h"
#include "graphics.h"
+#include "util.h"
EFI_STATUS graphics_mode(BOOLEAN on) {
#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \
diff --git a/src/boot/efi/linux.c b/src/boot/efi/linux.c
index 809c69310e..e9d097c132 100644
--- a/src/boot/efi/linux.c
+++ b/src/boot/efi/linux.c
@@ -17,8 +17,8 @@
#include <efi.h>
#include <efilib.h>
-#include "util.h"
#include "linux.h"
+#include "util.h"
#define SETUP_MAGIC 0x53726448 /* "HdrS" */
struct SetupHeader {
diff --git a/src/boot/efi/pefile.c b/src/boot/efi/pefile.c
index e6fedbc929..efb3271ee3 100644
--- a/src/boot/efi/pefile.c
+++ b/src/boot/efi/pefile.c
@@ -17,8 +17,8 @@
#include <efi.h>
#include <efilib.h>
-#include "util.h"
#include "pefile.h"
+#include "util.h"
struct DosFileHeader {
UINT8 Magic[2];
diff --git a/src/boot/efi/splash.c b/src/boot/efi/splash.c
index 470ea3e2cc..b584b5e6a9 100644
--- a/src/boot/efi/splash.c
+++ b/src/boot/efi/splash.c
@@ -18,9 +18,9 @@
#include <efi.h>
#include <efilib.h>
-#include "util.h"
#include "graphics.h"
#include "splash.h"
+#include "util.h"
struct bmp_file {
CHAR8 signature[2];
diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
index 0c5ee4e9ff..2cd5c33cb6 100644
--- a/src/boot/efi/stub.c
+++ b/src/boot/efi/stub.c
@@ -16,12 +16,12 @@
#include <efi.h>
#include <efilib.h>
-#include "util.h"
-#include "pefile.h"
#include "disk.h"
#include "graphics.h"
-#include "splash.h"
#include "linux.h"
+#include "pefile.h"
+#include "splash.h"
+#include "util.h"
/* magic string to find in the binary image */
static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-stub " VERSION " ####";
diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index 05330c0577..2bf473ffc1 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -22,25 +22,25 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <fcntl.h>
+#include <limits.h>
#include <stdio.h>
#include <string.h>
+#include <sys/utsname.h>
#include <time.h>
-#include <limits.h>
#include <unistd.h>
-#include <sys/utsname.h>
-#include <fcntl.h>
#include "alloc-util.h"
#include "architecture.h"
-#include "util.h"
+#include "bootchart.h"
+#include "fd-util.h"
#include "fileio.h"
+#include "list.h"
#include "macro.h"
#include "store.h"
#include "svg.h"
-#include "bootchart.h"
-#include "list.h"
#include "utf8.h"
-#include "fd-util.h"
+#include "util.h"
#define time_to_graph(t) ((t) * arg_scale_x)
#define ps_to_graph(n) ((n) * arg_scale_y)
diff --git a/src/bus-proxyd/bus-xml-policy.c b/src/bus-proxyd/bus-xml-policy.c
index f0834e9525..debd58ce8b 100644
--- a/src/bus-proxyd/bus-xml-policy.c
+++ b/src/bus-proxyd/bus-xml-policy.c
@@ -392,11 +392,11 @@ static int file_load(Policy *p, const char *path) {
} else {
PolicyItem *first;
- first = hashmap_get(p->user_items, UINT32_TO_PTR(i->uid));
+ first = hashmap_get(p->user_items, UID_TO_PTR(i->uid));
item_append(i, &first);
i->uid_valid = true;
- r = hashmap_replace(p->user_items, UINT32_TO_PTR(i->uid), first);
+ r = hashmap_replace(p->user_items, UID_TO_PTR(i->uid), first);
if (r < 0) {
LIST_REMOVE(items, first, i);
return log_oom();
@@ -424,11 +424,11 @@ static int file_load(Policy *p, const char *path) {
} else {
PolicyItem *first;
- first = hashmap_get(p->group_items, UINT32_TO_PTR(i->gid));
+ first = hashmap_get(p->group_items, GID_TO_PTR(i->gid));
item_append(i, &first);
i->gid_valid = true;
- r = hashmap_replace(p->group_items, UINT32_TO_PTR(i->gid), first);
+ r = hashmap_replace(p->group_items, GID_TO_PTR(i->gid), first);
if (r < 0) {
LIST_REMOVE(items, first, i);
return log_oom();
@@ -787,7 +787,7 @@ static int policy_check(Policy *p, const struct policy_check_filter *filter) {
verdict = check_policy_items(p->default_items, filter);
if (filter->gid != GID_INVALID) {
- items = hashmap_get(p->group_items, UINT32_TO_PTR(filter->gid));
+ items = hashmap_get(p->group_items, GID_TO_PTR(filter->gid));
if (items) {
v = check_policy_items(items, filter);
if (v != DUNNO)
@@ -796,7 +796,7 @@ static int policy_check(Policy *p, const struct policy_check_filter *filter) {
}
if (filter->uid != UID_INVALID) {
- items = hashmap_get(p->user_items, UINT32_TO_PTR(filter->uid));
+ items = hashmap_get(p->user_items, UID_TO_PTR(filter->uid));
if (items) {
v = check_policy_items(items, filter);
if (v != DUNNO)
@@ -1155,7 +1155,7 @@ static void dump_hashmap_items(Hashmap *h) {
void *k;
HASHMAP_FOREACH_KEY(i, k, h, j) {
- printf("\t%s Item for %u:\n", draw_special_char(DRAW_ARROW), PTR_TO_UINT(k));
+ printf("\t%s Item for " UID_FMT ":\n", draw_special_char(DRAW_ARROW), PTR_TO_UID(k));
dump_items(i, "\t\t");
}
}
diff --git a/src/bus-proxyd/stdio-bridge.c b/src/bus-proxyd/stdio-bridge.c
index 6e47884209..2dc5fe631b 100644
--- a/src/bus-proxyd/stdio-bridge.c
+++ b/src/bus-proxyd/stdio-bridge.c
@@ -27,8 +27,8 @@
#include <string.h>
#include <unistd.h>
-#include "sd-daemon.h"
#include "sd-bus.h"
+#include "sd-daemon.h"
#include "alloc-util.h"
#include "bus-internal.h"
diff --git a/src/core/.gitignore b/src/core/.gitignore
index f293bbdc93..465b4fcc20 100644
--- a/src/core/.gitignore
+++ b/src/core/.gitignore
@@ -1,2 +1,3 @@
/macros.systemd
+/triggers.systemd
/systemd.pc
diff --git a/src/core/audit-fd.c b/src/core/audit-fd.c
index 3ae46d8cfb..0a484d89fc 100644
--- a/src/core/audit-fd.c
+++ b/src/core/audit-fd.c
@@ -21,16 +21,17 @@
#include <errno.h>
+
#include "audit-fd.h"
#ifdef HAVE_AUDIT
-#include <stdbool.h>
#include <libaudit.h>
+#include <stdbool.h>
+#include "fd-util.h"
#include "log.h"
#include "util.h"
-#include "fd-util.h"
static bool initialized = false;
static int audit_fd;
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index bed01fde21..d122175417 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -217,7 +217,7 @@ static int whitelist_device(const char *path, const char *node, const char *acc)
r = cg_set_attribute("devices", path, "devices.allow", buf);
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EINVAL) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EINVAL, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set devices.allow on %s: %m", path);
return r;
@@ -288,7 +288,7 @@ static int whitelist_major(const char *path, const char *name, char type, const
r = cg_set_attribute("devices", path, "devices.allow", buf);
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EINVAL) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EINVAL, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set devices.allow on %s: %m", path);
}
@@ -328,13 +328,13 @@ void cgroup_context_apply(CGroupContext *c, CGroupMask mask, const char *path, u
c->cpu_shares != CGROUP_CPU_SHARES_INVALID ? c->cpu_shares : CGROUP_CPU_SHARES_DEFAULT);
r = cg_set_attribute("cpu", path, "cpu.shares", buf);
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set cpu.shares on %s: %m", path);
sprintf(buf, USEC_FMT "\n", CGROUP_CPU_QUOTA_PERIOD_USEC);
r = cg_set_attribute("cpu", path, "cpu.cfs_period_us", buf);
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set cpu.cfs_period_us on %s: %m", path);
if (c->cpu_quota_per_sec_usec != USEC_INFINITY) {
@@ -343,7 +343,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupMask mask, const char *path, u
} else
r = cg_set_attribute("cpu", path, "cpu.cfs_quota_us", "-1");
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set cpu.cfs_quota_us on %s: %m", path);
}
@@ -359,7 +359,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupMask mask, const char *path, u
c->blockio_weight != CGROUP_BLKIO_WEIGHT_INVALID ? c->blockio_weight : CGROUP_BLKIO_WEIGHT_DEFAULT);
r = cg_set_attribute("blkio", path, "blkio.weight", buf);
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set blkio.weight on %s: %m", path);
/* FIXME: no way to reset this list */
@@ -373,7 +373,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupMask mask, const char *path, u
sprintf(buf, "%u:%u %" PRIu64 "\n", major(dev), minor(dev), w->weight);
r = cg_set_attribute("blkio", path, "blkio.weight_device", buf);
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set blkio.weight_device on %s: %m", path);
}
}
@@ -392,7 +392,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupMask mask, const char *path, u
sprintf(buf, "%u:%u %" PRIu64 "\n", major(dev), minor(dev), b->bandwidth);
r = cg_set_attribute("blkio", path, a, buf);
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set %s on %s: %m", a, path);
}
}
@@ -416,7 +416,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupMask mask, const char *path, u
}
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set memory.limit_in_bytes/memory.max on %s: %m", path);
}
@@ -432,7 +432,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupMask mask, const char *path, u
else
r = cg_set_attribute("devices", path, "devices.allow", "a");
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EINVAL) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EINVAL, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to reset devices.list on %s: %m", path);
if (c->device_policy == CGROUP_CLOSED ||
@@ -494,7 +494,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupMask mask, const char *path, u
r = cg_set_attribute("pids", path, "pids.max", "max");
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set pids.max on %s: %m", path);
}
@@ -505,7 +505,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupMask mask, const char *path, u
r = cg_set_attribute("net_cls", path, "net_cls.classid", buf);
if (r < 0)
- log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
+ log_full_errno(IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set net_cls.classid on %s: %m", path);
}
}
diff --git a/src/core/dbus-automount.c b/src/core/dbus-automount.c
index 45f2c2ffd6..54830a515b 100644
--- a/src/core/dbus-automount.c
+++ b/src/core/dbus-automount.c
@@ -21,8 +21,8 @@
#include "automount.h"
#include "bus-util.h"
-#include "string-util.h"
#include "dbus-automount.h"
+#include "string-util.h"
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, automount_result, AutomountResult);
diff --git a/src/core/dbus-busname.c b/src/core/dbus-busname.c
index 05ac89c3c0..445b237643 100644
--- a/src/core/dbus-busname.c
+++ b/src/core/dbus-busname.c
@@ -21,9 +21,9 @@
#include "bus-util.h"
#include "busname.h"
+#include "dbus-busname.h"
#include "string-util.h"
#include "unit.h"
-#include "dbus-busname.h"
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, busname_result, BusNameResult);
diff --git a/src/core/dbus-device.c b/src/core/dbus-device.c
index cb156fd37c..97e4a47556 100644
--- a/src/core/dbus-device.c
+++ b/src/core/dbus-device.c
@@ -19,9 +19,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "unit.h"
-#include "device.h"
#include "dbus-device.h"
+#include "device.h"
+#include "unit.h"
const sd_bus_vtable bus_device_vtable[] = {
SD_BUS_VTABLE_START(0),
diff --git a/src/core/dbus-kill.c b/src/core/dbus-kill.c
index 3b8116281c..c633eb1b76 100644
--- a/src/core/dbus-kill.c
+++ b/src/core/dbus-kill.c
@@ -19,11 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "signal-util.h"
#include "bus-util.h"
-
-#include "kill.h"
#include "dbus-kill.h"
+#include "kill.h"
+#include "signal-util.h"
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_kill_mode, kill_mode, KillMode);
diff --git a/src/core/dbus-mount.c b/src/core/dbus-mount.c
index 90a6d37073..bc5751a10d 100644
--- a/src/core/dbus-mount.c
+++ b/src/core/dbus-mount.c
@@ -23,10 +23,10 @@
#include "dbus-cgroup.h"
#include "dbus-execute.h"
#include "dbus-kill.h"
+#include "dbus-mount.h"
#include "mount.h"
#include "string-util.h"
#include "unit.h"
-#include "dbus-mount.h"
static int property_get_what(
sd_bus *bus,
diff --git a/src/core/dbus-path.c b/src/core/dbus-path.c
index 9e32b5fb06..e0544e9161 100644
--- a/src/core/dbus-path.c
+++ b/src/core/dbus-path.c
@@ -20,10 +20,10 @@
***/
#include "bus-util.h"
+#include "dbus-path.h"
#include "path.h"
#include "string-util.h"
#include "unit.h"
-#include "dbus-path.h"
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, path_result, PathResult);
diff --git a/src/core/dbus-slice.c b/src/core/dbus-slice.c
index 09e78d1f33..469e3e1c93 100644
--- a/src/core/dbus-slice.c
+++ b/src/core/dbus-slice.c
@@ -19,10 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "unit.h"
-#include "slice.h"
#include "dbus-cgroup.h"
#include "dbus-slice.h"
+#include "slice.h"
+#include "unit.h"
const sd_bus_vtable bus_slice_vtable[] = {
SD_BUS_VTABLE_START(0),
diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c
index 603ca95fd9..f2a0f1d172 100644
--- a/src/core/dbus-swap.c
+++ b/src/core/dbus-swap.c
@@ -23,10 +23,10 @@
#include "bus-util.h"
#include "dbus-cgroup.h"
#include "dbus-execute.h"
+#include "dbus-swap.h"
#include "string-util.h"
#include "swap.h"
#include "unit.h"
-#include "dbus-swap.h"
static int property_get_priority(
sd_bus *bus,
diff --git a/src/core/dbus-target.c b/src/core/dbus-target.c
index 350f5c3ed2..654bcf1a29 100644
--- a/src/core/dbus-target.c
+++ b/src/core/dbus-target.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "unit.h"
#include "dbus-target.h"
+#include "unit.h"
const sd_bus_vtable bus_target_vtable[] = {
SD_BUS_VTABLE_START(0),
diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c
index 3645f9c515..d92a9a764f 100644
--- a/src/core/hostname-setup.c
+++ b/src/core/hostname-setup.c
@@ -25,12 +25,12 @@
#include "alloc-util.h"
#include "fileio.h"
+#include "hostname-setup.h"
#include "hostname-util.h"
#include "log.h"
#include "macro.h"
#include "string-util.h"
#include "util.h"
-#include "hostname-setup.h"
int hostname_setup(void) {
int r;
diff --git a/src/core/ima-setup.c b/src/core/ima-setup.c
index 9572fa17d9..4f42ae6f31 100644
--- a/src/core/ima-setup.c
+++ b/src/core/ima-setup.c
@@ -21,8 +21,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
#include <errno.h>
+#include <unistd.h>
#include "fd-util.h"
#include "fileio.h"
diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c
index 651f79a1fe..a6ab8cf4b3 100644
--- a/src/core/kmod-setup.c
+++ b/src/core/kmod-setup.c
@@ -19,17 +19,17 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
#include <string.h>
+#include <unistd.h>
#ifdef HAVE_KMOD
#include <libkmod.h>
#endif
-#include "macro.h"
-#include "capability-util.h"
#include "bus-util.h"
+#include "capability-util.h"
#include "kmod-setup.h"
+#include "macro.h"
#ifdef HAVE_KMOD
static void systemd_kmod_log(
diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c
index 11566af51b..3fa66f91aa 100644
--- a/src/core/load-dropin.c
+++ b/src/core/load-dropin.c
@@ -20,13 +20,13 @@
***/
-#include "unit.h"
+#include "conf-parser.h"
#include "load-dropin.h"
+#include "load-fragment.h"
#include "log.h"
#include "strv.h"
#include "unit-name.h"
-#include "conf-parser.h"
-#include "load-fragment.h"
+#include "unit.h"
static int add_dependency_consumer(
UnitDependency dependency,
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 5d013de2e8..dda79267f7 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -32,8 +32,8 @@
#include <sys/resource.h>
#include <sys/stat.h>
-#include "alloc-util.h"
#include "af-list.h"
+#include "alloc-util.h"
#include "bus-error.h"
#include "bus-internal.h"
#include "bus-util.h"
diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c
index bd632131b9..4c8d920389 100644
--- a/src/core/locale-setup.c
+++ b/src/core/locale-setup.c
@@ -24,12 +24,12 @@
#include "env-util.h"
#include "fileio.h"
+#include "locale-setup.h"
#include "locale-util.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
#include "virt.h"
-#include "locale-setup.h"
int locale_setup(char ***environment) {
char **add;
diff --git a/src/core/macros.systemd.in b/src/core/macros.systemd.in
index bea6ef1da3..8a0e44b58c 100644
--- a/src/core/macros.systemd.in
+++ b/src/core/macros.systemd.in
@@ -1,4 +1,4 @@
-# -*- Mode: makefile; indent-tabs-mode: t -*- */
+# -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */
#
# This file is part of systemd.
#
@@ -39,7 +39,7 @@ Requires(postun): systemd \
%systemd_post() \
if [ $1 -eq 1 ] ; then \
# Initial installation \
- systemctl preset %{?*} >/dev/null 2>&1 || : \
+ systemctl --no-reload preset %{?*} >/dev/null 2>&1 || : \
fi \
%{nil}
@@ -48,8 +48,7 @@ fi \
%systemd_preun() \
if [ $1 -eq 0 ] ; then \
# Package removal, not upgrade \
- systemctl --no-reload disable %{?*} > /dev/null 2>&1 || : \
- systemctl stop %{?*} > /dev/null 2>&1 || : \
+ systemctl --no-reload disable --now %{?*} > /dev/null 2>&1 || : \
fi \
%{nil}
@@ -60,14 +59,11 @@ if [ $1 -eq 0 ] ; then \
fi \
%{nil}
-%systemd_postun() \
-systemctl daemon-reload >/dev/null 2>&1 || : \
-%{nil}
+%systemd_postun() %{nil}
%systemd_user_postun() %{nil}
%systemd_postun_with_restart() \
-systemctl daemon-reload >/dev/null 2>&1 || : \
if [ $1 -ge 1 ] ; then \
# Package upgrade, not uninstall \
systemctl try-restart %{?*} >/dev/null 2>&1 || : \
diff --git a/src/core/main.c b/src/core/main.c
index a09ce0f083..97f904b031 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -37,8 +37,8 @@
#include <valgrind/valgrind.h>
#endif
-#include "sd-daemon.h"
#include "sd-bus.h"
+#include "sd-daemon.h"
#include "alloc-util.h"
#include "architecture.h"
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index b2596d1cd1..2b8d590ed1 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -19,11 +19,11 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <sys/mount.h>
#include <errno.h>
+#include <ftw.h>
#include <stdlib.h>
+#include <sys/mount.h>
#include <unistd.h>
-#include <ftw.h>
#include "alloc-util.h"
#include "bus-util.h"
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
index 4bcdd27389..8856927c88 100644
--- a/src/core/selinux-access.c
+++ b/src/core/selinux-access.c
@@ -23,10 +23,10 @@
#ifdef HAVE_SELINUX
-#include <stdio.h>
#include <errno.h>
-#include <selinux/selinux.h>
#include <selinux/avc.h>
+#include <selinux/selinux.h>
+#include <stdio.h>
#ifdef HAVE_AUDIT
#include <libaudit.h>
#endif
diff --git a/src/core/selinux-setup.c b/src/core/selinux-setup.c
index d9b00fb95c..d4757e0853 100644
--- a/src/core/selinux-setup.c
+++ b/src/core/selinux-setup.c
@@ -29,10 +29,10 @@
#include "log.h"
#include "macro.h"
+#include "selinux-setup.h"
#include "selinux-util.h"
#include "string-util.h"
#include "util.h"
-#include "selinux-setup.h"
#ifdef HAVE_SELINUX
_printf_(2,3)
diff --git a/src/core/slice.c b/src/core/slice.c
index 9c488f0fd7..06ac6f8450 100644
--- a/src/core/slice.c
+++ b/src/core/slice.c
@@ -24,12 +24,12 @@
#include "alloc-util.h"
#include "dbus-slice.h"
#include "log.h"
+#include "slice.h"
#include "special.h"
#include "string-util.h"
#include "strv.h"
#include "unit-name.h"
#include "unit.h"
-#include "slice.h"
static const UnitActiveState state_translation_table[_SLICE_STATE_MAX] = {
[SLICE_DEAD] = UNIT_INACTIVE,
diff --git a/src/core/transaction.c b/src/core/transaction.c
index cf37b5eb75..15e79d00b3 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
#include <fcntl.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "bus-common-errors.h"
diff --git a/src/core/triggers.systemd.in b/src/core/triggers.systemd.in
new file mode 100644
index 0000000000..141f42dbcf
--- /dev/null
+++ b/src/core/triggers.systemd.in
@@ -0,0 +1,26 @@
+# -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */
+#
+# This file is part of systemd.
+#
+# Copyright 2015 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 <http://www.gnu.org/licenses/>.
+
+# The contents of this are an example to be copied into systemd.spec.
+
+%transfiletriggerin -- @systemunitdir@ /etc/systemd/system
+systemctl daemon-reload &>/dev/null || :
+
+%transfiletriggerun -- @systemunitdir@ /etc/systemd/system
+systemctl daemon-reload &>/dev/null || :
diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index 5b806a1e69..e0436d794c 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -20,14 +20,14 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdio.h>
-#include <stdbool.h>
#include <errno.h>
-#include <unistd.h>
#include <fcntl.h>
+#include <stdbool.h>
+#include <stdio.h>
#include <sys/file.h>
-#include <sys/stat.h>
#include <sys/prctl.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include "sd-bus.h"
#include "sd-device.h"
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index 34852ce381..ce8cecc5cb 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -19,10 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
+#include <blkid/blkid.h>
#include <stdlib.h>
#include <sys/statfs.h>
-#include <blkid/blkid.h>
+#include <unistd.h>
#include "libudev.h"
#include "sd-id128.h"
diff --git a/src/hibernate-resume/hibernate-resume.c b/src/hibernate-resume/hibernate-resume.c
index 316a2803d3..2e1259ef68 100644
--- a/src/hibernate-resume/hibernate-resume.c
+++ b/src/hibernate-resume/hibernate-resume.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdio.h>
#include <errno.h>
+#include <stdio.h>
#include <sys/stat.h>
#include "alloc-util.h"
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index 92061532b8..dde2baf661 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -21,8 +21,8 @@
#include <errno.h>
#include <string.h>
-#include <unistd.h>
#include <sys/utsname.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "bus-util.h"
diff --git a/src/import/aufs-util.c b/src/import/aufs-util.c
index 7b1ac134a0..82f519958c 100644
--- a/src/import/aufs-util.c
+++ b/src/import/aufs-util.c
@@ -21,10 +21,10 @@
#include <ftw.h>
+#include "aufs-util.h"
#include "rm-rf.h"
#include "string-util.h"
#include "util.h"
-#include "aufs-util.h"
static int nftw_cb(
const char *fpath,
diff --git a/src/import/curl-util.c b/src/import/curl-util.c
index 4278466df1..8e531a64fa 100644
--- a/src/import/curl-util.c
+++ b/src/import/curl-util.c
@@ -48,9 +48,7 @@ static int curl_glue_on_io(sd_event_source *s, int fd, uint32_t revents, void *u
assert(s);
assert(g);
- translated_fd = PTR_TO_INT(hashmap_get(g->translate_fds, INT_TO_PTR(fd+1)));
- assert(translated_fd > 0);
- translated_fd--;
+ translated_fd = PTR_TO_FD(hashmap_get(g->translate_fds, FD_TO_PTR(fd)));
if ((revents & (EPOLLIN|EPOLLOUT)) == (EPOLLIN|EPOLLOUT))
action = CURL_POLL_INOUT;
@@ -79,7 +77,7 @@ static int curl_glue_socket_callback(CURLM *curl, curl_socket_t s, int action, v
assert(curl);
assert(g);
- io = hashmap_get(g->ios, INT_TO_PTR(s+1));
+ io = hashmap_get(g->ios, FD_TO_PTR(s));
if (action == CURL_POLL_REMOVE) {
if (io) {
@@ -91,8 +89,8 @@ static int curl_glue_socket_callback(CURLM *curl, curl_socket_t s, int action, v
sd_event_source_set_enabled(io, SD_EVENT_OFF);
sd_event_source_unref(io);
- hashmap_remove(g->ios, INT_TO_PTR(s+1));
- hashmap_remove(g->translate_fds, INT_TO_PTR(fd+1));
+ hashmap_remove(g->ios, FD_TO_PTR(s));
+ hashmap_remove(g->translate_fds, FD_TO_PTR(fd));
safe_close(fd);
}
@@ -143,17 +141,17 @@ static int curl_glue_socket_callback(CURLM *curl, curl_socket_t s, int action, v
sd_event_source_set_description(io, "curl-io");
- r = hashmap_put(g->ios, INT_TO_PTR(s+1), io);
+ r = hashmap_put(g->ios, FD_TO_PTR(s), io);
if (r < 0) {
log_oom();
sd_event_source_unref(io);
return -1;
}
- r = hashmap_put(g->translate_fds, INT_TO_PTR(fd+1), INT_TO_PTR(s+1));
+ r = hashmap_put(g->translate_fds, FD_TO_PTR(fd), FD_TO_PTR(s));
if (r < 0) {
log_oom();
- hashmap_remove(g->ios, INT_TO_PTR(s+1));
+ hashmap_remove(g->ios, FD_TO_PTR(s));
sd_event_source_unref(io);
return -1;
}
@@ -229,7 +227,7 @@ CurlGlue *curl_glue_unref(CurlGlue *g) {
fd = sd_event_source_get_io_fd(io);
assert(fd >= 0);
- hashmap_remove(g->translate_fds, INT_TO_PTR(fd+1));
+ hashmap_remove(g->translate_fds, FD_TO_PTR(fd));
safe_close(fd);
sd_event_source_unref(io);
diff --git a/src/import/export-raw.c b/src/import/export-raw.c
index 103d45bf21..28c87594d6 100644
--- a/src/import/export-raw.c
+++ b/src/import/export-raw.c
@@ -20,6 +20,10 @@
***/
#include <sys/sendfile.h>
+
+/* When we include libgen.h because we need dirname() we immediately
+ * undefine basename() since libgen.h defines it as a macro to the POSIX
+ * version which is really broken. We prefer GNU basename(). */
#include <libgen.h>
#undef basename
diff --git a/src/import/pull-common.c b/src/import/pull-common.c
index 16b0c6160f..a83cffffa0 100644
--- a/src/import/pull-common.c
+++ b/src/import/pull-common.c
@@ -165,7 +165,7 @@ static int hash_url(const char *url, char **ret) {
assert(url);
- siphash24(&h, url, strlen(url), k.bytes);
+ h = siphash24(url, strlen(url), k.bytes);
if (asprintf(ret, "%"PRIx64, h) < 0)
return -ENOMEM;
diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c
index e7fcd293f1..2e48167c54 100644
--- a/src/import/pull-tar.c
+++ b/src/import/pull-tar.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <sys/prctl.h>
#include <curl/curl.h>
+#include <sys/prctl.h>
#include "sd-daemon.h"
diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
index d4f8673187..a35f2b541c 100644
--- a/src/initctl/initctl.c
+++ b/src/initctl/initctl.c
@@ -19,11 +19,11 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdio.h>
+#include <ctype.h>
#include <errno.h>
-#include <unistd.h>
+#include <stdio.h>
#include <sys/epoll.h>
-#include <ctype.h>
+#include <unistd.h>
#include "sd-bus.h"
#include "sd-daemon.h"
diff --git a/src/journal-remote/journal-upload-journal.c b/src/journal-remote/journal-upload-journal.c
index 3ee6d32bf7..a6d7c3b7e8 100644
--- a/src/journal-remote/journal-upload-journal.c
+++ b/src/journal-remote/journal-upload-journal.c
@@ -19,9 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdbool.h>
-
#include <curl/curl.h>
+#include <stdbool.h>
#include "alloc-util.h"
#include "journal-upload.h"
diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c
index b2c398a845..09e6da0031 100644
--- a/src/journal-remote/microhttpd-util.c
+++ b/src/journal-remote/microhttpd-util.c
@@ -32,10 +32,10 @@
#include "alloc-util.h"
#include "log.h"
#include "macro.h"
+#include "microhttpd-util.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
-#include "microhttpd-util.h"
void microhttpd_logger(void *arg, const char *fmt, va_list ap) {
char *f;
diff --git a/src/journal/audit-type.c b/src/journal/audit-type.c
index 4888c7d05d..086bf7e7e3 100644
--- a/src/journal/audit-type.c
+++ b/src/journal/audit-type.c
@@ -25,8 +25,7 @@
# include <libaudit.h>
#endif
-#include "audit-type.h"
-#include "macro.h"
#include "missing.h"
-
+#include "audit-type.h"
#include "audit_type-to-name.h"
+#include "macro.h"
diff --git a/src/journal/coredump-vacuum.c b/src/journal/coredump-vacuum.c
index 39bc2e4270..09ab60c6c4 100644
--- a/src/journal/coredump-vacuum.c
+++ b/src/journal/coredump-vacuum.c
@@ -157,8 +157,7 @@ int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
if (errno == ENOENT)
return 0;
- log_error_errno(errno, "Can't open coredump directory: %m");
- return -errno;
+ return log_error_errno(errno, "Can't open coredump directory: %m");
}
for (;;) {
@@ -183,7 +182,7 @@ int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
if (errno == ENOENT)
continue;
- log_warning("Failed to stat /var/lib/systemd/coredump/%s", de->d_name);
+ log_warning_errno(errno, "Failed to stat /var/lib/systemd/coredump/%s: %m", de->d_name);
continue;
}
@@ -201,7 +200,7 @@ int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
t = timespec_load(&st.st_mtim);
- c = hashmap_get(h, UINT32_TO_PTR(uid));
+ c = hashmap_get(h, UID_TO_PTR(uid));
if (c) {
if (t < c->oldest_mtime) {
@@ -229,7 +228,7 @@ int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
n->oldest_mtime = t;
- r = hashmap_put(h, UINT32_TO_PTR(uid), n);
+ r = hashmap_put(h, UID_TO_PTR(uid), n);
if (r < 0)
return log_oom();
@@ -259,8 +258,7 @@ int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
if (errno == ENOENT)
continue;
- log_error_errno(errno, "Failed to remove file %s: %m", worst->oldest_file);
- return -errno;
+ return log_error_errno(errno, "Failed to remove file %s: %m", worst->oldest_file);
} else
log_info("Removed old coredump %s.", worst->oldest_file);
}
@@ -268,6 +266,5 @@ int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
return 0;
fail:
- log_error_errno(errno, "Failed to read directory: %m");
- return -errno;
+ return log_error_errno(errno, "Failed to read directory: %m");
}
diff --git a/src/journal/journal-authenticate.c b/src/journal/journal-authenticate.c
index 0c4ac5cdc3..aeec83da1e 100644
--- a/src/journal/journal-authenticate.c
+++ b/src/journal/journal-authenticate.c
@@ -24,10 +24,10 @@
#include "fd-util.h"
#include "fsprg.h"
+#include "hexdecoct.h"
#include "journal-authenticate.h"
#include "journal-def.h"
#include "journal-file.h"
-#include "hexdecoct.h"
static uint64_t journal_file_tag_seqnum(JournalFile *f) {
uint64_t r;
diff --git a/src/journal/journal-qrcode.c b/src/journal/journal-qrcode.c
index 1db66e89c6..257ddb302b 100644
--- a/src/journal/journal-qrcode.c
+++ b/src/journal/journal-qrcode.c
@@ -20,12 +20,11 @@
***/
#include <assert.h>
-#include <stdio.h>
#include <errno.h>
-#include <stdlib.h>
-#include <stdbool.h>
-
#include <qrencode.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
#include "journal-qrcode.h"
diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
index 3676cb8788..715847e018 100644
--- a/src/journal/journal-verify.c
+++ b/src/journal/journal-verify.c
@@ -19,10 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
-#include <sys/mman.h>
#include <fcntl.h>
#include <stddef.h>
+#include <sys/mman.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "compress.h"
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 75a48c761c..d9a8063d31 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -2247,7 +2247,8 @@ int main(int argc, char *argv[]) {
if (arg_follow)
need_seek = true;
else {
- printf("-- No entries --\n");
+ if (!arg_quiet)
+ printf("-- No entries --\n");
goto finish;
}
}
diff --git a/src/journal/journald-console.c b/src/journal/journald-console.c
index 89f3d4b42f..04487c29b5 100644
--- a/src/journal/journald-console.c
+++ b/src/journal/journald-console.c
@@ -19,9 +19,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <time.h>
#include <fcntl.h>
#include <sys/socket.h>
+#include <time.h>
#include "alloc-util.h"
#include "fd-util.h"
diff --git a/src/journal/journald-rate-limit.c b/src/journal/journald-rate-limit.c
index ad78d09294..1c406aef8e 100644
--- a/src/journal/journald-rate-limit.c
+++ b/src/journal/journald-rate-limit.c
@@ -24,11 +24,11 @@
#include "alloc-util.h"
#include "hashmap.h"
+#include "journald-rate-limit.h"
#include "list.h"
#include "random-util.h"
#include "string-util.h"
#include "util.h"
-#include "journald-rate-limit.h"
#define POOLS_MAX 5
#define BUCKETS_MAX 127
@@ -162,7 +162,7 @@ static JournalRateLimitGroup* journal_rate_limit_group_new(JournalRateLimit *r,
siphash24_init(&state, r->hash_key);
string_hash_func(g->id, &state);
- siphash24_finalize(&g->hash, &state);
+ g->hash = siphash24_finalize(&state);
journal_rate_limit_vacuum(r, ts);
@@ -230,7 +230,7 @@ int journal_rate_limit_test(JournalRateLimit *r, const char *id, int priority, u
siphash24_init(&state, r->hash_key);
string_hash_func(id, &state);
- siphash24_finalize(&h, &state);
+ h = siphash24_finalize(&state);
g = r->buckets[h % BUCKETS_MAX];
LIST_FOREACH(bucket, g, g)
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index be913d26ef..7d11a568aa 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -69,6 +69,7 @@
#include "socket-util.h"
#include "string-table.h"
#include "string-util.h"
+#include "user-util.h"
#define USER_JOURNALS_MAX 1024
@@ -281,7 +282,7 @@ static JournalFile* find_journal(Server *s, uid_t uid) {
if (r < 0)
return s->system_journal;
- f = ordered_hashmap_get(s->user_journals, UINT32_TO_PTR(uid));
+ f = ordered_hashmap_get(s->user_journals, UID_TO_PTR(uid));
if (f)
return f;
@@ -302,7 +303,7 @@ static JournalFile* find_journal(Server *s, uid_t uid) {
server_fix_perms(s, f, uid);
- r = ordered_hashmap_put(s->user_journals, UINT32_TO_PTR(uid), f);
+ r = ordered_hashmap_put(s->user_journals, UID_TO_PTR(uid), f);
if (r < 0) {
journal_file_close(f);
return s->system_journal;
@@ -348,7 +349,7 @@ void server_rotate(Server *s) {
(void) do_rotate(s, &s->system_journal, "system", s->seal, 0);
ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
- r = do_rotate(s, &f, "user", s->seal, PTR_TO_UINT32(k));
+ r = do_rotate(s, &f, "user", s->seal, PTR_TO_UID(k));
if (r >= 0)
ordered_hashmap_replace(s->user_journals, k, f);
else if (!f)
@@ -359,7 +360,6 @@ void server_rotate(Server *s) {
void server_sync(Server *s) {
JournalFile *f;
- void *k;
Iterator i;
int r;
@@ -369,7 +369,7 @@ void server_sync(Server *s) {
log_warning_errno(r, "Failed to sync system journal, ignoring: %m");
}
- ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
+ ORDERED_HASHMAP_FOREACH(f, s->user_journals, i) {
r = journal_file_set_offline(f);
if (r < 0)
log_warning_errno(r, "Failed to sync user journal, ignoring: %m");
diff --git a/src/journal/journald-wall.c b/src/journal/journald-wall.c
index 69540f1141..88bea3b86e 100644
--- a/src/journal/journald-wall.c
+++ b/src/journal/journald-wall.c
@@ -22,10 +22,10 @@
#include "alloc-util.h"
#include "formats-util.h"
#include "journald-server.h"
+#include "journald-wall.h"
#include "process-util.h"
#include "string-util.h"
#include "utmp-wtmp.h"
-#include "journald-wall.h"
void server_forward_wall(
Server *s,
diff --git a/src/journal/journald.c b/src/journal/journald.c
index b137e3c7be..b9f5c099e1 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -21,16 +21,15 @@
#include <unistd.h>
-#include "sd-messages.h"
#include "sd-daemon.h"
+#include "sd-messages.h"
+#include "formats-util.h"
#include "journal-authenticate.h"
-#include "journald-server.h"
#include "journald-kmsg.h"
+#include "journald-server.h"
#include "journald-syslog.h"
-
#include "sigbus.h"
-#include "formats-util.h"
int main(int argc, char *argv[]) {
Server server;
diff --git a/src/journal/lookup3.c b/src/journal/lookup3.c
index 52ffdf7b1d..3d791234f4 100644
--- a/src/journal/lookup3.c
+++ b/src/journal/lookup3.c
@@ -40,10 +40,10 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
*/
/* #define SELF_TEST 1 */
-#include <stdio.h> /* defines printf for tests */
-#include <time.h> /* defines time_t for timings in the test */
#include <stdint.h> /* defines uint32_t etc */
+#include <stdio.h> /* defines printf for tests */
#include <sys/param.h> /* attempt to define endianness */
+#include <time.h> /* defines time_t for timings in the test */
#ifdef linux
# include <endian.h> /* attempt to define endianness */
#endif
diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
index 3cb1dfa986..5a07ddda76 100644
--- a/src/journal/mmap-cache.c
+++ b/src/journal/mmap-cache.c
@@ -24,13 +24,14 @@
#include <sys/mman.h>
#include "alloc-util.h"
+#include "fd-util.h"
#include "hashmap.h"
#include "list.h"
#include "log.h"
-#include "util.h"
#include "macro.h"
-#include "sigbus.h"
#include "mmap-cache.h"
+#include "sigbus.h"
+#include "util.h"
typedef struct Window Window;
typedef struct Context Context;
@@ -289,7 +290,7 @@ static void fd_free(FileDescriptor *f) {
window_free(f->windows);
if (f->cache)
- assert_se(hashmap_remove(f->cache->fds, INT_TO_PTR(f->fd + 1)));
+ assert_se(hashmap_remove(f->cache->fds, FD_TO_PTR(f->fd)));
free(f);
}
@@ -301,7 +302,7 @@ static FileDescriptor* fd_add(MMapCache *m, int fd) {
assert(m);
assert(fd >= 0);
- f = hashmap_get(m->fds, INT_TO_PTR(fd + 1));
+ f = hashmap_get(m->fds, FD_TO_PTR(fd));
if (f)
return f;
@@ -316,7 +317,7 @@ static FileDescriptor* fd_add(MMapCache *m, int fd) {
f->cache = m;
f->fd = fd;
- r = hashmap_put(m->fds, UINT_TO_PTR(fd + 1), f);
+ r = hashmap_put(m->fds, FD_TO_PTR(fd), f);
if (r < 0) {
free(f);
return NULL;
@@ -429,7 +430,7 @@ static int find_mmap(
assert(fd >= 0);
assert(size > 0);
- f = hashmap_get(m->fds, INT_TO_PTR(fd + 1));
+ f = hashmap_get(m->fds, FD_TO_PTR(fd));
if (!f)
return 0;
@@ -679,7 +680,7 @@ bool mmap_cache_got_sigbus(MMapCache *m, int fd) {
mmap_cache_process_sigbus(m);
- f = hashmap_get(m->fds, INT_TO_PTR(fd + 1));
+ f = hashmap_get(m->fds, FD_TO_PTR(fd));
if (!f)
return false;
@@ -698,7 +699,7 @@ void mmap_cache_close_fd(MMapCache *m, int fd) {
mmap_cache_process_sigbus(m);
- f = hashmap_get(m->fds, INT_TO_PTR(fd + 1));
+ f = hashmap_get(m->fds, FD_TO_PTR(fd));
if (!f)
return;
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c
index aea8fd15e6..25980b7744 100644
--- a/src/journal/test-catalog.c
+++ b/src/journal/test-catalog.c
@@ -20,10 +20,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <locale.h>
-#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
+#include <locale.h>
+#include <unistd.h>
#include "sd-messages.h"
diff --git a/src/journal/test-journal-enum.c b/src/journal/test-journal-enum.c
index 040c7d58fb..8f56ea1907 100644
--- a/src/journal/test-journal-enum.c
+++ b/src/journal/test-journal-enum.c
@@ -23,9 +23,9 @@
#include "sd-journal.h"
+#include "journal-internal.h"
#include "log.h"
#include "macro.h"
-#include "journal-internal.h"
int main(int argc, char *argv[]) {
unsigned n = 0;
diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c
index 4ad89fe4b6..5c055ef748 100644
--- a/src/journal/test-journal-interleaving.c
+++ b/src/journal/test-journal-interleaving.c
@@ -20,8 +20,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
#include <fcntl.h>
+#include <unistd.h>
#include "sd-journal.h"
diff --git a/src/journal/test-journal-verify.c b/src/journal/test-journal-verify.c
index 887a83efe1..a7abb11fba 100644
--- a/src/journal/test-journal-verify.c
+++ b/src/journal/test-journal-verify.c
@@ -19,9 +19,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
-#include <fcntl.h>
#include "fd-util.h"
#include "journal-file.h"
diff --git a/src/journal/test-journal.c b/src/journal/test-journal.c
index 01d4bc968a..266e0d5473 100644
--- a/src/journal/test-journal.c
+++ b/src/journal/test-journal.c
@@ -22,11 +22,11 @@
#include <fcntl.h>
#include <unistd.h>
-#include "log.h"
-#include "rm-rf.h"
-#include "journal-file.h"
#include "journal-authenticate.h"
+#include "journal-file.h"
#include "journal-vacuum.h"
+#include "log.h"
+#include "rm-rf.h"
static bool arg_keep = false;
diff --git a/src/libsystemd-network/dhcp-identifier.c b/src/libsystemd-network/dhcp-identifier.c
index 368525c40a..d7ae865557 100644
--- a/src/libsystemd-network/dhcp-identifier.c
+++ b/src/libsystemd-network/dhcp-identifier.c
@@ -52,7 +52,7 @@ int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len) {
/* a bit of snake-oil perhaps, but no need to expose the machine-id
directly; duid->en.id might not be aligned, so we need to copy */
- siphash24(&hash, &machine_id, sizeof(machine_id), HASH_KEY.bytes);
+ hash = htole64(siphash24(&machine_id, sizeof(machine_id), HASH_KEY.bytes));
memcpy(duid->en.id, &hash, sizeof(duid->en.id));
return 0;
@@ -86,10 +86,12 @@ int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_i
}
if (name)
- siphash24(&id, name, strlen(name), HASH_KEY.bytes);
+ id = siphash24(name, strlen(name), HASH_KEY.bytes);
else
/* fall back to MAC address if no predictable name available */
- siphash24(&id, mac, mac_len, HASH_KEY.bytes);
+ id = siphash24(mac, mac_len, HASH_KEY.bytes);
+
+ id = htole64(id);
/* fold into 32 bits */
unaligned_write_be32(_id, (id & 0xffffffff) ^ (id >> 32));
diff --git a/src/libsystemd-network/dhcp-option.c b/src/libsystemd-network/dhcp-option.c
index 36be7d54ed..a6c410ba91 100644
--- a/src/libsystemd-network/dhcp-option.c
+++ b/src/libsystemd-network/dhcp-option.c
@@ -19,10 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdint.h>
-#include <string.h>
#include <errno.h>
+#include <stdint.h>
#include <stdio.h>
+#include <string.h>
#include "dhcp-internal.h"
diff --git a/src/libsystemd-network/dhcp-packet.c b/src/libsystemd-network/dhcp-packet.c
index cd7f5095ca..9ff42b155e 100644
--- a/src/libsystemd-network/dhcp-packet.c
+++ b/src/libsystemd-network/dhcp-packet.c
@@ -19,13 +19,12 @@
***/
#include <errno.h>
-#include <string.h>
#include <net/ethernet.h>
#include <net/if_arp.h>
+#include <string.h>
-
-#include "dhcp-protocol.h"
#include "dhcp-internal.h"
+#include "dhcp-protocol.h"
#define DHCP_CLIENT_MIN_OPTIONS_SIZE 312
diff --git a/src/libsystemd-network/dhcp6-option.c b/src/libsystemd-network/dhcp6-option.c
index 0f46df6a1b..62023a9e49 100644
--- a/src/libsystemd-network/dhcp6-option.c
+++ b/src/libsystemd-network/dhcp6-option.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <netinet/in.h>
#include <errno.h>
+#include <netinet/in.h>
#include <string.h>
#include "alloc-util.h"
diff --git a/src/libsystemd-network/lldp-port.c b/src/libsystemd-network/lldp-port.c
index 97b6b485d2..1f1a49adbf 100644
--- a/src/libsystemd-network/lldp-port.c
+++ b/src/libsystemd-network/lldp-port.c
@@ -22,9 +22,9 @@
#include "alloc-util.h"
#include "async.h"
-#include "lldp-port.h"
-#include "lldp-network.h"
#include "lldp-internal.h"
+#include "lldp-network.h"
+#include "lldp-port.h"
int lldp_port_start(lldp_port *p) {
int r;
diff --git a/src/libsystemd-network/lldp-tlv.c b/src/libsystemd-network/lldp-tlv.c
index 7890160497..66343147a1 100644
--- a/src/libsystemd-network/lldp-tlv.c
+++ b/src/libsystemd-network/lldp-tlv.c
@@ -20,8 +20,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <net/ethernet.h>
#include <arpa/inet.h>
+#include <net/ethernet.h>
#include "alloc-util.h"
#include "lldp-tlv.h"
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c
index ab20b6065a..a4d4f1ae2f 100644
--- a/src/libsystemd-network/network-internal.c
+++ b/src/libsystemd-network/network-internal.c
@@ -29,9 +29,9 @@
#include "condition.h"
#include "conf-parser.h"
#include "dhcp-lease-internal.h"
+#include "hexdecoct.h"
#include "log.h"
#include "network-internal.h"
-#include "hexdecoct.h"
#include "parse-util.h"
#include "siphash24.h"
#include "string-util.h"
@@ -81,7 +81,7 @@ int net_get_unique_predictable_data(struct udev_device *device, uint64_t *result
/* Let's hash the machine ID plus the device name. We
* use a fixed, but originally randomly created hash
* key here. */
- siphash24(result, v, sz, HASH_KEY.bytes);
+ *result = htole64(siphash24(v, sz, HASH_KEY.bytes));
return 0;
}
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index eeb59bb3da..277c88e2b9 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -753,7 +753,7 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
siphash24_init(&state, HASH_KEY.bytes);
client_id_hash_func(&req->client_id, &state);
- siphash24_finalize(&hash, &state);
+ hash = htole64(siphash24_finalize(&state));
next_offer = hash % server->pool_size;
for (i = 0; i < server->pool_size; i++) {
diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c
index e69b1864d7..30a7ef5785 100644
--- a/src/libsystemd-network/sd-ipv4ll.c
+++ b/src/libsystemd-network/sd-ipv4ll.c
@@ -101,6 +101,8 @@ int sd_ipv4ll_new(sd_ipv4ll **ret) {
if (!ll)
return -ENOMEM;
+ ll->n_ref = 1;
+
r = sd_ipv4acd_new(&ll->acd);
if (r < 0)
return r;
@@ -109,8 +111,6 @@ int sd_ipv4ll_new(sd_ipv4ll **ret) {
if (r < 0)
return r;
- ll->n_ref = 1;
-
*ret = ll;
ll = NULL;
@@ -146,12 +146,11 @@ int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr) {
uint64_t seed;
/* If no random data is set, generate some from the MAC */
- siphash24(&seed, &addr->ether_addr_octet,
- ETH_ALEN, HASH_KEY.bytes);
+ seed = siphash24(&addr->ether_addr_octet, ETH_ALEN, HASH_KEY.bytes);
assert_cc(sizeof(unsigned) <= 8);
- r = sd_ipv4ll_set_address_seed(ll, (unsigned)seed);
+ r = sd_ipv4ll_set_address_seed(ll, (unsigned) htole64(seed));
if (r < 0)
return r;
}
diff --git a/src/libsystemd-network/test-acd.c b/src/libsystemd-network/test-acd.c
index 94c31af3f3..69eff5116f 100644
--- a/src/libsystemd-network/test-acd.c
+++ b/src/libsystemd-network/test-acd.c
@@ -19,21 +19,21 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdlib.h>
#include <errno.h>
+#include <stdlib.h>
#include <unistd.h>
#include <linux/veth.h>
#include <net/if.h>
#include "sd-event.h"
-#include "sd-netlink.h"
#include "sd-ipv4acd.h"
+#include "sd-netlink.h"
-#include "util.h"
#include "event-util.h"
-#include "netlink-util.h"
#include "in-addr-util.h"
+#include "netlink-util.h"
+#include "util.h"
static void acd_handler(sd_ipv4acd *acd, int event, void *userdata) {
assert_se(acd);
diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c
index 5b52c1cbb9..1200a7c251 100644
--- a/src/libsystemd-network/test-dhcp-client.c
+++ b/src/libsystemd-network/test-dhcp-client.c
@@ -32,8 +32,8 @@
#include "dhcp-internal.h"
#include "dhcp-protocol.h"
#include "event-util.h"
-#include "util.h"
#include "fd-util.h"
+#include "util.h"
static uint8_t mac_addr[] = {'A', 'B', 'C', '1', '2', '3'};
diff --git a/src/libsystemd-network/test-dhcp-option.c b/src/libsystemd-network/test-dhcp-option.c
index 2d29e28f16..3607df63af 100644
--- a/src/libsystemd-network/test-dhcp-option.c
+++ b/src/libsystemd-network/test-dhcp-option.c
@@ -1,8 +1,8 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-#include <stdio.h>
-#include <stdbool.h>
#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
#include <string.h>
#include "alloc-util.h"
diff --git a/src/libsystemd-network/test-dhcp-server.c b/src/libsystemd-network/test-dhcp-server.c
index 62fdec46da..2b5f59e4d6 100644
--- a/src/libsystemd-network/test-dhcp-server.c
+++ b/src/libsystemd-network/test-dhcp-server.c
@@ -200,13 +200,11 @@ static void test_message_handler(void) {
static uint64_t client_id_hash_helper(DHCPClientId *id, uint8_t key[HASH_KEY_SIZE]) {
struct siphash state;
- uint64_t hash;
siphash24_init(&state, key);
client_id_hash_func(id, &state);
- siphash24_finalize(&hash, &state);
- return hash;
+ return htole64(siphash24_finalize(&state));
}
static void test_client_id_hash(void) {
diff --git a/src/libsystemd/sd-bus/bus-bloom.c b/src/libsystemd/sd-bus/bus-bloom.c
index a592ff50cf..c0c5d445eb 100644
--- a/src/libsystemd/sd-bus/bus-bloom.c
+++ b/src/libsystemd/sd-bus/bus-bloom.c
@@ -19,9 +19,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "util.h"
-#include "siphash24.h"
#include "bus-bloom.h"
+#include "siphash24.h"
+#include "util.h"
static inline void set_bit(uint64_t filter[], unsigned long b) {
filter[b >> 6] |= 1ULL << (b & 63);
@@ -72,7 +72,7 @@ static void bloom_add_data(
for (d = 0; d < w; d++) {
if (c <= 0) {
- siphash24(&h, data, n, hash_keys[hash_index++].bytes);
+ h = siphash24(data, n, hash_keys[hash_index++].bytes);
c += 8;
}
diff --git a/src/libsystemd/sd-bus/bus-bloom.h b/src/libsystemd/sd-bus/bus-bloom.h
index a9350d7f51..38892044f1 100644
--- a/src/libsystemd/sd-bus/bus-bloom.h
+++ b/src/libsystemd/sd-bus/bus-bloom.h
@@ -22,6 +22,7 @@
***/
#include <stdbool.h>
+#include <stddef.h>
#include <stdint.h>
/*
diff --git a/src/libsystemd/sd-bus/bus-common-errors.c b/src/libsystemd/sd-bus/bus-common-errors.c
index 52f8dfd3be..8d486fcbbd 100644
--- a/src/libsystemd/sd-bus/bus-common-errors.c
+++ b/src/libsystemd/sd-bus/bus-common-errors.c
@@ -22,8 +22,9 @@
#include <errno.h>
#include "sd-bus.h"
-#include "bus-error.h"
+
#include "bus-common-errors.h"
+#include "bus-error.h"
BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = {
SD_BUS_ERROR_MAP(BUS_ERROR_NO_SUCH_UNIT, ENOENT),
diff --git a/src/libsystemd/sd-bus/bus-container.c b/src/libsystemd/sd-bus/bus-container.c
index 589a90bbff..7da6ba9903 100644
--- a/src/libsystemd/sd-bus/bus-container.c
+++ b/src/libsystemd/sd-bus/bus-container.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
#include <fcntl.h>
+#include <unistd.h>
#include "bus-container.h"
#include "bus-internal.h"
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index ddd3a55b6c..94251fe87c 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -23,8 +23,8 @@
#include <valgrind/memcheck.h>
#endif
-#include <stddef.h>
#include <errno.h>
+#include <stddef.h>
#include "sd-bus.h"
diff --git a/src/libsystemd/sd-bus/bus-error.c b/src/libsystemd/sd-bus/bus-error.c
index 239d7245e6..404eaa3c89 100644
--- a/src/libsystemd/sd-bus/bus-error.c
+++ b/src/libsystemd/sd-bus/bus-error.c
@@ -29,10 +29,10 @@
#include "sd-bus.h"
#include "alloc-util.h"
+#include "bus-error.h"
#include "errno-list.h"
#include "string-util.h"
#include "util.h"
-#include "bus-error.h"
BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_standard_errors[] = {
SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.Failed", EACCES),
diff --git a/src/libsystemd/sd-bus/bus-gvariant.c b/src/libsystemd/sd-bus/bus-gvariant.c
index 402d43d66d..ec027590b2 100644
--- a/src/libsystemd/sd-bus/bus-gvariant.c
+++ b/src/libsystemd/sd-bus/bus-gvariant.c
@@ -19,9 +19,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "bus-type.h"
#include "bus-gvariant.h"
#include "bus-signature.h"
+#include "bus-type.h"
int bus_gvariant_get_size(const char *signature) {
const char *p;
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
index 8c472626a8..303e49fa84 100644
--- a/src/libsystemd/sd-bus/bus-objects.c
+++ b/src/libsystemd/sd-bus/bus-objects.c
@@ -23,6 +23,7 @@
#include "bus-internal.h"
#include "bus-introspect.h"
#include "bus-message.h"
+#include "bus-objects.h"
#include "bus-signature.h"
#include "bus-slot.h"
#include "bus-type.h"
@@ -30,7 +31,6 @@
#include "set.h"
#include "string-util.h"
#include "strv.h"
-#include "bus-objects.h"
static int node_vtable_get_userdata(
sd_bus *bus,
diff --git a/src/libsystemd/sd-bus/bus-slot.c b/src/libsystemd/sd-bus/bus-slot.c
index 550bad27ba..e405a04c53 100644
--- a/src/libsystemd/sd-bus/bus-slot.c
+++ b/src/libsystemd/sd-bus/bus-slot.c
@@ -24,8 +24,8 @@
#include "alloc-util.h"
#include "bus-control.h"
#include "bus-objects.h"
-#include "string-util.h"
#include "bus-slot.h"
+#include "string-util.h"
sd_bus_slot *bus_slot_allocate(
sd_bus *bus,
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index a8d79b01b0..99780c8cce 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -20,12 +20,12 @@
***/
#include <endian.h>
-#include <stdlib.h>
-#include <unistd.h>
#include <netdb.h>
#include <poll.h>
-#include <sys/mman.h>
#include <pthread.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <unistd.h>
#include "sd-bus.h"
@@ -46,10 +46,10 @@
#include "cgroup-util.h"
#include "def.h"
#include "fd-util.h"
+#include "hexdecoct.h"
#include "hostname-util.h"
#include "macro.h"
#include "missing.h"
-#include "hexdecoct.h"
#include "parse-util.h"
#include "string-util.h"
#include "strv.h"
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
index 767aef63ff..f20eced4ac 100644
--- a/src/libsystemd/sd-bus/test-bus-chat.c
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
@@ -19,10 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdlib.h>
+#include <fcntl.h>
#include <pthread.h>
+#include <stdlib.h>
#include <unistd.h>
-#include <fcntl.h>
#include "sd-bus.h"
@@ -31,11 +31,11 @@
#include "bus-internal.h"
#include "bus-match.h"
#include "bus-util.h"
+#include "fd-util.h"
#include "formats-util.h"
#include "log.h"
#include "macro.h"
#include "util.h"
-#include "fd-util.h"
static int match_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
log_info("Match triggered! interface=%s member=%s", strna(sd_bus_message_get_interface(m)), strna(sd_bus_message_get_member(m)));
diff --git a/src/libsystemd/sd-bus/test-bus-creds.c b/src/libsystemd/sd-bus/test-bus-creds.c
index 580117165a..bd0101af9e 100644
--- a/src/libsystemd/sd-bus/test-bus-creds.c
+++ b/src/libsystemd/sd-bus/test-bus-creds.c
@@ -20,6 +20,7 @@
***/
#include "sd-bus.h"
+
#include "bus-dump.h"
#include "bus-util.h"
#include "cgroup-util.h"
diff --git a/src/libsystemd/sd-bus/test-bus-error.c b/src/libsystemd/sd-bus/test-bus-error.c
index 5753c04b0e..9d6c221eb0 100644
--- a/src/libsystemd/sd-bus/test-bus-error.c
+++ b/src/libsystemd/sd-bus/test-bus-error.c
@@ -20,10 +20,11 @@
***/
#include "sd-bus.h"
+
+#include "bus-common-errors.h"
#include "bus-error.h"
#include "bus-util.h"
#include "errno-list.h"
-#include "bus-common-errors.h"
static void test_error(void) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL, second = SD_BUS_ERROR_NULL;
diff --git a/src/libsystemd/sd-bus/test-bus-introspect.c b/src/libsystemd/sd-bus/test-bus-introspect.c
index f39dedeb24..26ba16d119 100644
--- a/src/libsystemd/sd-bus/test-bus-introspect.c
+++ b/src/libsystemd/sd-bus/test-bus-introspect.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "log.h"
#include "bus-introspect.h"
+#include "log.h"
static int prop_get(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) {
return -EINVAL;
diff --git a/src/libsystemd/sd-bus/test-bus-marshal.c b/src/libsystemd/sd-bus/test-bus-marshal.c
index 0747d6a37c..0a6093e78b 100644
--- a/src/libsystemd/sd-bus/test-bus-marshal.c
+++ b/src/libsystemd/sd-bus/test-bus-marshal.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdlib.h>
#include <math.h>
+#include <stdlib.h>
#ifdef HAVE_GLIB
#include <gio/gio.h>
@@ -38,8 +38,8 @@
#include "bus-message.h"
#include "bus-util.h"
#include "fd-util.h"
-#include "log.h"
#include "hexdecoct.h"
+#include "log.h"
#include "util.h"
static void test_bus_path_encode_unique(void) {
diff --git a/src/libsystemd/sd-bus/test-bus-match.c b/src/libsystemd/sd-bus/test-bus-match.c
index 75ea28371b..94896c196a 100644
--- a/src/libsystemd/sd-bus/test-bus-match.c
+++ b/src/libsystemd/sd-bus/test-bus-match.c
@@ -19,13 +19,12 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "log.h"
-#include "macro.h"
-
#include "bus-match.h"
#include "bus-message.h"
-#include "bus-util.h"
#include "bus-slot.h"
+#include "bus-util.h"
+#include "log.h"
+#include "macro.h"
static bool mask[32];
diff --git a/src/libsystemd/sd-bus/test-bus-objects.c b/src/libsystemd/sd-bus/test-bus-objects.c
index 5bc72e2355..edd63f9ea7 100644
--- a/src/libsystemd/sd-bus/test-bus-objects.c
+++ b/src/libsystemd/sd-bus/test-bus-objects.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdlib.h>
#include <pthread.h>
+#include <stdlib.h>
#include "sd-bus.h"
diff --git a/src/libsystemd/sd-bus/test-bus-signature.c b/src/libsystemd/sd-bus/test-bus-signature.c
index 92a810a7d8..949d16e6e9 100644
--- a/src/libsystemd/sd-bus/test-bus-signature.c
+++ b/src/libsystemd/sd-bus/test-bus-signature.c
@@ -19,10 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "string-util.h"
-#include "log.h"
-#include "bus-signature.h"
#include "bus-internal.h"
+#include "bus-signature.h"
+#include "log.h"
+#include "string-util.h"
int main(int argc, char *argv[]) {
char prefix[256];
diff --git a/src/libsystemd/sd-bus/test-bus-zero-copy.c b/src/libsystemd/sd-bus/test-bus-zero-copy.c
index ff8df61a9e..1cf8416fa4 100644
--- a/src/libsystemd/sd-bus/test-bus-zero-copy.c
+++ b/src/libsystemd/sd-bus/test-bus-zero-copy.c
@@ -27,11 +27,11 @@
#include "bus-dump.h"
#include "bus-kernel.h"
#include "bus-message.h"
+#include "fd-util.h"
#include "log.h"
#include "memfd-util.h"
#include "string-util.h"
#include "util.h"
-#include "fd-util.h"
#define FIRST_ARRAY 17
#define SECOND_ARRAY 33
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index ee4886700e..700ac691b5 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -34,6 +34,7 @@
#include "macro.h"
#include "missing.h"
#include "prioq.h"
+#include "process-util.h"
#include "set.h"
#include "signal-util.h"
#include "string-util.h"
@@ -808,7 +809,7 @@ static void source_disconnect(sd_event_source *s) {
s->event->n_enabled_child_sources--;
}
- (void) hashmap_remove(s->event->child_sources, INT_TO_PTR(s->child.pid));
+ (void) hashmap_remove(s->event->child_sources, PID_TO_PTR(s->child.pid));
event_gc_signal_data(s->event, &s->priority, SIGCHLD);
}
@@ -1188,7 +1189,7 @@ _public_ int sd_event_add_child(
if (r < 0)
return r;
- if (hashmap_contains(e->child_sources, INT_TO_PTR(pid)))
+ if (hashmap_contains(e->child_sources, PID_TO_PTR(pid)))
return -EBUSY;
s = source_new(e, !ret, SOURCE_CHILD);
@@ -1201,7 +1202,7 @@ _public_ int sd_event_add_child(
s->userdata = userdata;
s->enabled = SD_EVENT_ONESHOT;
- r = hashmap_put(e->child_sources, INT_TO_PTR(pid), s);
+ r = hashmap_put(e->child_sources, PID_TO_PTR(pid), s);
if (r < 0) {
source_free(s);
return r;
diff --git a/src/libsystemd/sd-id128/sd-id128.c b/src/libsystemd/sd-id128/sd-id128.c
index 1e17ea6a06..c12bb1e20b 100644
--- a/src/libsystemd/sd-id128/sd-id128.c
+++ b/src/libsystemd/sd-id128/sd-id128.c
@@ -26,9 +26,9 @@
#include "sd-id128.h"
#include "fd-util.h"
+#include "hexdecoct.h"
#include "io-util.h"
#include "macro.h"
-#include "hexdecoct.h"
#include "random-util.h"
#include "util.h"
diff --git a/src/libsystemd/sd-netlink/local-addresses.c b/src/libsystemd/sd-netlink/local-addresses.c
index a00865b56b..d431ba4be4 100644
--- a/src/libsystemd/sd-netlink/local-addresses.c
+++ b/src/libsystemd/sd-netlink/local-addresses.c
@@ -23,9 +23,9 @@
#include "sd-netlink.h"
#include "alloc-util.h"
-#include "netlink-util.h"
-#include "macro.h"
#include "local-addresses.h"
+#include "macro.h"
+#include "netlink-util.h"
static int address_compare(const void *_a, const void *_b) {
const struct local_address *a = _a, *b = _b;
diff --git a/src/libsystemd/sd-netlink/netlink-types.h b/src/libsystemd/sd-netlink/netlink-types.h
index bf7c641541..9e636a0b53 100644
--- a/src/libsystemd/sd-netlink/netlink-types.h
+++ b/src/libsystemd/sd-netlink/netlink-types.h
@@ -21,6 +21,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "macro.h"
+
enum {
NETLINK_TYPE_UNSPEC,
NETLINK_TYPE_U8, /* NLA_U8 */
diff --git a/src/libsystemd/sd-netlink/netlink-util.c b/src/libsystemd/sd-netlink/netlink-util.c
index 6f9fd2993b..95690b7ff1 100644
--- a/src/libsystemd/sd-netlink/netlink-util.c
+++ b/src/libsystemd/sd-netlink/netlink-util.c
@@ -21,8 +21,8 @@
#include "sd-netlink.h"
-#include "netlink-util.h"
#include "netlink-internal.h"
+#include "netlink-util.h"
int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) {
_cleanup_netlink_message_unref_ sd_netlink_message *message = NULL;
diff --git a/src/libsystemd/sd-netlink/test-local-addresses.c b/src/libsystemd/sd-netlink/test-local-addresses.c
index 7180175970..0b53297ab8 100644
--- a/src/libsystemd/sd-netlink/test-local-addresses.c
+++ b/src/libsystemd/sd-netlink/test-local-addresses.c
@@ -19,10 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "af-list.h"
#include "alloc-util.h"
#include "in-addr-util.h"
#include "local-addresses.h"
-#include "af-list.h"
static void print_local_addresses(struct local_address *a, unsigned n) {
unsigned i;
diff --git a/src/libsystemd/sd-utf8/sd-utf8.c b/src/libsystemd/sd-utf8/sd-utf8.c
index 381397cc52..9e52db3b3d 100644
--- a/src/libsystemd/sd-utf8/sd-utf8.c
+++ b/src/libsystemd/sd-utf8/sd-utf8.c
@@ -21,8 +21,8 @@
#include "sd-utf8.h"
-#include "util.h"
#include "utf8.h"
+#include "util.h"
_public_ const char *sd_utf8_is_valid(const char *s) {
assert_return(s, NULL);
diff --git a/src/libudev/libudev-queue.c b/src/libudev/libudev-queue.c
index 58410b1b8f..e3dffa6925 100644
--- a/src/libudev/libudev-queue.c
+++ b/src/libudev/libudev-queue.c
@@ -18,11 +18,11 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdlib.h>
-#include <stddef.h>
-#include <unistd.h>
#include <errno.h>
+#include <stddef.h>
+#include <stdlib.h>
#include <sys/inotify.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "fd-util.h"
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
index 38c426c1aa..36cdbbe0f9 100644
--- a/src/login/logind-core.c
+++ b/src/login/logind-core.c
@@ -19,10 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <sys/types.h>
-#include <sys/ioctl.h>
#include <fcntl.h>
#include <pwd.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
#include <linux/vt.h>
#include "alloc-util.h"
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 6c4ada29fb..9f03a7b31e 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -36,7 +36,6 @@
#include "bus-util.h"
#include "escape.h"
#include "fd-util.h"
-#include "fd-util.h"
#include "fileio.h"
#include "formats-util.h"
#include "io-util.h"
diff --git a/src/login/logind-utmp.c b/src/login/logind-utmp.c
index 3e7a935a34..3bd61a81fd 100644
--- a/src/login/logind-utmp.c
+++ b/src/login/logind-utmp.c
@@ -20,9 +20,9 @@
***/
#include <errno.h>
+#include <pwd.h>
#include <string.h>
#include <unistd.h>
-#include <pwd.h>
#include "sd-messages.h"
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
index 3f7cbb78df..ed4f7c726f 100644
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -493,7 +493,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
return PAM_SESSION_ERR;
}
- r = pam_set_data(handle, "systemd.session-fd", INT_TO_PTR(session_fd+1), NULL);
+ r = pam_set_data(handle, "systemd.session-fd", FD_TO_PTR(session_fd), NULL);
if (r != PAM_SUCCESS) {
pam_syslog(handle, LOG_ERR, "Failed to install session fd.");
safe_close(session_fd);
diff --git a/src/login/test-login-shared.c b/src/login/test-login-shared.c
index 4c4275d124..ac327f71fb 100644
--- a/src/login/test-login-shared.c
+++ b/src/login/test-login-shared.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "macro.h"
#include "login-util.h"
+#include "macro.h"
static void test_session_id_valid(void) {
assert_se(session_id_valid("c1"));
diff --git a/src/login/test-login-tables.c b/src/login/test-login-tables.c
index a4196bf14b..4fbc893a9a 100644
--- a/src/login/test-login-tables.c
+++ b/src/login/test-login-tables.c
@@ -19,7 +19,6 @@
#include "logind-action.h"
#include "logind-session.h"
-
#include "test-tables.h"
int main(int argc, char **argv) {
diff --git a/src/machine-id-setup/machine-id-setup-main.c b/src/machine-id-setup/machine-id-setup-main.c
index f1165ea09c..d805bcfdca 100644
--- a/src/machine-id-setup/machine-id-setup-main.c
+++ b/src/machine-id-setup/machine-id-setup-main.c
@@ -26,8 +26,8 @@
#include "log.h"
#include "machine-id-setup.h"
-#include "util.h"
#include "path-util.h"
+#include "util.h"
static char *arg_root = NULL;
static bool arg_commit = false;
diff --git a/src/machine/machine.c b/src/machine/machine.c
index 196bc4b8f4..6b1fae2769 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -29,6 +29,7 @@
#include "bus-error.h"
#include "bus-util.h"
#include "escape.h"
+#include "extract-word.h"
#include "fd-util.h"
#include "fileio.h"
#include "formats-util.h"
@@ -37,12 +38,12 @@
#include "machine.h"
#include "mkdir.h"
#include "parse-util.h"
+#include "process-util.h"
#include "special.h"
#include "string-table.h"
#include "terminal-util.h"
#include "unit-name.h"
#include "util.h"
-#include "extract-word.h"
Machine* machine_new(Manager *manager, MachineClass class, const char *name) {
Machine *m;
@@ -105,7 +106,7 @@ void machine_free(Machine *m) {
m->manager->host_machine = NULL;
if (m->leader > 0)
- (void) hashmap_remove_value(m->manager->machine_leaders, UINT_TO_PTR(m->leader), m);
+ (void) hashmap_remove_value(m->manager->machine_leaders, PID_TO_PTR(m->leader), m);
sd_bus_message_unref(m->create_message);
@@ -401,7 +402,7 @@ int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error) {
if (m->started)
return 0;
- r = hashmap_put(m->manager->machine_leaders, UINT_TO_PTR(m->leader), m);
+ r = hashmap_put(m->manager->machine_leaders, PID_TO_PTR(m->leader), m);
if (r < 0)
return r;
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index 4ec6baaa1f..961767c4a9 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -1508,7 +1508,7 @@ int manager_get_machine_by_pid(Manager *m, pid_t pid, Machine **machine) {
assert(pid >= 1);
assert(machine);
- mm = hashmap_get(m->machine_leaders, UINT_TO_PTR(pid));
+ mm = hashmap_get(m->machine_leaders, PID_TO_PTR(pid));
if (!mm) {
_cleanup_free_ char *unit = NULL;
diff --git a/src/machine/test-machine-tables.c b/src/machine/test-machine-tables.c
index 4aae426050..f851a4d37d 100644
--- a/src/machine/test-machine-tables.c
+++ b/src/machine/test-machine-tables.c
@@ -18,7 +18,6 @@
***/
#include "machine.h"
-
#include "test-tables.h"
int main(int argc, char **argv) {
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 446b048ef1..6fcb3050c7 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -36,7 +36,6 @@
#include "lldp.h"
#include "local-addresses.h"
#include "locale-util.h"
-#include "locale-util.h"
#include "netlink-util.h"
#include "pager.h"
#include "parse-util.h"
diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c
index c9222b8cb8..6e5480ee22 100644
--- a/src/network/networkd-fdb.c
+++ b/src/network/networkd-fdb.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <net/if.h>
#include <net/ethernet.h>
+#include <net/if.h>
#include "alloc-util.h"
#include "conf-parser.h"
diff --git a/src/network/networkd-ipv4ll.c b/src/network/networkd-ipv4ll.c
index 506654b5d7..f4aac4bb93 100644
--- a/src/network/networkd-ipv4ll.c
+++ b/src/network/networkd-ipv4ll.c
@@ -22,8 +22,8 @@
#include <netinet/ether.h>
#include <linux/if.h>
-#include "networkd-link.h"
#include "network-internal.h"
+#include "networkd-link.h"
static int ipv4ll_address_lost(Link *link) {
_cleanup_address_free_ Address *address = NULL;
diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c
index 11b35d6cf8..d09a3c2d07 100644
--- a/src/network/networkd-link-bus.c
+++ b/src/network/networkd-link-bus.c
@@ -19,13 +19,12 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "bus-util.h"
-#include "strv.h"
-
#include "alloc-util.h"
+#include "bus-util.h"
#include "networkd-link.h"
#include "networkd.h"
#include "parse-util.h"
+#include "strv.h"
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_operational_state, link_operstate, LinkOperationalState);
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_administrative_state, link_state, LinkState);
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index a2efac78f1..ce9e513ceb 100644
--- a/src/network/networkd-ndisc.c
+++ b/src/network/networkd-ndisc.c
@@ -207,6 +207,10 @@ static void ndisc_handler(sd_ndisc *nd, int event, void *userdata) {
r = sd_dhcp6_client_start(link->dhcp6_client);
if (r < 0 && r != -EBUSY)
log_link_warning_errno(link, r, "Starting DHCPv6 client after NDisc timeout failed: %m");
+
+ link->ndisc_configured = true;
+ link_check_ready(link);
+
break;
case SD_NDISC_EVENT_STOP:
break;
diff --git a/src/network/networkd-netdev-bond.c b/src/network/networkd-netdev-bond.c
index 4e4755f86f..50b9021d09 100644
--- a/src/network/networkd-netdev-bond.c
+++ b/src/network/networkd-netdev-bond.c
@@ -29,8 +29,8 @@
#include "conf-parser.h"
#include "missing.h"
#include "networkd-netdev-bond.h"
-#include "string-util.h"
#include "string-table.h"
+#include "string-util.h"
/*
* Number of seconds between instances where the bonding
diff --git a/src/network/networkd-netdev-bridge.c b/src/network/networkd-netdev-bridge.c
index 57c58d83b4..a991bdb5fb 100644
--- a/src/network/networkd-netdev-bridge.c
+++ b/src/network/networkd-netdev-bridge.c
@@ -22,9 +22,9 @@
#include <net/if.h>
-#include "networkd-netdev-bridge.h"
#include "missing.h"
#include "netlink-util.h"
+#include "networkd-netdev-bridge.h"
/* callback for brige netdev's parameter set */
static int netdev_bridge_set_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
diff --git a/src/network/networkd-netdev-tuntap.c b/src/network/networkd-netdev-tuntap.c
index 851e83537e..3d504a8564 100644
--- a/src/network/networkd-netdev-tuntap.c
+++ b/src/network/networkd-netdev-tuntap.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <sys/ioctl.h>
#include <net/if.h>
+#include <sys/ioctl.h>
#include <linux/if_tun.h>
#include "alloc-util.h"
diff --git a/src/network/networkd-netdev-veth.c b/src/network/networkd-netdev-veth.c
index bee1a16726..773a1ee6d1 100644
--- a/src/network/networkd-netdev-veth.c
+++ b/src/network/networkd-netdev-veth.c
@@ -23,6 +23,7 @@
#include <linux/veth.h>
#include "sd-netlink.h"
+
#include "networkd-netdev-veth.h"
static int netdev_veth_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
diff --git a/src/network/networkd-netdev-vxlan.c b/src/network/networkd-netdev-vxlan.c
index 755ad2f934..7932b93335 100644
--- a/src/network/networkd-netdev-vxlan.c
+++ b/src/network/networkd-netdev-vxlan.c
@@ -22,10 +22,11 @@
#include <net/if.h>
#include "sd-netlink.h"
-#include "networkd-netdev-vxlan.h"
-#include "networkd-link.h"
+
#include "conf-parser.h"
#include "missing.h"
+#include "networkd-link.h"
+#include "networkd-netdev-vxlan.h"
static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
VxLan *v;
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 081e299d82..a86a6383da 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -438,7 +438,7 @@ int netdev_get_mac(const char *ifname, struct ether_addr **ret) {
/* Let's hash the host machine ID plus the container name. We
* use a fixed, but originally randomly created hash key here. */
- siphash24(&result, v, sz, HASH_KEY.bytes);
+ result = siphash24(v, sz, HASH_KEY.bytes);
assert_cc(ETH_ALEN <= sizeof(result));
memcpy(mac->ether_addr_octet, &result, ETH_ALEN);
diff --git a/src/network/test-network-tables.c b/src/network/test-network-tables.c
index 438214015d..ecbbe6c3c9 100644
--- a/src/network/test-network-tables.c
+++ b/src/network/test-network-tables.c
@@ -1,11 +1,10 @@
-#include "networkd.h"
-#include "networkd-netdev-bond.h"
-#include "networkd-netdev-macvlan.h"
#include "dhcp6-internal.h"
#include "dhcp6-protocol.h"
-#include "netlink-internal.h"
#include "ethtool-util.h"
-
+#include "netlink-internal.h"
+#include "networkd-netdev-bond.h"
+#include "networkd-netdev-macvlan.h"
+#include "networkd.h"
#include "test-tables.h"
int main(int argc, char **argv) {
diff --git a/src/network/test-network.c b/src/network/test-network.c
index dbed3795e3..a1a77b6867 100644
--- a/src/network/test-network.c
+++ b/src/network/test-network.c
@@ -20,9 +20,9 @@
***/
#include "alloc-util.h"
-#include "networkd.h"
-#include "network-internal.h"
#include "dhcp-lease-internal.h"
+#include "network-internal.h"
+#include "networkd.h"
static void test_deserialize_in_addr(void) {
_cleanup_free_ struct in_addr *addresses = NULL;
diff --git a/src/nspawn/nspawn-network.c b/src/nspawn/nspawn-network.c
index 92dfb945e0..8f74c41c71 100644
--- a/src/nspawn/nspawn-network.c
+++ b/src/nspawn/nspawn-network.c
@@ -29,11 +29,11 @@
#include "alloc-util.h"
#include "ether-addr-util.h"
#include "netlink-util.h"
+#include "nspawn-network.h"
#include "siphash24.h"
#include "string-util.h"
#include "udev-util.h"
#include "util.h"
-#include "nspawn-network.h"
#define HOST_HASH_KEY SD_ID128_MAKE(1a,37,6f,c7,46,ec,45,0b,ad,a3,d5,31,06,60,5d,b1)
#define CONTAINER_HASH_KEY SD_ID128_MAKE(c3,c4,f9,19,b5,57,b2,1c,e6,cf,14,27,03,9c,ee,a2)
@@ -74,7 +74,7 @@ static int generate_mac(
/* Let's hash the host machine ID plus the container name. We
* use a fixed, but originally randomly created hash key here. */
- siphash24(&result, v, sz, hash_key.bytes);
+ result = htole64(siphash24(v, sz, hash_key.bytes));
assert_cc(ETH_ALEN <= sizeof(result));
memcpy(mac->ether_addr_octet, &result, ETH_ALEN);
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index d2ce731c72..f6a2c0386e 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -2283,7 +2283,7 @@ static int wait_for_container(pid_t pid, ContainerStatus *container) {
static int on_orderly_shutdown(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
pid_t pid;
- pid = PTR_TO_UINT32(userdata);
+ pid = PTR_TO_PID(userdata);
if (pid > 0) {
if (kill(pid, arg_kill_signal) >= 0) {
log_info("Trying to halt container. Send SIGTERM again to trigger immediate termination.");
@@ -3510,8 +3510,8 @@ int main(int argc, char *argv[]) {
if (arg_kill_signal > 0) {
/* Try to kill the init system on SIGINT or SIGTERM */
- sd_event_add_signal(event, NULL, SIGINT, on_orderly_shutdown, UINT32_TO_PTR(pid));
- sd_event_add_signal(event, NULL, SIGTERM, on_orderly_shutdown, UINT32_TO_PTR(pid));
+ sd_event_add_signal(event, NULL, SIGINT, on_orderly_shutdown, PID_TO_PTR(pid));
+ sd_event_add_signal(event, NULL, SIGTERM, on_orderly_shutdown, PID_TO_PTR(pid));
} else {
/* Immediately exit */
sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
diff --git a/src/quotacheck/quotacheck.c b/src/quotacheck/quotacheck.c
index dc2911e4e8..883d96608d 100644
--- a/src/quotacheck/quotacheck.c
+++ b/src/quotacheck/quotacheck.c
@@ -25,11 +25,11 @@
#include <sys/prctl.h>
#include <unistd.h>
+#include "proc-cmdline.h"
#include "process-util.h"
#include "signal-util.h"
#include "string-util.h"
#include "util.h"
-#include "proc-cmdline.h"
static bool arg_skip = false;
static bool arg_force = false;
diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c
index 57f99c9ef0..9fc56284d2 100644
--- a/src/remount-fs/remount-fs.c
+++ b/src/remount-fs/remount-fs.c
@@ -19,19 +19,22 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
#include <errno.h>
+#include <mntent.h>
#include <string.h>
+#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/wait.h>
-#include <mntent.h>
+#include <unistd.h>
#include "exit-status.h"
#include "log.h"
#include "mount-setup.h"
#include "mount-util.h"
#include "path-util.h"
+#include "process-util.h"
#include "signal-util.h"
+#include "strv.h"
#include "util.h"
/* Goes through /etc/fstab and remounts all API file systems, applying
@@ -39,10 +42,10 @@
* respected */
int main(int argc, char *argv[]) {
- int ret = EXIT_FAILURE;
+ _cleanup_hashmap_free_free_ Hashmap *pids = NULL;
_cleanup_endmntent_ FILE *f = NULL;
struct mntent* me;
- Hashmap *pids = NULL;
+ int r;
if (argc > 1) {
log_error("This program takes no argument.");
@@ -57,21 +60,21 @@ int main(int argc, char *argv[]) {
f = setmntent("/etc/fstab", "r");
if (!f) {
- if (errno == ENOENT)
- return EXIT_SUCCESS;
+ if (errno == ENOENT) {
+ r = 0;
+ goto finish;
+ }
- log_error_errno(errno, "Failed to open /etc/fstab: %m");
- return EXIT_FAILURE;
+ r = log_error_errno(errno, "Failed to open /etc/fstab: %m");
+ goto finish;
}
pids = hashmap_new(NULL);
if (!pids) {
- log_error("Failed to allocate set");
+ r = log_oom();
goto finish;
}
- ret = EXIT_SUCCESS;
-
while ((me = getmntent(f))) {
pid_t pid;
int k;
@@ -87,25 +90,18 @@ int main(int argc, char *argv[]) {
pid = fork();
if (pid < 0) {
- log_error_errno(errno, "Failed to fork: %m");
- ret = EXIT_FAILURE;
- continue;
+ r = log_error_errno(errno, "Failed to fork: %m");
+ goto finish;
}
if (pid == 0) {
- const char *arguments[5];
/* Child */
(void) reset_all_signal_handlers();
(void) reset_signal_mask();
+ (void) prctl(PR_SET_PDEATHSIG, SIGTERM);
- arguments[0] = MOUNT_PATH;
- arguments[1] = me->mnt_dir;
- arguments[2] = "-o";
- arguments[3] = "remount";
- arguments[4] = NULL;
-
- execv(MOUNT_PATH, (char **) arguments);
+ execv(MOUNT_PATH, STRV_MAKE(MOUNT_PATH, me->mnt_dir, "-o", "remount"));
log_error_errno(errno, "Failed to execute " MOUNT_PATH ": %m");
_exit(EXIT_FAILURE);
@@ -115,20 +111,19 @@ int main(int argc, char *argv[]) {
s = strdup(me->mnt_dir);
if (!s) {
- log_oom();
- ret = EXIT_FAILURE;
- continue;
+ r = log_oom();
+ goto finish;
}
-
- k = hashmap_put(pids, UINT_TO_PTR(pid), s);
+ k = hashmap_put(pids, PID_TO_PTR(pid), s);
if (k < 0) {
- log_error_errno(k, "Failed to add PID to set: %m");
- ret = EXIT_FAILURE;
- continue;
+ free(s);
+ r = log_oom();
+ goto finish;
}
}
+ r = 0;
while (!hashmap_isempty(pids)) {
siginfo_t si = {};
char *s;
@@ -138,12 +133,11 @@ int main(int argc, char *argv[]) {
if (errno == EINTR)
continue;
- log_error_errno(errno, "waitid() failed: %m");
- ret = EXIT_FAILURE;
- break;
+ r = log_error_errno(errno, "waitid() failed: %m");
+ goto finish;
}
- s = hashmap_remove(pids, UINT_TO_PTR(si.si_pid));
+ s = hashmap_remove(pids, PID_TO_PTR(si.si_pid));
if (s) {
if (!is_clean_exit(si.si_code, si.si_status, NULL)) {
if (si.si_code == CLD_EXITED)
@@ -151,7 +145,7 @@ int main(int argc, char *argv[]) {
else
log_error(MOUNT_PATH " for %s terminated by signal %s.", s, signal_to_string(si.si_status));
- ret = EXIT_FAILURE;
+ r = -ENOEXEC;
}
free(s);
@@ -159,9 +153,5 @@ int main(int argc, char *argv[]) {
}
finish:
-
- if (pids)
- hashmap_free_free(pids);
-
- return ret;
+ return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index 432e62dd9f..eb4e646846 100644
--- a/src/resolve-host/resolve-host.c
+++ b/src/resolve-host/resolve-host.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <net/if.h>
#include <getopt.h>
+#include <net/if.h>
#include "sd-bus.h"
diff --git a/src/resolve/resolved-llmnr.c b/src/resolve/resolved-llmnr.c
index 5c3a4a00c3..6a7ff9d245 100644
--- a/src/resolve/resolved-llmnr.c
+++ b/src/resolve/resolved-llmnr.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <resolv.h>
#include <netinet/in.h>
+#include <resolv.h>
#include "fd-util.h"
#include "resolved-llmnr.h"
diff --git a/src/run/run.c b/src/run/run.c
index 38a482bb11..df6a4f0074 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -33,6 +33,7 @@
#include "event-util.h"
#include "fd-util.h"
#include "formats-util.h"
+#include "parse-util.h"
#include "path-util.h"
#include "ptyfwd.h"
#include "signal-util.h"
@@ -41,7 +42,6 @@
#include "terminal-util.h"
#include "unit-name.h"
#include "user-util.h"
-#include "parse-util.h"
static bool arg_ask_password = true;
static bool arg_scope = false;
diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c
index 79f5a60579..35f2e1b67d 100644
--- a/src/shared/acl-util.c
+++ b/src/shared/acl-util.c
@@ -22,8 +22,8 @@
#include <errno.h>
#include <stdbool.h>
-#include "alloc-util.h"
#include "acl-util.h"
+#include "alloc-util.h"
#include "string-util.h"
#include "strv.h"
#include "user-util.h"
diff --git a/src/shared/acpi-fpdt.c b/src/shared/acpi-fpdt.c
index 8e36067f74..30e03c0652 100644
--- a/src/shared/acpi-fpdt.c
+++ b/src/shared/acpi-fpdt.c
@@ -25,8 +25,8 @@
#include <string.h>
#include <unistd.h>
-#include "alloc-util.h"
#include "acpi-fpdt.h"
+#include "alloc-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "time-util.h"
diff --git a/src/shared/architecture.c b/src/shared/architecture.c
index e2efa4272b..73937bd5a7 100644
--- a/src/shared/architecture.c
+++ b/src/shared/architecture.c
@@ -21,9 +21,9 @@
#include <sys/utsname.h>
+#include "architecture.h"
#include "string-table.h"
#include "string-util.h"
-#include "architecture.h"
int uname_architecture(void) {
diff --git a/src/shared/boot-timestamps.c b/src/shared/boot-timestamps.c
index ecbe1aaa0f..879aca9374 100644
--- a/src/shared/boot-timestamps.c
+++ b/src/shared/boot-timestamps.c
@@ -20,8 +20,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "boot-timestamps.h"
#include "acpi-fpdt.h"
+#include "boot-timestamps.h"
#include "efivars.h"
int boot_timestamps(const dual_timestamp *n, dual_timestamp *firmware, dual_timestamp *loader) {
diff --git a/src/shared/clean-ipc.c b/src/shared/clean-ipc.c
index 835fe52423..71cc613704 100644
--- a/src/shared/clean-ipc.c
+++ b/src/shared/clean-ipc.c
@@ -29,13 +29,13 @@
#include <sys/stat.h>
#include "clean-ipc.h"
+#include "dirent-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "formats-util.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
-#include "dirent-util.h"
static int clean_sysvipc_shm(uid_t delete_uid) {
_cleanup_fclose_ FILE *f = NULL;
diff --git a/src/shared/efivars.c b/src/shared/efivars.c
index 86bb0b57c3..89deeb9b55 100644
--- a/src/shared/efivars.c
+++ b/src/shared/efivars.c
@@ -19,9 +19,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <unistd.h>
-#include <string.h>
#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "dirent-util.h"
diff --git a/src/shared/firewall-util.c b/src/shared/firewall-util.c
index e178287872..5acfb0191b 100644
--- a/src/shared/firewall-util.c
+++ b/src/shared/firewall-util.c
@@ -19,9 +19,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <sys/types.h>
#include <arpa/inet.h>
#include <net/if.h>
+#include <sys/types.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter/nf_nat.h>
#include <linux/netfilter/xt_addrtype.h>
diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c
index d71f379e76..4a82bd18cd 100644
--- a/src/shared/path-lookup.c
+++ b/src/shared/path-lookup.c
@@ -19,18 +19,18 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdlib.h>
+#include <errno.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <errno.h>
#include "alloc-util.h"
-#include "util.h"
-#include "strv.h"
-#include "path-util.h"
#include "install.h"
-#include "string-util.h"
#include "path-lookup.h"
+#include "path-util.h"
+#include "string-util.h"
+#include "strv.h"
+#include "util.h"
int user_config_home(char **config_home) {
const char *e;
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c
index 63e81f4894..2666b8f7e2 100644
--- a/src/shared/ptyfwd.c
+++ b/src/shared/ptyfwd.c
@@ -19,9 +19,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <limits.h>
#include <sys/epoll.h>
#include <sys/ioctl.h>
-#include <limits.h>
#include <termios.h>
#include "alloc-util.h"
diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c
index c518cf83ec..09baf51661 100644
--- a/src/shared/seccomp-util.c
+++ b/src/shared/seccomp-util.c
@@ -21,9 +21,9 @@
#include <seccomp.h>
+#include "seccomp-util.h"
#include "string-util.h"
#include "util.h"
-#include "seccomp-util.h"
const char* seccomp_arch_to_string(uint32_t c) {
diff --git a/src/shared/spawn-ask-password-agent.c b/src/shared/spawn-ask-password-agent.c
index 29db855c67..3fcea61873 100644
--- a/src/shared/spawn-ask-password-agent.c
+++ b/src/shared/spawn-ask-password-agent.c
@@ -25,8 +25,8 @@
#include "log.h"
#include "process-util.h"
-#include "util.h"
#include "spawn-ask-password-agent.h"
+#include "util.h"
static pid_t agent_pid = 0;
diff --git a/src/shared/spawn-polkit-agent.c b/src/shared/spawn-polkit-agent.c
index ec6e5a8312..8ea6cb830b 100644
--- a/src/shared/spawn-polkit-agent.c
+++ b/src/shared/spawn-polkit-agent.c
@@ -19,11 +19,11 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
#include <errno.h>
#include <poll.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
#include "fd-util.h"
#include "io-util.h"
diff --git a/src/shared/sysctl-util.c b/src/shared/sysctl-util.c
index 21cb82ea1c..70caa542e7 100644
--- a/src/shared/sysctl-util.c
+++ b/src/shared/sysctl-util.c
@@ -30,8 +30,8 @@
#include "fileio.h"
#include "log.h"
#include "string-util.h"
-#include "util.h"
#include "sysctl-util.h"
+#include "util.h"
char *sysctl_normalize(char *s) {
char *n;
diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c
index d58f9873d5..7131e94cdb 100644
--- a/src/shared/watchdog.c
+++ b/src/shared/watchdog.c
@@ -19,15 +19,15 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <sys/ioctl.h>
#include <errno.h>
#include <fcntl.h>
+#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/watchdog.h>
-#include "watchdog.h"
-#include "log.h"
#include "fd-util.h"
+#include "log.h"
+#include "watchdog.h"
static int watchdog_fd = -1;
static usec_t watchdog_timeout = USEC_INFINITY;
diff --git a/src/test/test-architecture.c b/src/test/test-architecture.c
index a5b66a7d2f..35479d67c1 100644
--- a/src/test/test-architecture.c
+++ b/src/test/test-architecture.c
@@ -19,10 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "virt.h"
#include "architecture.h"
-#include "util.h"
#include "log.h"
+#include "util.h"
+#include "virt.h"
int main(int argc, char *argv[]) {
int a, v;
diff --git a/src/test/test-boot-timestamps.c b/src/test/test-boot-timestamps.c
index 06d93af533..fab33d20c7 100644
--- a/src/test/test-boot-timestamps.c
+++ b/src/test/test-boot-timestamps.c
@@ -20,11 +20,11 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "util.h"
-#include "log.h"
+#include "acpi-fpdt.h"
#include "boot-timestamps.h"
#include "efivars.h"
-#include "acpi-fpdt.h"
+#include "log.h"
+#include "util.h"
static int test_acpi_fpdt(void) {
usec_t loader_start;
diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c
index 85b0d607d6..2746013522 100644
--- a/src/test/test-cgroup-mask.c
+++ b/src/test/test-cgroup-mask.c
@@ -21,10 +21,10 @@
#include <stdio.h>
-#include "manager.h"
-#include "unit.h"
#include "macro.h"
+#include "manager.h"
#include "test-helper.h"
+#include "unit.h"
static int test_cgroup_mask(void) {
Manager *m = NULL;
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
index 954ed0d9e0..4f14c58788 100644
--- a/src/test/test-engine.c
+++ b/src/test/test-engine.c
@@ -19,12 +19,12 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdio.h>
#include <errno.h>
+#include <stdio.h>
#include <string.h>
-#include "manager.h"
#include "bus-util.h"
+#include "manager.h"
int main(int argc, char *argv[]) {
_cleanup_bus_error_free_ sd_bus_error err = SD_BUS_ERROR_NULL;
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index bde3c7c3cf..871c71e171 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdio.h>
#include <fcntl.h>
+#include <stdio.h>
#include <unistd.h>
#include "alloc-util.h"
diff --git a/src/test/test-firewall-util.c b/src/test/test-firewall-util.c
index d636e427c4..ff66bde094 100644
--- a/src/test/test-firewall-util.c
+++ b/src/test/test-firewall-util.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "log.h"
#include "firewall-util.h"
+#include "log.h"
#define MAKE_IN_ADDR_UNION(a,b,c,d) (union in_addr_union) { .in.s_addr = htobe32((uint32_t) (a) << 24 | (uint32_t) (b) << 16 | (uint32_t) (c) << 8 | (uint32_t) (d))}
diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c
index d0e65001f5..83cea360e6 100644
--- a/src/test/test-hashmap.c
+++ b/src/test/test-hashmap.c
@@ -17,8 +17,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "util.h"
#include "hashmap.h"
+#include "util.h"
void test_hashmap_funcs(void);
void test_ordered_hashmap_funcs(void);
diff --git a/src/test/test-install.c b/src/test/test-install.c
index 359b262347..ef6f1efb89 100644
--- a/src/test/test-install.c
+++ b/src/test/test-install.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <string.h>
#include <stdio.h>
+#include <string.h>
#include "install.h"
diff --git a/src/test/test-job-type.c b/src/test/test-job-type.c
index af0d76e894..75ce3a349e 100644
--- a/src/test/test-job-type.c
+++ b/src/test/test-job-type.c
@@ -22,8 +22,8 @@
#include <stdio.h>
#include "job.h"
-#include "unit.h"
#include "service.h"
+#include "unit.h"
int main(int argc, char*argv[]) {
JobType a, b, c, ab, bc, ab_c, bc_a, a_bc;
diff --git a/src/test/test-locale-util.c b/src/test/test-locale-util.c
index 9765075365..427c698d1d 100644
--- a/src/test/test-locale-util.c
+++ b/src/test/test-locale-util.c
@@ -19,8 +19,8 @@
#include "locale-util.h"
-#include "strv.h"
#include "macro.h"
+#include "strv.h"
static void test_get_locales(void) {
_cleanup_strv_free_ char **locales = NULL;
diff --git a/src/test/test-log.c b/src/test/test-log.c
index 9dcfa2f274..a01df9b049 100644
--- a/src/test/test-log.c
+++ b/src/test/test-log.c
@@ -22,9 +22,9 @@
#include <stddef.h>
#include <unistd.h>
+#include "formats-util.h"
#include "log.h"
#include "util.h"
-#include "formats-util.h"
int main(int argc, char* argv[]) {
diff --git a/src/test/test-loopback.c b/src/test/test-loopback.c
index e3e5a95add..556938a0f8 100644
--- a/src/test/test-loopback.c
+++ b/src/test/test-loopback.c
@@ -19,11 +19,11 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <string.h>
#include <stdio.h>
+#include <string.h>
-#include "loopback-setup.h"
#include "log.h"
+#include "loopback-setup.h"
int main(int argc, char* argv[]) {
int r;
diff --git a/src/test/test-ns.c b/src/test/test-ns.c
index 3050be9e9d..1175114a3a 100644
--- a/src/test/test-ns.c
+++ b/src/test/test-ns.c
@@ -22,8 +22,8 @@
#include <stdlib.h>
#include <unistd.h>
-#include "namespace.h"
#include "log.h"
+#include "namespace.h"
int main(int argc, char *argv[]) {
const char * const writable[] = {
diff --git a/src/test/test-ratelimit.c b/src/test/test-ratelimit.c
index 462b55cdb3..990b834c79 100644
--- a/src/test/test-ratelimit.c
+++ b/src/test/test-ratelimit.c
@@ -19,9 +19,9 @@
#include <unistd.h>
+#include "macro.h"
#include "ratelimit.h"
#include "time-util.h"
-#include "macro.h"
static void test_ratelimit_test(void) {
int i;
diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c
index ebc9110c4d..8396ae60f3 100644
--- a/src/test/test-sched-prio.c
+++ b/src/test/test-sched-prio.c
@@ -21,8 +21,8 @@
#include <sched.h>
-#include "manager.h"
#include "macro.h"
+#include "manager.h"
int main(int argc, char *argv[]) {
Manager *m = NULL;
diff --git a/src/test/test-siphash24.c b/src/test/test-siphash24.c
index 0200e146ad..a571a95a70 100644
--- a/src/test/test-siphash24.c
+++ b/src/test/test-siphash24.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "util.h"
#include "siphash24.h"
+#include "util.h"
#define ITERATIONS 10000000ULL
@@ -29,7 +29,7 @@ static int do_test(const uint8_t *in, size_t len, const uint8_t *key) {
uint64_t out = 0;
unsigned i, j;
- siphash24(&out, in, len, key);
+ out = siphash24(in, len, key);
assert_se(out == htole64(0xa129ca6149be45e5));
/* verify the internal state as given in the above paper */
@@ -43,7 +43,7 @@ static int do_test(const uint8_t *in, size_t len, const uint8_t *key) {
assert_se(state.v1 == 0x0d52f6f62a4f59a4);
assert_se(state.v2 == 0x634cb3577b01fd3d);
assert_se(state.v3 == 0xa5224d6f55c7d9c8);
- siphash24_finalize(&out, &state);
+ out = siphash24_finalize(&state);
assert_se(out == htole64(0xa129ca6149be45e5));
assert_se(state.v0 == 0xf6bcd53893fecff1);
assert_se(state.v1 == 0x54b9964c7ea0d937);
@@ -58,7 +58,7 @@ static int do_test(const uint8_t *in, size_t len, const uint8_t *key) {
siphash24_compress(in, i, &state);
siphash24_compress(&in[i], j - i, &state);
siphash24_compress(&in[j], len - j, &state);
- siphash24_finalize(&out, &state);
+ out = siphash24_finalize(&state);
assert_se(out == htole64(0xa129ca6149be45e5));
}
}
diff --git a/src/test/test-sleep.c b/src/test/test-sleep.c
index 4308ddfb64..fb115ce4f3 100644
--- a/src/test/test-sleep.c
+++ b/src/test/test-sleep.c
@@ -21,10 +21,10 @@
#include <stdio.h>
-#include "util.h"
#include "log.h"
#include "sleep-config.h"
#include "strv.h"
+#include "util.h"
static void test_sleep(void) {
_cleanup_strv_free_ char
diff --git a/src/test/test-tables.c b/src/test/test-tables.c
index da27cde3da..aef992ee3c 100644
--- a/src/test/test-tables.c
+++ b/src/test/test-tables.c
@@ -36,6 +36,7 @@
#include "logs-show.h"
#include "mount.h"
#include "path.h"
+#include "rlimit-util.h"
#include "scope.h"
#include "service.h"
#include "slice.h"
@@ -43,13 +44,11 @@
#include "socket.h"
#include "swap.h"
#include "target.h"
+#include "test-tables.h"
#include "timer.h"
#include "unit-name.h"
#include "unit.h"
#include "util.h"
-#include "rlimit-util.h"
-
-#include "test-tables.h"
int main(int argc, char **argv) {
test_table(architecture, ARCHITECTURE);
diff --git a/src/test/test-terminal-util.c b/src/test/test-terminal-util.c
index e940b5a204..84b448a095 100644
--- a/src/test/test-terminal-util.c
+++ b/src/test/test-terminal-util.c
@@ -18,8 +18,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdio.h>
#include <stdbool.h>
+#include <stdio.h>
#include "fd-util.h"
#include "fileio.h"
diff --git a/src/test/test-time.c b/src/test/test-time.c
index 820e4aaee2..8896b2c92b 100644
--- a/src/test/test-time.c
+++ b/src/test/test-time.c
@@ -19,8 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "time-util.h"
#include "strv.h"
+#include "time-util.h"
static void test_parse_sec(void) {
usec_t u;
diff --git a/src/test/test-unaligned.c b/src/test/test-unaligned.c
index ec52db262c..b18b3fca0e 100644
--- a/src/test/test-unaligned.c
+++ b/src/test/test-unaligned.c
@@ -17,8 +17,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "unaligned.h"
#include "sparse-endian.h"
+#include "unaligned.h"
#include "util.h"
static uint8_t data[] = {
diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c
index 0af8349732..e98be5763c 100644
--- a/src/test/test-utf8.c
+++ b/src/test/test-utf8.c
@@ -20,9 +20,9 @@
***/
#include "alloc-util.h"
+#include "string-util.h"
#include "utf8.h"
#include "util.h"
-#include "string-util.h"
static void test_utf8_is_printable(void) {
assert_se(utf8_is_printable("ascii is valid\tunicode", 22));
diff --git a/src/test/test-watchdog.c b/src/test/test-watchdog.c
index 2e5d0c3aae..d10d9f49af 100644
--- a/src/test/test-watchdog.c
+++ b/src/test/test-watchdog.c
@@ -21,8 +21,8 @@
#include <unistd.h>
-#include "watchdog.h"
#include "log.h"
+#include "watchdog.h"
int main(int argc, char *argv[]) {
usec_t t = 10 * USEC_PER_SEC;
diff --git a/src/udev/mtd_probe/mtd_probe.c b/src/udev/mtd_probe/mtd_probe.c
index 67b750c4b3..462fab7623 100644
--- a/src/udev/mtd_probe/mtd_probe.c
+++ b/src/udev/mtd_probe/mtd_probe.c
@@ -17,14 +17,14 @@
* Boston, MA 02110-1301 USA
*/
+#include <fcntl.h>
+#include <mtd/mtd-user.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/ioctl.h>
-#include <mtd/mtd-user.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <fcntl.h>
+#include <sys/types.h>
#include <unistd.h>
-#include <stdlib.h>
#include "mtd_probe.h"
diff --git a/src/udev/mtd_probe/probe_smartmedia.c b/src/udev/mtd_probe/probe_smartmedia.c
index a007ccee2f..6a6c5522a7 100644
--- a/src/udev/mtd_probe/probe_smartmedia.c
+++ b/src/udev/mtd_probe/probe_smartmedia.c
@@ -17,15 +17,16 @@
* Boston, MA 02110-1301 USA
*/
+#include <fcntl.h>
+#include <mtd/mtd-user.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <mtd/mtd-user.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <fcntl.h>
+#include <sys/types.h>
#include <unistd.h>
-#include <stdint.h>
+
#include "mtd_probe.h"
static const uint8_t cis_signature[] = {
diff --git a/src/udev/udev-builtin-uaccess.c b/src/udev/udev-builtin-uaccess.c
index bbda9de08c..3ebe36f043 100644
--- a/src/udev/udev-builtin-uaccess.c
+++ b/src/udev/udev-builtin-uaccess.c
@@ -18,9 +18,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <errno.h>
#include "sd-login.h"
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 1e05be51a5..962de22f43 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -10,13 +10,13 @@
*/
#include <errno.h>
-#include <stdlib.h>
+#include <poll.h>
#include <stddef.h>
+#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <poll.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "fd-util.h"
diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c
index 9aa5ab185d..f1fdccaed8 100644
--- a/src/udev/udev-watch.c
+++ b/src/udev/udev-watch.c
@@ -17,12 +17,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <errno.h>
-#include <stdio.h>
#include <dirent.h>
+#include <errno.h>
#include <stddef.h>
-#include <unistd.h>
+#include <stdio.h>
#include <sys/inotify.h>
+#include <unistd.h>
#include "udev.h"
diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c
index 78170463b6..989decbe95 100644
--- a/src/udev/udevadm-control.c
+++ b/src/udev/udevadm-control.c
@@ -13,15 +13,15 @@
*/
#include <errno.h>
+#include <getopt.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <stddef.h>
#include <string.h>
#include <unistd.h>
-#include <getopt.h>
-#include "udev.h"
#include "udev-util.h"
+#include "udev.h"
static void print_help(void) {
printf("%s control COMMAND\n\n"
diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
index 30aa53feb2..f9cb5e63a2 100644
--- a/src/udev/udevadm-monitor.c
+++ b/src/udev/udevadm-monitor.c
@@ -15,15 +15,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdio.h>
-#include <stddef.h>
-#include <string.h>
#include <errno.h>
-#include <signal.h>
#include <getopt.h>
-#include <time.h>
-#include <sys/time.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
#include <sys/epoll.h>
+#include <sys/time.h>
+#include <time.h>
#include "fd-util.h"
#include "formats-util.h"
diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index c25071b0fe..6a5dc6e9e4 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -17,14 +17,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-#include <stdio.h>
-#include <unistd.h>
#include <errno.h>
#include <getopt.h>
#include <poll.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include "parse-util.h"
#include "udev.h"
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 5364b92a57..6d9d765153 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -191,7 +191,7 @@ static void worker_free(struct worker *worker) {
assert(worker->manager);
- hashmap_remove(worker->manager->workers, UINT_TO_PTR(worker->pid));
+ hashmap_remove(worker->manager->workers, PID_TO_PTR(worker->pid));
udev_monitor_unref(worker->monitor);
event_free(worker->event);
@@ -234,7 +234,7 @@ static int worker_new(struct worker **ret, Manager *manager, struct udev_monitor
if (r < 0)
return r;
- r = hashmap_put(manager->workers, UINT_TO_PTR(pid), worker);
+ r = hashmap_put(manager->workers, PID_TO_PTR(pid), worker);
if (r < 0)
return r;
@@ -891,7 +891,7 @@ static int on_worker(sd_event_source *s, int fd, uint32_t revents, void *userdat
}
/* lookup worker who sent the signal */
- worker = hashmap_get(manager->workers, UINT_TO_PTR(ucred->pid));
+ worker = hashmap_get(manager->workers, PID_TO_PTR(ucred->pid));
if (!worker) {
log_debug("worker ["PID_FMT"] returned, but is no longer tracked", ucred->pid);
continue;
@@ -1195,7 +1195,7 @@ static int on_sigchld(sd_event_source *s, const struct signalfd_siginfo *si, voi
if (pid <= 0)
break;
- worker = hashmap_get(manager->workers, UINT_TO_PTR(pid));
+ worker = hashmap_get(manager->workers, PID_TO_PTR(pid));
if (!worker) {
log_warning("worker ["PID_FMT"] is unknown, ignoring", pid);
continue;
diff --git a/src/udev/v4l_id/v4l_id.c b/src/udev/v4l_id/v4l_id.c
index 607d78a019..aec6676a33 100644
--- a/src/udev/v4l_id/v4l_id.c
+++ b/src/udev/v4l_id/v4l_id.c
@@ -13,17 +13,17 @@
* General Public License for more details:
*/
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
+#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
-#include <sys/types.h>
-#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <linux/videodev2.h>
#include "fd-util.h"