From 5f7b80b4e543edd045785a5510ae480baeed84f8 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 17:14:35 +0200 Subject: [PATCH 1/4] hashmap: Make sure Iterator struct is named Otherwise we can't forward declare it. Split out of #37344 --- src/basic/hashmap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/hashmap.h b/src/basic/hashmap.h index f7e02c814e..4aa8fbb003 100644 --- a/src/basic/hashmap.h +++ b/src/basic/hashmap.h @@ -38,7 +38,7 @@ typedef struct IteratedCache IteratedCache; /* Caches the iterated order of on /* Ideally the Iterator would be an opaque struct, but it is instantiated * by hashmap users, so the definition has to be here. Do not use its fields * directly. */ -typedef struct { +typedef struct Iterator { const void *next_key; /* expected value of that entry's key pointer */ unsigned idx; /* index of an entry to be iterated next */ #if ENABLE_DEBUG_HASHMAP From 905ebf6b79621bdf42618db37cfb6f1836198762 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 17:20:57 +0200 Subject: [PATCH 2/4] sd-bus: Make sure sd_bus_error and sd_bus_error_map structs are named Otherwise we can't forward declare them. Split out of #37344 --- src/systemd/sd-bus-protocol.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/systemd/sd-bus-protocol.h b/src/systemd/sd-bus-protocol.h index 45e5f2e317..292b03e0bf 100644 --- a/src/systemd/sd-bus-protocol.h +++ b/src/systemd/sd-bus-protocol.h @@ -115,13 +115,13 @@ typedef struct sd_bus_slot sd_bus_slot; typedef struct sd_bus_creds sd_bus_creds; typedef struct sd_bus_track sd_bus_track; -typedef struct { +typedef struct sd_bus_error { const char *name; const char *message; int _need_free; } sd_bus_error; -typedef struct { +typedef struct sd_bus_error_map { const char *name; int code; } sd_bus_error_map; From 5a94aaaf5d383caea42aa846a683a2599ef5b216 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 17:10:53 +0200 Subject: [PATCH 3/4] xdg-autostart-generator: Clean up includes Split out of #37344 --- src/xdg-autostart-generator/fuzz-xdg-desktop.c | 7 ++----- src/xdg-autostart-generator/test-xdg-autostart.c | 1 - src/xdg-autostart-generator/xdg-autostart-condition.c | 3 ++- src/xdg-autostart-generator/xdg-autostart-generator.c | 8 ++------ src/xdg-autostart-generator/xdg-autostart-service.c | 3 +-- src/xdg-autostart-generator/xdg-autostart-service.h | 3 +-- 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/xdg-autostart-generator/fuzz-xdg-desktop.c b/src/xdg-autostart-generator/fuzz-xdg-desktop.c index 9aca797e1b..8c01feb827 100644 --- a/src/xdg-autostart-generator/fuzz-xdg-desktop.c +++ b/src/xdg-autostart-generator/fuzz-xdg-desktop.c @@ -1,13 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "alloc-util.h" +#include + #include "fd-util.h" -#include "fs-util.h" #include "fuzz.h" #include "rm-rf.h" -#include "string-util.h" -#include "strv.h" -#include "tests.h" #include "tmpfile-util.h" #include "xdg-autostart-service.h" diff --git a/src/xdg-autostart-generator/test-xdg-autostart.c b/src/xdg-autostart-generator/test-xdg-autostart.c index edad2452be..4caf6087fc 100644 --- a/src/xdg-autostart-generator/test-xdg-autostart.c +++ b/src/xdg-autostart-generator/test-xdg-autostart.c @@ -2,7 +2,6 @@ #include "alloc-util.h" #include "fd-util.h" -#include "fs-util.h" #include "string-util.h" #include "strv.h" #include "tests.h" diff --git a/src/xdg-autostart-generator/xdg-autostart-condition.c b/src/xdg-autostart-generator/xdg-autostart-condition.c index b822ab5aab..a59604082e 100644 --- a/src/xdg-autostart-generator/xdg-autostart-condition.c +++ b/src/xdg-autostart-generator/xdg-autostart-condition.c @@ -1,8 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #include "log.h" #include "main-func.h" -#include "string-util.h" #include "strv.h" /* diff --git a/src/xdg-autostart-generator/xdg-autostart-generator.c b/src/xdg-autostart-generator/xdg-autostart-generator.c index 37e59991e9..c7b9a1c70a 100644 --- a/src/xdg-autostart-generator/xdg-autostart-generator.c +++ b/src/xdg-autostart-generator/xdg-autostart-generator.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include +#include +#include #include #include "alloc-util.h" @@ -11,11 +11,7 @@ #include "glyph-util.h" #include "hashmap.h" #include "log.h" -#include "main-func.h" -#include "nulstr-util.h" #include "path-lookup.h" -#include "stat-util.h" -#include "string-util.h" #include "strv.h" #include "xdg-autostart-service.h" diff --git a/src/xdg-autostart-generator/xdg-autostart-service.c b/src/xdg-autostart-generator/xdg-autostart-service.c index e4081c9e63..dbf9087304 100644 --- a/src/xdg-autostart-generator/xdg-autostart-service.c +++ b/src/xdg-autostart-generator/xdg-autostart-service.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #include @@ -12,8 +11,8 @@ #include "fd-util.h" #include "fileio.h" #include "generator.h" +#include "glyph-util.h" #include "log.h" -#include "nulstr-util.h" #include "parse-util.h" #include "path-util.h" #include "specifier.h" diff --git a/src/xdg-autostart-generator/xdg-autostart-service.h b/src/xdg-autostart-generator/xdg-autostart-service.h index d540a7396c..83a692f708 100644 --- a/src/xdg-autostart-generator/xdg-autostart-service.h +++ b/src/xdg-autostart-generator/xdg-autostart-service.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "macro.h" -#include "memory-util.h" +#include "forward.h" typedef struct XdgAutostartService { char *name; From e2165e01bd2b3293a083e989dde3fedcdbc08afb Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 17:12:06 +0200 Subject: [PATCH 4/4] vmspawn: Clean up includes Split out of #37344 --- src/vmspawn/test-vmspawn-util.c | 2 -- src/vmspawn/vmspawn-mount.c | 2 -- src/vmspawn/vmspawn-mount.h | 3 +-- src/vmspawn/vmspawn-register.c | 3 +-- src/vmspawn/vmspawn-register.h | 5 +---- src/vmspawn/vmspawn-scope.c | 8 ++------ src/vmspawn/vmspawn-scope.h | 6 +----- src/vmspawn/vmspawn-settings.h | 5 +---- src/vmspawn/vmspawn-util.c | 9 ++------- src/vmspawn/vmspawn-util.h | 5 +---- src/vmspawn/vmspawn.c | 15 ++++----------- 11 files changed, 14 insertions(+), 49 deletions(-) diff --git a/src/vmspawn/test-vmspawn-util.c b/src/vmspawn/test-vmspawn-util.c index aaf5524536..d487cbcacb 100644 --- a/src/vmspawn/test-vmspawn-util.c +++ b/src/vmspawn/test-vmspawn-util.c @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include - #include "alloc-util.h" #include "string-util.h" #include "tests.h" diff --git a/src/vmspawn/vmspawn-mount.c b/src/vmspawn/vmspawn-mount.c index a57baaa3e8..9f03a21655 100644 --- a/src/vmspawn/vmspawn-mount.c +++ b/src/vmspawn/vmspawn-mount.c @@ -2,8 +2,6 @@ #include "alloc-util.h" #include "extract-word.h" -#include "macro.h" -#include "parse-argument.h" #include "path-util.h" #include "stat-util.h" #include "string-util.h" diff --git a/src/vmspawn/vmspawn-mount.h b/src/vmspawn/vmspawn-mount.h index 2ea24fd035..531288a9ed 100644 --- a/src/vmspawn/vmspawn-mount.h +++ b/src/vmspawn/vmspawn-mount.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include +#include "forward.h" typedef struct RuntimeMount { bool read_only; diff --git a/src/vmspawn/vmspawn-register.c b/src/vmspawn/vmspawn-register.c index a55caebc11..ae7edd0fdb 100644 --- a/src/vmspawn/vmspawn-register.c +++ b/src/vmspawn/vmspawn-register.c @@ -9,9 +9,8 @@ #include "bus-error.h" #include "bus-locator.h" -#include "json-util.h" +#include "errno-util.h" #include "log.h" -#include "macro.h" #include "process-util.h" #include "socket-util.h" #include "string-util.h" diff --git a/src/vmspawn/vmspawn-register.h b/src/vmspawn/vmspawn-register.h index c785b162ba..58cae542ce 100644 --- a/src/vmspawn/vmspawn-register.h +++ b/src/vmspawn/vmspawn-register.h @@ -1,9 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include - -#include "sd-bus.h" -#include "sd-id128.h" +#include "forward.h" int register_machine( sd_bus *bus, diff --git a/src/vmspawn/vmspawn-scope.c b/src/vmspawn/vmspawn-scope.c index 024efb53e1..624bd7730d 100644 --- a/src/vmspawn/vmspawn-scope.c +++ b/src/vmspawn/vmspawn-scope.c @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include - #include "sd-bus.h" #include "bus-error.h" @@ -11,13 +9,11 @@ #include "bus-wait-for-jobs.h" #include "escape.h" #include "log.h" -#include "macro.h" -#include "process-util.h" +#include "pidref.h" #include "random-util.h" #include "socket-util.h" +#include "string-util.h" #include "strv.h" -#include "unit-def.h" -#include "unit-name.h" #include "vmspawn-scope.h" int start_transient_scope(sd_bus *bus, const char *machine_name, bool allow_pidfd, char **ret_scope) { diff --git a/src/vmspawn/vmspawn-scope.h b/src/vmspawn/vmspawn-scope.h index 100de94fa1..c29325a314 100644 --- a/src/vmspawn/vmspawn-scope.h +++ b/src/vmspawn/vmspawn-scope.h @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "sd-bus.h" - -#include "macro.h" +#include "forward.h" typedef struct SocketServicePair { char **exec_start_pre; diff --git a/src/vmspawn/vmspawn-settings.h b/src/vmspawn/vmspawn-settings.h index 0902dbb245..1267dd0701 100644 --- a/src/vmspawn/vmspawn-settings.h +++ b/src/vmspawn/vmspawn-settings.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#include "macro.h" +#include "forward.h" typedef enum ConsoleMode { CONSOLE_INTERACTIVE, /* ptyfwd */ diff --git a/src/vmspawn/vmspawn-util.c b/src/vmspawn/vmspawn-util.c index 3fb8f8405b..1216f3c5be 100644 --- a/src/vmspawn/vmspawn-util.c +++ b/src/vmspawn/vmspawn-util.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include +#include #include #include @@ -10,20 +11,14 @@ #include "architecture.h" #include "conf-files.h" #include "errno-util.h" -#include "escape.h" #include "fd-util.h" -#include "fileio.h" +#include "hashmap.h" #include "json-util.h" #include "log.h" -#include "macro.h" -#include "memory-util.h" #include "path-lookup.h" #include "path-util.h" #include "random-util.h" -#include "recurse-dir.h" #include "siphash24.h" -#include "socket-util.h" -#include "sort-util.h" #include "string-table.h" #include "string-util.h" #include "strv.h" diff --git a/src/vmspawn/vmspawn-util.h b/src/vmspawn/vmspawn-util.h index ff1cffd13e..a8a69a9e50 100644 --- a/src/vmspawn/vmspawn-util.h +++ b/src/vmspawn/vmspawn-util.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "assert-util.h" -#include "memory-util.h" +#include "forward.h" #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__) # define ARCHITECTURE_SUPPORTS_SMBIOS 1 diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index 7c12b5e612..3f53f1f436 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -3,13 +3,13 @@ #include #include #include -#include #include #include #include #include #include +#include "sd-bus.h" #include "sd-daemon.h" #include "sd-event.h" #include "sd-id128.h" @@ -18,16 +18,14 @@ #include "architecture.h" #include "bootspec.h" #include "build.h" +#include "bus-error.h" #include "bus-internal.h" #include "bus-locator.h" #include "bus-util.h" #include "bus-wait-for-jobs.h" #include "capability-util.h" -#include "chase.h" #include "common-signal.h" #include "copy.h" -#include "creds-util.h" -#include "dirent-util.h" #include "discover-image.h" #include "dissect-image.h" #include "escape.h" @@ -35,18 +33,15 @@ #include "event-util.h" #include "extract-word.h" #include "fd-util.h" -#include "fileio.h" #include "format-util.h" #include "fs-util.h" #include "gpt.h" #include "hexdecoct.h" #include "hostname-setup.h" #include "hostname-util.h" -#include "io-util.h" -#include "kernel-image.h" +#include "id128-util.h" #include "log.h" #include "machine-credential.h" -#include "macro.h" #include "main-func.h" #include "mkdir.h" #include "namespace-util.h" @@ -66,15 +61,13 @@ #include "rm-rf.h" #include "signal-util.h" #include "socket-util.h" -#include "stat-util.h" #include "stdio-util.h" #include "string-util.h" #include "strv.h" #include "sync-util.h" -#include "time-util.h" +#include "terminal-util.h" #include "tmpfile-util.h" #include "unit-name.h" -#include "user-util.h" #include "utf8.h" #include "vmspawn-mount.h" #include "vmspawn-register.h"