From: Daan De Meyer Date: Tue, 6 May 2025 13:39:03 +0000 (+0200) Subject: basic: Override glibc's sys/param.h header with an empty file X-Git-Tag: v258-rc1~656^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b58245624a7c23cc9810854e2d5e368af611bb7;p=thirdparty%2Fsystemd.git basic: Override glibc's sys/param.h header with an empty file Instead of unconditionally including sys/param.h in macro-fundamental.h which itself includes a bunch of other unnecessary headers, let's override it with an empty file to avoid it from overriding our MAX() macro. We can't make including it an error as it's included ( for seemingly no good reason) by . --- diff --git a/src/basic/include/sys/param.h b/src/basic/include/sys/param.h new file mode 100644 index 00000000000..88cc47edf4f --- /dev/null +++ b/src/basic/include/sys/param.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +/* sys/param.h from glibc unconditionally overrides the MIN() and MAX() macros which interferes with our own + * MAX() macro. It also includes a bunch of other headers transitively so we don't want to include + * sys/param.h in macro-fundamental.h unconditionally. We'd like to make including this file an error but + * unfortunately includes it. However, doesn't actually make use of anything from + * sys/param.h, so we override it with an empty file so it can't mess with our macros. */ diff --git a/src/basic/macro.h b/src/basic/macro.h index cf1c1a46175..9cee1868a5c 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -5,7 +5,6 @@ #include #include #include -#include #include #include diff --git a/src/basic/pidref.h b/src/basic/pidref.h index 064b9d851a9..59a4e392042 100644 --- a/src/basic/pidref.h +++ b/src/basic/pidref.h @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include + #include "macro.h" #include "memory-util.h" diff --git a/src/core/ipe-setup.c b/src/core/ipe-setup.c index 5cc8b9bcccf..392c9187e5e 100644 --- a/src/core/ipe-setup.c +++ b/src/core/ipe-setup.c @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #include "alloc-util.h" #include "conf-files.h" #include "copy.h" diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index 28fef06c993..597228f1395 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -7,13 +7,6 @@ #include #include -/* This header unconditionally defines MAX() so include it here already so - * it won't override our own definition of MAX() that we define later in this - * file. */ -#if !SD_BOOT -#include -#endif - /* Temporarily disable some warnings */ #define DISABLE_WARNING_DEPRECATED_DECLARATIONS \ _Pragma("GCC diagnostic push"); \ diff --git a/src/libsystemd/sd-journal/lookup3.c b/src/libsystemd/sd-journal/lookup3.c index 8e3dac05afa..a2015a74282 100644 --- a/src/libsystemd/sd-journal/lookup3.c +++ b/src/libsystemd/sd-journal/lookup3.c @@ -47,13 +47,10 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy. */ /* #define SELF_TEST 1 */ +#include /* attempt to define endianness */ #include /* defines uint32_t etc */ #include /* defines printf for tests */ -#include /* attempt to define endianness */ #include /* defines time_t for timings in the test */ -#ifdef linux -# include /* attempt to define endianness */ -#endif _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") diff --git a/src/network/test-network.c b/src/network/test-network.c index 89dd98f560e..b98b9ecfb54 100644 --- a/src/network/test-network.c +++ b/src/network/test-network.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include #include "sd-device.h" diff --git a/src/shared/initreq.h b/src/shared/initreq.h index c6a10508059..205a3be44a3 100644 --- a/src/shared/initreq.h +++ b/src/shared/initreq.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #if defined(__FreeBSD_kernel__) # define INIT_FIFO "/etc/.initctl" @@ -25,13 +25,6 @@ #define INIT_CMD_UNSETENV 7 #define INIT_CMD_CHANGECONS 12345 - -#ifdef MAXHOSTNAMELEN -# define INITRQ_HLEN MAXHOSTNAMELEN -#else -# define INITRQ_HLEN 64 -#endif - /* * This is what BSD 4.4 uses when talking to init. * Linux doesn't use this right now. @@ -39,7 +32,7 @@ struct init_request_bsd { char gen_id[8]; /* Beats me.. telnetd uses "fe" */ char tty_id[16]; /* Tty name minus /dev/tty */ - char host[INITRQ_HLEN]; /* Hostname */ + char host[HOST_NAME_MAX]; /* Hostname */ char term_type[16]; /* Terminal type */ int signal; /* Signal to send */ int pid; /* Process to send to */