]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fundamental: Always use _Static_assert for assert_cc()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 18 Apr 2025 09:50:18 +0000 (11:50 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 18 Apr 2025 12:19:13 +0000 (14:19 +0200)
Let's get rid of the assert.h include in macro-fundamental.h by always
using the builtin. Behavior is unchanged.

src/fundamental/macro-fundamental.h

index 585bacaf821f31d2035647c0d5bd184dd0e3c943..cab8368c87123d289874b6e2a6ba77f13c9fc406 100644 (file)
@@ -1,16 +1,19 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#if !SD_BOOT
-#  include <assert.h>
-#endif
-
 #include <limits.h>
 #include <stdalign.h>
 #include <stdbool.h>
 #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");                                 \
 #define XCONCATENATE(x, y) x ## y
 #define CONCATENATE(x, y) XCONCATENATE(x, y)
 
-#if SD_BOOT
-        #define static_assert _Static_assert
-#endif
-
-#define assert_cc(expr) static_assert(expr, #expr)
+#define assert_cc(expr) _Static_assert(expr, #expr)
 
 #define UNIQ_T(x, uniq) CONCATENATE(__unique_prefix_, CONCATENATE(x, uniq))
 #define UNIQ __COUNTER__