Skip to content

Commit b8fd3f7

Browse files
authored
Various changes made as part of trying to run include-what-you-use on the systemd repository (systemd#37112)
I have been trying to run https://github.com/include-what-you-use/include-what-you-use on the systemd repository to hopefully get a handle on the rampant numbers of includes we have in every file with no idea if any of the symbols coming from that file are used or not. While I haven't got it fully working yet, these changes still make sense IMO and can be merged already. Except the last commit, all other changes are about removing circular dependencies between headers which trips up include-what-you-use. Regardless of the tool, circular dependencies between headers are a code smell and I think we should get rid of them regardless of whether we end up using the tool or not.
2 parents defd506 + 44c2c9a commit b8fd3f7

File tree

488 files changed

+1230
-790
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

488 files changed

+1230
-790
lines changed

LICENSES/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ The following exceptions apply:
3232
* some sources under src/udev/ are licensed under **GPL-2.0-or-later**,
3333
so all udev programs (`systemd-udevd`, `udevadm`, and the udev builtins
3434
and test programs) are also distributed under **GPL-2.0-or-later**.
35-
* the header files contained in src/basic/linux/ and src/shared/linux/ are copied
35+
* the header files contained in src/basic/include/linux are copied
3636
verbatim from the Linux kernel source tree and are licensed under **GPL-2.0 WITH
3737
Linux-syscall-note** and are used within the scope of the Linux-syscall-note
3838
exception provisions
3939
* the following sources are licensed under the **LGPL-2.0-or-later** license:
4040
- src/basic/utf8.c
4141
- src/shared/initreq.h
42-
* the src/shared/linux/bpf_insn.h header is copied from the Linux kernel
42+
* the src/basic/include/linux/bpf_insn.h header is copied from the Linux kernel
4343
source tree and is licensed under either **BSD-2-Clause** or **GPL-2.0-only**,
4444
and thus is included in the systemd build under the BSD-2-Clause license.
45-
* The src/basic/linux/wireguard.h header is copied from the Linux kernel
45+
* The src/basic/include/linux/wireguard.h header is copied from the Linux kernel
4646
source tree and is licensed under either **MIT** or **GPL-2.0 WITH Linux-syscall-note**,
4747
and thus is included in the systemd build under the MIT license.
4848
* the following sources are licensed under the **MIT** license (in case of our
4949
scripts, to facilitate copying and reuse of those helpers to other projects):
5050
- hwdb.d/parse_hwdb.py
51-
- src/basic/linux/batman_adv.h
51+
- src/basic/include/linux/batman_adv.h
5252
- src/basic/sparse-endian.h
5353
- tools/catalog-report.py
5454
* the following sources are licensed under the **CC0-1.0** license:

coccinelle/run-coccinelle.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ set -e
55
# Exclude following paths from the Coccinelle transformations
66
EXCLUDED_PATHS=(
77
"src/boot/efi/*"
8-
"src/shared/linux/*"
9-
"src/basic/linux/*"
8+
"src/basic/include/linux/*"
109
# Symlinked to test-bus-vtable-cc.cc, which causes issues with the IN_SET macro
1110
"src/libsystemd/sd-bus/test-bus-vtable.c"
1211
"src/libsystemd/sd-journal/lookup3.c"

meson.build

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,11 +2053,18 @@ boot_stubs = []
20532053

20542054
build_dir_include = include_directories('.')
20552055

2056-
basic_includes = include_directories(
2057-
'src/basic',
2058-
'src/fundamental',
2059-
'src/systemd',
2060-
'.')
2056+
basic_includes = [
2057+
include_directories(
2058+
'src/basic',
2059+
'src/fundamental',
2060+
'src/systemd',
2061+
'.',
2062+
),
2063+
include_directories(
2064+
'src/basic/include',
2065+
is_system : true,
2066+
),
2067+
]
20612068

20622069
libsystemd_includes = [basic_includes, include_directories(
20632070
'src/libsystemd/sd-bus',

src/ac-power/ac-power.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "ansi-color.h"
66
#include "battery-util.h"
77
#include "build.h"
8+
#include "log.h"
89
#include "main-func.h"
910
#include "pretty-print.h"
1011

src/analyze/analyze-compare-versions.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "analyze-compare-versions.h"
66
#include "compare-operator.h"
7+
#include "log.h"
78
#include "macro.h"
89
#include "string-util.h"
910
#include "strv.h"

src/analyze/analyze-time-data.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "sd-bus.h"
55

6+
#include "memory-util.h"
67
#include "time-util.h"
78
#include "unit-def.h"
89

src/basic/alloc-util.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include "alloc-util.h"
88
#include "macro.h"
9-
#include "memory-util.h"
109

1110
void* memdup(const void *p, size_t l) {
1211
void *ret;

src/basic/alloc-util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include <stdlib.h>
88
#include <string.h>
99

10+
#include "assert-util.h"
1011
#include "macro.h"
12+
#include "memory-util.h"
1113

1214
#if HAS_FEATURE_MEMORY_SANITIZER
1315
# include <sanitizer/msan_interface.h>
@@ -266,5 +268,3 @@ _alloc_(2) static inline void *realloc0(void *p, size_t new_size) {
266268

267269
return q;
268270
}
269-
270-
#include "memory-util.h"

src/basic/argv-util.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "argv-util.h"
99
#include "capability-util.h"
1010
#include "errno-util.h"
11+
#include "log.h"
1112
#include "missing_sched.h"
1213
#include "parse-util.h"
1314
#include "path-util.h"

src/basic/argv-util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <stdbool.h>
55

6+
#include "assert-util.h"
67
#include "macro.h"
78

89
extern int saved_argc;

0 commit comments

Comments
 (0)