]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic: Use _Static_assert() in missing_audit.h instead of assert_cc()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 23 Apr 2025 08:19:59 +0000 (10:19 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 23 Apr 2025 08:33:37 +0000 (10:33 +0200)
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.

src/basic/missing_audit.h

index e14599ebe674b5820958a1b6575628239ea0f6ca..3aaec1ee248181d6214509eaf204e41deb74a34d 100644 (file)
@@ -7,20 +7,25 @@
 #  include <libaudit.h>
 #endif
 
+/* We use _Static_assert() directly here instead of assert_cc()
+ * because if we include macro.h in this header, the invocation
+ * of generate-audit_type-list.sh becomes more complex.
+ */
+
 #ifndef AUDIT_SERVICE_START
 #  define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
 #else
-assert_cc(AUDIT_SERVICE_START == 1130);
+_Static_assert(AUDIT_SERVICE_START == 1130, "");
 #endif
 
 #ifndef AUDIT_SERVICE_STOP
 #  define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
 #else
-assert_cc(AUDIT_SERVICE_STOP == 1131);
+_Static_assert(AUDIT_SERVICE_STOP == 1131, "");
 #endif
 
 #ifndef MAX_AUDIT_MESSAGE_LENGTH
 #  define MAX_AUDIT_MESSAGE_LENGTH 8970
 #else
-assert_cc(MAX_AUDIT_MESSAGE_LENGTH == 8970);
+_Static_assert(MAX_AUDIT_MESSAGE_LENGTH == 8970, "");
 #endif