tree-wide: Make sure all headers are standalone

Let's make sure all of our headers include everything they require.
This commit is contained in:
Daan De Meyer
2025-04-23 10:33:38 +02:00
parent 44de729cdc
commit 401a22bfc1
81 changed files with 128 additions and 27 deletions
+1
View File
@@ -5,6 +5,7 @@
#include <sys/uio.h>
#include "macro.h"
#include "memory-util.h"
struct iovec_wrapper {
struct iovec *iovec;
+2
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdint.h>
/* This is currently not exported in the public kernel headers, but the libxfs library code part of xfsprogs
* defines it as public header */
+2
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdint.h>
/*
* For details about the file format see RFC:
* https://www.ietf.org/id/draft-tuexen-opsawg-pcapng-03.html
+1 -1
View File
@@ -3,7 +3,7 @@
#include <pthread.h>
#include "macro.h"
#include "assert-util.h"
static inline pthread_mutex_t* pthread_mutex_lock_assert(pthread_mutex_t *mutex) {
assert_se(pthread_mutex_lock(mutex) == 0);
+1
View File
@@ -4,6 +4,7 @@
#include <linux/reboot.h>
#include <sys/reboot.h>
#include <sys/syscall.h>
#include <unistd.h>
/* glibc defines the reboot() API call, which is a wrapper around the system call of the same name, but without the
* extra "arg" parameter. Since we need that parameter for some calls, let's add a "raw" wrapper that is defined the
+1 -1
View File
@@ -5,7 +5,7 @@
#include <stdint.h>
#include <sys/types.h>
#include "macro.h"
#include "memory-util.h"
struct strbuf {
char *buf;
+1
View File
@@ -4,6 +4,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "hashmap.h"
#include "macro.h"
#include "stdio-util.h"
#include "string-util.h"
+2
View File
@@ -4,6 +4,8 @@
#include <stdbool.h>
#include <sys/types.h>
#include "macro.h"
/* The container base should have the last 16 bit set to zero */
assert_cc((CONTAINER_UID_BASE_MIN & 0xFFFFU) == 0);
assert_cc((CONTAINER_UID_BASE_MAX & 0xFFFFU) == 0);
+1 -1
View File
@@ -4,7 +4,7 @@
#include <stdbool.h>
#include <sys/types.h>
#include "macro.h"
#include "memory-util.h"
typedef struct UIDRangeEntry {
uid_t start, nr;
+2
View File
@@ -1,4 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "efi.h"
char16_t *disk_get_url(EFI_HANDLE *handle);
+1 -1
View File
@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdio.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/types.h>
#include "fdset.h"
+2
View File
@@ -3,6 +3,8 @@
#include <stdbool.h>
#include "crash-handler.h"
extern bool arg_dump_core;
extern int arg_crash_chvt;
extern bool arg_crash_shell;
+1
View File
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdarg.h>
#include <stdbool.h>
#include "macro.h"
+2
View File
@@ -7,4 +7,6 @@
Nathaniel Chen <nathaniel.chen@intel.com>
***/
#include <stdbool.h>
int mac_smack_setup(bool *loaded_policy);
+1
View File
@@ -3,6 +3,7 @@
#include <sys/types.h>
#include "ask-password-api.h"
#include "cryptsetup-util.h"
#include "log.h"
#include "time-util.h"
@@ -1,6 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stddef.h>
struct crypt_device;
/* for more information see libcryptsetup.h crypt-tokens section */
const char* cryptsetup_token_version(void);
@@ -2,6 +2,8 @@
#pragma once
#include <stddef.h>
struct crypt_device;
int acquire_luks2_key(
+6
View File
@@ -1,7 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#if !SD_BOOT
#include <stdlib.h>
#include <sys/uio.h>
#endif
#include "assert-fundamental.h"
#include "macro-fundamental.h"
#if SD_BOOT
/* struct iovec is a POSIX userspace construct. Let's introduce it also in EFI mode, it's just so useful */
+1 -1
View File
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "bus-util.h"
#include "bus-object.h"
extern const BusObjectImplementation manager_object;
+1
View File
@@ -2,6 +2,7 @@
#pragma once
#include <stdbool.h>
#include <sys/types.h>
int home_mount_node(const char *node, const char *fstype, bool discard, unsigned long flags, const char *extra_mount_options);
int home_unshare_and_mkdir(void);
+1 -1
View File
@@ -4,7 +4,7 @@
#include "sd-event.h"
#include "import-compress.h"
#include "macro.h"
#include "memory-util.h"
typedef struct RawExport RawExport;
+1 -1
View File
@@ -4,7 +4,7 @@
#include "sd-event.h"
#include "import-compress.h"
#include "macro.h"
#include "memory-util.h"
typedef struct TarExport TarExport;
+2
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <errno.h>
#include <stdbool.h>
#include <sys/types.h>
#include "sd-event.h"
+1
View File
@@ -13,6 +13,7 @@
#include "import-common.h"
#include "import-compress.h"
#include "import-raw.h"
#include "import-util.h"
#include "install-file.h"
#include "io-util.h"
#include "log.h"
+1 -2
View File
@@ -4,8 +4,7 @@
#include "sd-event.h"
#include "import-common.h"
#include "import-util.h"
#include "macro.h"
#include "memory-util.h"
typedef struct RawImport RawImport;
+1
View File
@@ -13,6 +13,7 @@
#include "import-common.h"
#include "import-compress.h"
#include "import-tar.h"
#include "import-util.h"
#include "install-file.h"
#include "io-util.h"
#include "log.h"
+1 -2
View File
@@ -4,8 +4,7 @@
#include "sd-event.h"
#include "import-common.h"
#include "import-util.h"
#include "macro.h"
#include "memory-util.h"
typedef struct TarImport TarImport;
-1
View File
@@ -1,6 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <curl/curl.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
+1
View File
@@ -2,6 +2,7 @@
#pragma once
#include <curl/curl.h>
#include <inttypes.h>
#include "sd-event.h"
+1 -1
View File
@@ -4,7 +4,7 @@
#include <microhttpd.h>
#include <stdarg.h>
#include "macro.h"
#include "memory-util.h"
/* Those defines are added when options are renamed. If the old names
* are not '#define'd, then they are not deprecated yet and there are
+1
View File
@@ -2,6 +2,7 @@
#pragma once
#include <stdbool.h>
#include <stddef.h>
bool signature_is_single(const char *s, bool allow_dict_entry);
bool signature_is_pair(const char *s);
+2
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdbool.h>
#include "sd-bus.h"
void bus_socket_setup(sd_bus *b);
+2
View File
@@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct sd_bus_track sd_bus_track;
void bus_track_dispatch(sd_bus_track *track);
void bus_track_close(sd_bus_track *track);
+3 -1
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* This is meant to be included in other files, hence no headers */
#include <stdbool.h>
#include "sd-bus-vtable.h"
struct context {
bool quit;
+1
View File
@@ -6,6 +6,7 @@
#include <sys/stat.h>
#include "journal-def.h"
#include "memory-util.h"
typedef struct MMapCache MMapCache;
typedef struct MMapFileDescriptor MMapFileDescriptor;
+4
View File
@@ -2,8 +2,12 @@
#pragma once
#include <stdbool.h>
#include "sd-json.h"
#include "macro.h"
/* This header should include all prototypes only the JSON parser itself and
* its tests need access to. Normal code consuming the JSON parser should not
* interface with this. */
+4
View File
@@ -1,8 +1,12 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdbool.h>
#include "sd-netlink.h"
#include "netlink-internal.h"
int netlink_slot_allocate(
sd_netlink *nl,
bool floating,
+1 -1
View File
@@ -4,7 +4,7 @@
#include "sd-varlink.h"
#include "sd-varlink-idl.h"
#include "macro.h"
#include "memory-util.h"
int varlink_idl_parse(const char *text, unsigned *ret_line, unsigned *ret_column, sd_varlink_interface **ret);
sd_varlink_interface* varlink_interface_free(sd_varlink_interface *interface);
+1 -1
View File
@@ -3,7 +3,7 @@
#include "libudev.h"
#include "macro.h"
#include "memory-util.h"
struct udev_list;
+1
View File
@@ -2,6 +2,7 @@
#pragma once
#include <inttypes.h>
#include <net/ethernet.h>
#include "conf-parser.h"
#include "in-addr-util.h"
+2
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdbool.h>
typedef struct Address Address;
typedef struct Link Link;
+2
View File
@@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct Address Address;
void address_add_netlabel(const Address *address);
void address_del_netlabel(const Address *address);
+1
View File
@@ -17,6 +17,7 @@ typedef struct Link Link;
typedef struct Manager Manager;
typedef struct Network Network;
typedef struct NextHop NextHop;
typedef struct Request Request;
typedef int (*nexthop_netlink_handler_t)(
sd_netlink *rtnl,
sd_netlink_message *m,
+1
View File
@@ -15,6 +15,7 @@
#include "ndisc-option.h"
#include "networkd-util.h"
typedef struct Address Address;
typedef struct Link Link;
typedef struct Network Network;
+1
View File
@@ -5,6 +5,7 @@
#include <stdbool.h>
#include "conf-parser.h"
#include "in-addr-util.h"
typedef struct Link Link;
typedef struct Manager Manager;
+2
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdbool.h>
typedef struct Link Link;
typedef struct Manager Manager;
+1
View File
@@ -4,6 +4,7 @@
#include <inttypes.h>
#include "sd-device.h"
#include "sd-netlink.h"
#include "macro.h"
+2
View File
@@ -2,6 +2,8 @@
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <sys/types.h>
#include "volatile-util.h"
+1 -1
View File
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <sys/types.h>
#include <stdint.h>
int setup_seccomp(uint64_t cap_list_retain, char **syscall_allow_list, char **syscall_deny_list);
+3
View File
@@ -1,5 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdbool.h>
#include <sys/types.h>
int change_uid_gid_raw(uid_t uid, gid_t gid, const gid_t *supplementary_gids, size_t n_supplementary_gids, bool chown_stdio);
int change_uid_gid(const char *user, bool chown_stdio, char **ret_home);
+1 -1
View File
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "macro.h"
#include "memory-util.h"
#define USER_NAMESPACE_CGROUPS_DELEGATE_MAX 16U
#define USER_NAMESPACE_NETIFS_DELEGATE_MAX 16U
+2
View File
@@ -3,6 +3,8 @@
#include <stdbool.h>
#include "assert-util.h"
int _nss_systemd_block(bool b);
bool _nss_systemd_is_blocked(void);
+1 -1
View File
@@ -3,7 +3,7 @@
#include <openssl/asn1t.h>
#include "macro.h"
#include "memory-util.h"
#define SPC_INDIRECT_DATA_OBJID "1.3.6.1.4.1.311.2.1.4"
#define SPC_PE_IMAGE_DATA_OBJID "1.3.6.1.4.1.311.2.1.15"
+2
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <bpf/libbpf.h>
/* libbpf has been moving quickly.
* They added new symbols in the 0.x versions and shortly after removed
* deprecated symbols in 1.0.
+1 -1
View File
@@ -3,7 +3,7 @@
#include <sched.h>
#include "macro.h"
#include "memory-util.h"
#include "missing_syscall.h"
/* This wraps the libc interface with a variable to keep the allocated size. */
+1
View File
@@ -3,6 +3,7 @@
#include <sys/types.h>
#include "ask-password-api.h"
#include "cryptsetup-util.h"
#include "libfido2-util.h"
#include "log.h"
+1
View File
@@ -2,6 +2,7 @@
#pragma once
#include <stdbool.h>
#include <stddef.h>
#define DROPIN_MARKER_START "### Anything between here and the comment below will become the contents of the drop-in file"
#define DROPIN_MARKER_END "### Edits below this comment will be discarded"
+1 -1
View File
@@ -7,7 +7,7 @@
#include "sd-id128.h"
#include "macro.h"
#include "memory-util.h"
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_context*, fdisk_unref_context, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_partition*, fdisk_unref_partition, NULL);
+3
View File
@@ -2,8 +2,11 @@
#pragma once
#include <linux/fiemap.h>
#include <stdint.h>
#include <sys/types.h>
#include "assert-util.h"
/* represents values for /sys/power/resume & /sys/power/resume_offset and the corresponding path */
typedef struct HibernationDevice {
dev_t devno;
+3
View File
@@ -1,9 +1,12 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include "macro.h"
typedef enum HostnameSource {
HOSTNAME_STATIC, /* from /etc/hostname */
HOSTNAME_TRANSIENT, /* a transient hostname set through systemd, hostnamed, the container manager, or otherwise */
+1
View File
@@ -2,6 +2,7 @@
#pragma once
#include <errno.h>
#include <stdbool.h>
#include "sd-id128.h"
+1
View File
@@ -2,6 +2,7 @@
#pragma once
#include <stdbool.h>
#include <stddef.h>
int make_salt(char **ret);
int hash_password_full(const char *password, void **cd_data, int *cd_size, char **ret);
+1 -1
View File
@@ -5,7 +5,7 @@
#include "sd-device.h"
#include "macro.h"
#include "memory-util.h"
#include "time-util.h"
typedef struct LoopDevice LoopDevice;
+1
View File
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdbool.h>
#include <sys/types.h>
typedef struct MachineCredential {
+2
View File
@@ -3,6 +3,8 @@
#include <stdbool.h>
#include "sd-id128.h"
typedef enum MachineIdSetupFlags {
MACHINE_ID_SETUP_FORCE_TRANSIENT = 1 << 0,
MACHINE_ID_SETUP_FORCE_FIRMWARE = 1 << 1,
+1
View File
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include "sd-bus.h"
+3
View File
@@ -1,8 +1,11 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <errno.h>
#include <linux/if_link.h>
#include "macro.h"
typedef enum MacVlanMode {
NETDEV_MACVLAN_MODE_PRIVATE = MACVLAN_MODE_PRIVATE,
NETDEV_MACVLAN_MODE_VEPA = MACVLAN_MODE_VEPA,
+1
View File
@@ -4,6 +4,7 @@
#include <linux/if_link.h>
#include "sd-device.h"
#include "sd-netlink.h"
#include "conf-parser.h"
#include "ether-addr-util.h"
+2
View File
@@ -2,7 +2,9 @@
#pragma once
#include <security/pam_modules.h>
#include <syslog.h>
#include "macro.h"
#include "sd-bus.h"
void pam_log_setup(void);
@@ -9,6 +9,7 @@
#include <pwquality.h>
#include "dlfcn-util.h"
#include "memory-util.h"
extern DLSYM_PROTOTYPE(pwquality_check);
extern DLSYM_PROTOTYPE(pwquality_default_settings);
+1 -1
View File
@@ -15,7 +15,7 @@
#include "ask-password-api.h"
#include "dlfcn-util.h"
#include "log.h"
#include "macro.h"
#include "memory-util.h"
#include "time-util.h"
bool pkcs11_uri_valid(const char *uri);
+1 -1
View File
@@ -5,7 +5,7 @@
#include "sd-event.h"
#include "macro.h"
#include "memory-util.h"
typedef struct PTYForward PTYForward;
+2 -2
View File
@@ -1,9 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdbool.h>
#include <errno.h>
#include <linux/securebits.h>
#include <stdbool.h>
int secure_bits_to_string_alloc(int i, char **s);
int secure_bits_from_string(const char *s);
+2
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <errno.h>
typedef enum VolatileMode {
VOLATILE_NO,
VOLATILE_YES,
+1
View File
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <sys/stat.h>
#include <sys/types.h>
#include "architecture.h"
+2
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "time-util.h"
int verb_list_units(int argc, char *argv[], void *userdata);
int verb_list_sockets(int argc, char *argv[], void *userdata);
int verb_list_timers(int argc, char *argv[], void *userdata);
+1
View File
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "macro.h"
#include "sparse-endian.h"
/* NTP protocol, packet header */
+1
View File
@@ -4,6 +4,7 @@
/* Copyright (C) IBM Corp. 2003 */
#include <scsi/scsi.h>
#include <sys/types.h>
struct scsi_ioctl_command {
unsigned inlen; /* excluding scsi command length */
+1
View File
@@ -3,6 +3,7 @@
#include "sd-device.h"
#include "time-util.h"
#include "udev-def.h"
int find_device(const char *id, const char *prefix, sd_device **ret);
+2
View File
@@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdbool.h>
#include "sd-bus.h"
#include "sd-id128.h"
+3 -1
View File
@@ -2,7 +2,9 @@
#pragma once
#include <stdbool.h>
#include "macro.h"
#include "assert-util.h"
#include "memory-util.h"
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
# define ARCHITECTURE_SUPPORTS_SMBIOS 1