diff options
-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) |