Commit Graph
81002 Commits
Author SHA1 Message Date
Daan De Meyer d06abcf68e meson: Implement duplicate includes check with clang-tidy
Instead of doing this with our own script, let's use clang-tidy
instead.
2025-04-24 12:36:38 +02:00
Daan De Meyer 5008a92469 network: Remove duplicate include 2025-04-24 12:36:38 +02:00
Daan De Meyer 44e86153d1 meson: Define our own clang-tidy target
meson's target has a few issues:
- Runs on all source files regardless if they're included in the
  build or not
- Doesn't have any dependencies on generated sources which means we
  have to do a full build first before we can run clang-tidy
- Doesn't allow us to pass any extra arguments

To work around these, let's define our own clang-tidy target instead
using llvm's run-clang-tidy script. Alongside the clang-tidy target,
let's start keeping track of all generated sources which we make the
clang-tidy target depend on. We also add a new target which will only
generate source files which is useful for setting up the source tree
for running code analysis against it.
2025-04-24 12:36:36 +02:00
Yu Watanabe 10594762c7 Remove unused code and fix one bug (#37225) 2025-04-24 12:28:48 +09:00
Daan De Meyer bcf716ca01 tree-wide: Remove dead code
This code seems to not be used anywhere at all, so let's drop it.

Follow up for ba8d00e859
Follow up for 85686b37b0
Follow up for aff853f8ea
Follow up for 36dad381a2
2025-04-24 10:15:19 +09:00
Daan De Meyer 8621c646b8 core: Use parse_syscall_archs() in bus_exec_context_set_transient_property() 2025-04-24 10:15:19 +09:00
Daan De Meyer 058d680625 network: Fix wrong config parser for Bridge.MulticastIGMPVersion
Follow up for afa51e2dfb
2025-04-24 10:14:57 +09:00
Nick Labich 5d49aec4c1 repart: Allow devices as sources for --copy-from
Implements #37208
2025-04-24 09:33:51 +09:00
Yu Watanabe a31777df99 udev: support soft-reboot (#37222) 2025-04-24 09:31:56 +09:00
Daan De Meyer bde994efcc mkosi: Run clangd within the tools tree instead of the build container
Running within the build sandbox has a number of disadvantages:
- We have a separate clangd cache for each distribution/release combo
- It requires to build the full image before clangd can be used
- It breaks every time the image becomes out of date and requires a
  rebuild
- We can't look at system headers as we don't have the knowledge to map
  them from inside the build sandbox to the corresponding path on the host

Instead, let's have mkosi.clangd run clangd within the tools tree. We
already require building systemd for both the host and the target anyway,
and all the dependencies to build systemd are installed in the tools tree
already for that, as well as clangd since it's installed together with the
other clang tooling we install in the tools tree. Unlike the previous approach,
this approach only requires the mkosi tools tree to be built upfront, which has
a much higher chance of not invalidating its cache. We can also trivially map
system header lookups from within the sandbox to the path within mkosi.tools
on the host so that starts working as well.
2025-04-23 21:04:07 +02:00
Daan De Meyer cfe8f3ec74 Add clang-tidy check in CI (#37226)
This will make sure we keep our headers standalone and don't introduce
any new cyclic header dependencies
2025-04-23 16:43:17 +02:00
Daan De Meyer 9b5895be12 ci: Add basic clang-tidy check to linter workflow
Let's add a basic clang-tidy check to the linter workflow. This
gives us the following:
- A check so that we don't introduce any new cyclic header dependencies
- A check to make sure all of our header files are standalone, as clang-tidy
  will fail to parse header files that don't include all their dependencies.
2025-04-23 16:13:58 +02:00
Daan De Meyer 50810ff7b8 Various logging improvements and cleanups (#37040) 2025-04-23 15:31:44 +02:00
Daan De Meyer 9e3d048bd0 ci: Use mkosi in linter workflow
Let's reuse the mkosi tools tree to get all the tools we need instead
of pulling them from pypi.
2025-04-23 15:27:49 +02:00
Daan De Meyer 98a8117eb9 Add .clangd configuration file that disables the unused include check
The clangd include checker is rather broken and is littered with false
positives in our codebase, so let's disable the feature until it improves
a bit.
2025-04-23 15:27:49 +02:00
Daan De Meyer 44d50ba88e execute: Get rid of custom logging macros
We already have LOG_CONTEXT_PUSH_EXEC() which with two additions
does exactly the same as the custom logging macros, so let's get rid
of the custom logging macros and use LOG_CONTEXT_PUSH_EXEC() instead.
2025-04-23 14:48:45 +02:00
Daan De Meyer a94d0e3177 timedate: Drop custom logging macros in favor of log context
Additionally, using the log context makes sure the extra fields are
applied to all log messages generated while the context is in place,
rather than only log messages logged with log_unit_xxx() in timedated
itself.

It also means the unit name is prefixed to all log messages logged
within that context. While it's not clear whether we always want the
unit name to be attached to library log messages, we also don't want
the unit name to not be attached to any library log messages, so we opt
to add more rather than less information by adding the unit name everywhere
for now.

In the future we can look into some log.h helpers to enable/disable
adding the prefix to the following log messages or not.
2025-04-23 14:46:46 +02:00
Daan De Meyer ba77798bba unit: Make sure individual unit maximum log level always takes priority
Currently LogLevelMax= can only be used to decrease the maximum log level
for a unit but not to increase it. Let's make sure the latter works as
well, so LogLevelMax=debug can be used to enable debug logging for specific
units without enabling debug logging globally.
2025-04-23 14:46:12 +02:00
Daan De Meyer 6d47c16ce0 log: Make sure LOG_CONTEXT_SET_LOG_LEVEL() can be nested 2025-04-23 14:46:12 +02:00
cvlc12 05f2d9c080 homectl: Use 'user_subvol_rm_allowed' for btrfs by default. 2025-04-23 14:45:18 +02:00
Daan De Meyer b5bea81b74 Various fixes to streamline running code analysis tools such as clang-tidy (#37224) 2025-04-23 14:34:52 +02:00
Daan De Meyer d55c896907 core: Merge forward declaration and definition of DynamicUser 2025-04-23 13:48:48 +02:00
Daan De Meyer e3a70ca482 core: Drop unused forward declaration
We already include unit.h.
2025-04-23 13:48:48 +02:00
Daan De Meyer d25c238f97 basic: Move various macros from assert-util.h to assert-fundamental.h
ASSERT_PTR() and friends in assert-fundamental.h make use of assert()
and assert_se() which when not building for sd-boot are defined in
assert-util.h. Because assert() from glibc is only overridden in
assert-util.h, the macros in assert-fundamental.h still end up using
the glibc assert.

Let's fix this by moving the required macros and related logic to
assert-fundamental.h.
2025-04-23 13:48:48 +02:00
Daan De Meyer 5332be60d3 tree-wide: Use assert_se() instead of assert() in various places
assert() is compiled away if NDEBUG is set which causes an unused
variable warning in various places when the next commit is applied
so let's use assert_se() to avoid these warnings.
2025-04-23 13:48:16 +02:00
Daan De Meyer a843382d1e journal: Always compile journal authentication related files
Tooling such as clang-tidy is bad at dealing with condition
compilation on the build system level instead of at the source file
level. What happens? It still tries to analyze the file and fails
horribly if the required headers aren't available. Let's work around
the issue and make things more consistent at the same time by doing
the necessary HAVE_GCRYPT checks inside of the source files instead
of doing them at the build system level.

We also add some typedefs to allow getting rid of various HAVE_GCRYPT
checks.
2025-04-23 11:50:33 +02:00
Daan De Meyer 84104ad613 libsystemd: Skip _sd-common.h include check when __clang_analyzer__ is defined
This check doesn't work properly when tools such as clang-tidy are
analyzing headers. Since we don't care about the check in that case,
skip it if __clang_analyzer__ is defined similar to how we skip it as
well if __COVERITY__ is defined.
2025-04-23 11:50:32 +02:00
Daan De Meyer ed2506d1d0 boot: Make free() a non inline function
The static inline declaration in iovec-fundamental.h causes static
analyze tooling warnings (clang-tidy). Let's get around it by making
free() non-inline. LTO will make sure it's still inlined properly.
2025-04-23 11:50:32 +02:00
Daan De Meyer c0ced8fc32 Remove more circular header dependencies (#37185)
Continuation of https://github.com/systemd/systemd/pull/37112
2025-04-23 11:24:02 +02:00
Daan De Meyer 401a22bfc1 tree-wide: Make sure all headers are standalone
Let's make sure all of our headers include everything they require.
2025-04-23 10:33:38 +02:00
Daan De Meyer 44de729cdc basic: Use _Static_assert() in missing_audit.h instead of assert_cc()
We want to make the header standalone so it includes all the stuff it
needs. However, including macro.h for assert_cc() doesn't work because
of generate-audit_type-list.sh which would have to become more complex
to handle the extra include directories.

Instead, let's just use _Static_assert() directly which is a builtin and
doesn't need any extra includes.
2025-04-23 10:33:37 +02:00
Daan De Meyer f82e233128 timesync: Remove circular header dependencies 2025-04-23 10:33:37 +02:00
Daan De Meyer cf108818b3 sysupdate: Remove circular header includes 2025-04-23 10:33:37 +02:00
Daan De Meyer 68527d3051 resolved: Remove circular header dependencies 2025-04-23 10:33:37 +02:00
Daan De Meyer 834dc38310 resolve: Move implementations of some functions to resolved-dns-packet.c
These depend on a full definition of DnsResourceRecord which we want
to forward declare in the next commit, so let's move the implementation
of these functions to the implementation file and make them lowercase.
2025-04-23 10:33:37 +02:00
Daan De Meyer 6f502df478 resolve: Move two functions from resolved-conf.h to resolved-dns-server.h
Preparation for getting rid of circular header dependencies.
2025-04-23 10:33:37 +02:00
Daan De Meyer 1fe208e60a portable: Remove circular header dependencies 2025-04-23 10:33:37 +02:00
Daan De Meyer 5d5eb76557 network: Remove circular header dependencies in network/netdev 2025-04-23 10:33:37 +02:00
Daan De Meyer 72673948f3 network: Remove circular header dependencies in network/tc
Include the headers in the implementation file (and the gperf file)
instead of in the qdisc.h header. I opted to keep them separate from
the other headers since they're slightly different than regular headers.
2025-04-23 10:33:37 +02:00
Daan De Meyer 02d83a8a1e network: Move networkd-manager.h include to implementation file 2025-04-23 10:33:37 +02:00
Daan De Meyer ff43267ce7 machine: Remove circular header dependencies 2025-04-23 10:33:37 +02:00
Daan De Meyer 214c93c84c login: Remove circular header dependencies 2025-04-23 10:33:37 +02:00
Daan De Meyer d88dc9a5dd journal: Remove circular header dependencies 2025-04-23 10:33:37 +02:00
Daan De Meyer f31e462ba7 import: Remove circular header dependencies 2025-04-23 10:33:37 +02:00
Daan De Meyer 52ee9ba13d home: Remove circular header dependencies 2025-04-23 10:33:37 +02:00
Daan De Meyer 4ea4abb651 core: Remove circular dependencies between headers
Currently there are various circular dependencies between headers
in core/. Let's get rid of these by making judicious use of forward
declarations and moving includes into implementation files instead of
having them in header files.

Getting rid of circular header includes simplifies the code and makes
various clang based tooling such as iwyu work much better on our code.

The most important change is getting rid of the manager.h include in
unit.h which is possible thanks to the previous commits. We also move
the OOMPolicy and StatusType enums to unit.h to remove the need for
other unit headers to include manager.h to get access to these enums.
2025-04-23 10:33:35 +02:00
Daan De Meyer 64fd6ba9ca core: Turn manager unit log fields into unit functions
There's no need for these to be fields inside the manager struct,
let's turn them into functions in unit.h instead, again to allow
forward declaring the Manager struct in a later commit.
2025-04-23 09:53:53 +02:00
Daan De Meyer 8aa304d313 shared: Remove circular dependency between image-policy.h and dissect-image.h
ImagePolicy can just be a forward declaration in dissect-image.h.
2025-04-23 09:53:43 +02:00
Daan De Meyer 36642d0304 sd-bus: Get rid of circular dependency between sd-bus.h and sd-bus-vtable.h
Let's move more types to sd-bus-protocol.h so we can get rid of the
circular include between sd-bus-vtable.h and sd-bus.h.
2025-04-23 09:53:28 +02:00
Yu Watanabe b7591658f0 man,network: fix typo
Follow-up for a06e884264.
2025-04-23 13:42:12 +09:00