From b063c87596f4e05e4aaac9f69541e01278920451 Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 7 Oct 2015 11:40:13 -0700 Subject: mark unreachable code with a macro --- include/grpc/support/port_platform.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index 434dd6de87..f98038da52 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -181,6 +181,7 @@ #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif +#define GPR_FORBID_UNREACHABLE_CODE #define GPR_MSG_IOVLEN_TYPE int #if TARGET_OS_IPHONE #define GPR_PLATFORM_STRING "ios" @@ -336,4 +337,15 @@ typedef uintptr_t gpr_uintptr; #endif #endif +#ifdef GPR_FORBID_UNREACHABLE_CODE +#define GPR_UNREACHABLE_CODE(STATEMENT) +#else +#define GPR_UNREACHABLE_CODE(STATEMENT) \ + do { \ + gpr_log(GPR_ERROR, "Should never reach here."); \ + abort(); \ + STATEMENT; \ + } while (0) +#endif /* GPR_FORBID_UNREACHABLE_CODE */ + #endif /* GRPC_SUPPORT_PORT_PLATFORM_H */ -- cgit v1.2.3