emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 5598886adc 1/2: Prefer static_assert to verify in seccomp-filter


From: Paul Eggert
Subject: master 5598886adc 1/2: Prefer static_assert to verify in seccomp-filter
Date: Sun, 2 Oct 2022 16:48:04 -0400 (EDT)

branch: master
commit 5598886adc9f7bc83ba9775151f839d4691128e4
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    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.
---
 lib-src/seccomp-filter.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c
index 4bd2816dfc..061af9dc07 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]