]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic: Override glibc's sys/param.h header with an empty file
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 6 May 2025 13:39:03 +0000 (15:39 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 9 May 2025 09:23:14 +0000 (11:23 +0200)
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 <resolv.h>.

src/basic/include/sys/param.h [new file with mode: 0644]
src/basic/macro.h
src/basic/pidref.h
src/core/ipe-setup.c
src/fundamental/macro-fundamental.h
src/libsystemd/sd-journal/lookup3.c
src/network/test-network.c
src/shared/initreq.h

diff --git a/src/basic/include/sys/param.h b/src/basic/include/sys/param.h
new file mode 100644 (file)
index 0000000..88cc47e
--- /dev/null
@@ -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 <resolv.h> includes it. However, <resolv.h> 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. */
index cf1c1a46175bbea40b6a96e126cd14ea91cb94c7..9cee1868a5c12860c8ec728aac40719e478bf34c 100644 (file)
@@ -5,7 +5,6 @@
 #include <errno.h>
 #include <inttypes.h>
 #include <stdbool.h>
-#include <sys/param.h>
 #include <sys/sysmacros.h>
 #include <sys/types.h>
 
index 064b9d851a95367cf48918a76a8344b5f43b2742..59a4e3920420d822852f872266f953d137a8f160 100644 (file)
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include <signal.h>
+
 #include "macro.h"
 #include "memory-util.h"
 
index 5cc8b9bcccfa64d3bfc9ca15c4d21562031f2dad..392c9187e5e1e39b02a28732bb97e1e135239494 100644 (file)
@@ -1,5 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include <unistd.h>
+
 #include "alloc-util.h"
 #include "conf-files.h"
 #include "copy.h"
index 28fef06c9933bfbfdd09d9933af406959905d6ab..597228f13954e08cca8b1f77f6b769f9cd1cf086 100644 (file)
@@ -7,13 +7,6 @@
 #include <stddef.h>
 #include <stdint.h>
 
-/* 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 <sys/param.h>
-#endif
-
 /* Temporarily disable some warnings */
 #define DISABLE_WARNING_DEPRECATED_DECLARATIONS                         \
         _Pragma("GCC diagnostic push");                                 \
index 8e3dac05afaed219d26d34fc70874295b2b85de4..a2015a742821296ce6eba08f088839008ec340c8 100644 (file)
@@ -47,13 +47,10 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
 */
 /* #define SELF_TEST 1 */
 
+#include <endian.h>    /* attempt to define endianness */
 #include <stdint.h>     /* defines uint32_t etc */
 #include <stdio.h>      /* defines printf for tests */
-#include <sys/param.h>  /* attempt to define endianness */
 #include <time.h>       /* defines time_t for timings in the test */
-#ifdef linux
-# include <endian.h>    /* attempt to define endianness */
-#endif
 
 _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
 
index 89dd98f560e8a5f2bda2c80ce0dc547a0632e06c..b98b9ecfb543c0cceebc63da26bcb29a119be67f 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <arpa/inet.h>
-#include <sys/param.h>
 
 #include "sd-device.h"
 
index c6a105080592a745afe108f9bb887267a91e4b2e..205a3be44a3f96c1f9313b85c5d2d81f1140caa6 100644 (file)
@@ -6,7 +6,7 @@
 
 #pragma once
 
-#include <sys/param.h>
+#include <limits.h>
 
 #if defined(__FreeBSD_kernel__)
 #  define INIT_FIFO  "/etc/.initctl"
 #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           */