diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-04-26 22:41:40 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-12 13:02:05 -0600 |
commit | 5255dbd5196f0125b51d969c46e46ac5765db7ed (patch) | |
tree | 8af92c558c12c231ff3ea2bec991c77d947e6ffe | |
parent | cd5e55ebb7d5a51c0a8bd62137ab75a0f6ff1356 (diff) |
libmisc: macro.h: Add LM_PARTIAL_SWITCH, use it
-rw-r--r-- | lib9p/srv.c | 5 | ||||
-rw-r--r-- | libmisc/include/libmisc/macro.h | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c index 12124af..1a6bbb1 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -632,9 +632,7 @@ void lib9p_srv_worker(struct srv_req *ctx) { /* Handle it. ********************************************************/ tmessage_handler handler; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wswitch-enum" - switch (typ) { + LM_PARTIAL_SWITCH (typ) { case LIB9P_TYP_Tversion: handler = (tmessage_handler)handle_Tversion; break; #if _LIB9P_ENABLE_stat case LIB9P_TYP_Tauth: handler = (tmessage_handler)handle_Tauth; break; @@ -661,7 +659,6 @@ void lib9p_srv_worker(struct srv_req *ctx) { default: assert_notreached("lib9p_Tmsg_validate() should have rejected unknown typ"); } -#pragma GCC diagnostic pop handler(ctx, (void *)host_req); assert(ctx->responded); diff --git a/libmisc/include/libmisc/macro.h b/libmisc/include/libmisc/macro.h index ae204ae..9ac29b9 100644 --- a/libmisc/include/libmisc/macro.h +++ b/libmisc/include/libmisc/macro.h @@ -11,6 +11,12 @@ #define LM_FORCE_SEMICOLON static_assert(1, "force semicolon") +#define LM_PARTIAL_SWITCH(VAL) \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wswitch-enum\"") \ + switch (VAL) \ + _Pragma("GCC diagnostic pop") \ + /* for function definitions */ #define LM_UNUSED(argname) |