mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-10 13:04:23 -04:00
EVUTIL_ASSERT: Use sizeof() to avoid "unused variable" warnings.
This commit is contained in:
parent
18adc3f015
commit
b63ab1776b
6
buffer.c
6
buffer.c
@ -246,6 +246,12 @@ evbuffer_chains_all_empty(struct evbuffer_chain *chain)
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
/* The definition is needed for EVUTIL_ASSERT, which uses sizeof to avoid
|
||||||
|
"unused variable" warnings. */
|
||||||
|
static inline int evbuffer_chains_all_empty(struct evbuffer_chain *chain) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -52,6 +52,10 @@ extern "C" {
|
|||||||
|
|
||||||
/* A good no-op to use in macro definitions. */
|
/* A good no-op to use in macro definitions. */
|
||||||
#define _EVUTIL_NIL_STMT ((void)0)
|
#define _EVUTIL_NIL_STMT ((void)0)
|
||||||
|
/* Suppresses the compiler's "unused variable" warnings for unused assert. */
|
||||||
|
#define _EVUTIL_NIL_CONDITION(condition) do { \
|
||||||
|
(void)sizeof(condition); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
/* Internal use only: macros to match patterns of error codes in a
|
/* Internal use only: macros to match patterns of error codes in a
|
||||||
cross-platform way. We need these macros because of two historical
|
cross-platform way. We need these macros because of two historical
|
||||||
@ -177,7 +181,7 @@ long _evutil_weakrand(void);
|
|||||||
|
|
||||||
/* Replacement for assert() that calls event_errx on failure. */
|
/* Replacement for assert() that calls event_errx on failure. */
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define EVUTIL_ASSERT(cond) _EVUTIL_NIL_STMT
|
#define EVUTIL_ASSERT(cond) _EVUTIL_NIL_CONDITION(cond)
|
||||||
#define EVUTIL_FAILURE_CHECK(cond) 0
|
#define EVUTIL_FAILURE_CHECK(cond) 0
|
||||||
#else
|
#else
|
||||||
#define EVUTIL_ASSERT(cond) \
|
#define EVUTIL_ASSERT(cond) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user