summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-10-02 13:37:39 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2022-10-02 13:47:56 -0700
commit5598886adc9f7bc83ba9775151f839d4691128e4 (patch)
tree968bc775052aabc4485fe988b4d8b42991b88e1f /lib-src
parent3cc1706c63fde2e5a6313537817db2d32e829b6a (diff)
downloademacs-5598886adc9f7bc83ba9775151f839d4691128e4.tar.gz
Prefer static_assert to verify in seccomp-filter
Prefer static_assert in just one file for now; the idea is to do it elsewhere eventually. static_assert is standard (starting with C23) whereas verify is not, and static_assert can be used even in pre-C23 files due to Gnulib’s support for it. * lib-src/seccomp-filter.c: Do not include verify.h. Prefer static_assert to verify.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/seccomp-filter.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c
index 4bd2816dfc5..061af9dc072 100644
--- a/lib-src/seccomp-filter.c
+++ b/lib-src/seccomp-filter.c
@@ -59,7 +59,6 @@ variants of those files that can be used to sandbox Emacs before
#include <unistd.h>
#include <attribute.h>
-#include <verify.h>
#ifndef ARCH_CET_STATUS
#define ARCH_CET_STATUS 0x3001
@@ -167,12 +166,12 @@ main (int argc, char **argv)
set_attribute (SCMP_FLTATR_CTL_NNP, 1);
set_attribute (SCMP_FLTATR_CTL_TSYNC, 1);
- verify (CHAR_BIT == 8);
- verify (sizeof (int) == 4 && INT_MIN == INT32_MIN
- && INT_MAX == INT32_MAX);
- verify (sizeof (long) == 8 && LONG_MIN == INT64_MIN
- && LONG_MAX == INT64_MAX);
- verify (sizeof (void *) == 8);
+ static_assert (CHAR_BIT == 8);
+ static_assert (sizeof (int) == 4 && INT_MIN == INT32_MIN
+ && INT_MAX == INT32_MAX);
+ static_assert (sizeof (long) == 8 && LONG_MIN == INT64_MIN
+ && LONG_MAX == INT64_MAX);
+ static_assert (sizeof (void *) == 8);
assert ((uintptr_t) NULL == 0);
/* Allow a clean exit. */
@@ -182,8 +181,8 @@ main (int argc, char **argv)
/* Allow `mmap' and friends. This is necessary for dynamic loading,
reading the portable dump file, and thread creation. We don't
allow pages to be both writable and executable. */
- verify (MAP_PRIVATE != 0);
- verify (MAP_SHARED != 0);
+ static_assert (MAP_PRIVATE != 0);
+ static_assert (MAP_SHARED != 0);
RULE (SCMP_ACT_ALLOW, SCMP_SYS (mmap),
SCMP_A2_32 (SCMP_CMP_MASKED_EQ,
~(PROT_NONE | PROT_READ | PROT_WRITE)),
@@ -255,9 +254,9 @@ main (int argc, char **argv)
/* Allow opening files, assuming they are only opened for
reading. */
- verify (O_WRONLY != 0);
- verify (O_RDWR != 0);
- verify (O_CREAT != 0);
+ static_assert (O_WRONLY != 0);
+ static_assert (O_RDWR != 0);
+ static_assert (O_CREAT != 0);
RULE (SCMP_ACT_ALLOW, SCMP_SYS (open),
SCMP_A1_32 (SCMP_CMP_MASKED_EQ,
~(O_RDONLY | O_BINARY | O_CLOEXEC | O_PATH