From 9fcc42d6ab3bc386c9b42861a69421f534a247f8 Mon Sep 17 00:00:00 2001 From: Markus Teich Date: Wed, 13 Jul 2016 12:22:23 +0200 Subject: [PATCH] fixup last commit --- util.h | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/util.h b/util.h index 1e67197..faf893a 100644 --- a/util.h +++ b/util.h @@ -33,35 +33,41 @@ void weprintf (const char *fmt, ...); #ifdef NDEBUG -#define brandt_assert(expr) ((expr) ? (void)(0) : \ -eprintf("Assertion failed in file %s line %d function %s: %s", \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__, \ - (#expr))) +#define brandt_assert(expr) do { \ + (expr) ? (void)(0) : eprintf ( \ + "Assertion failed in file %s line %d function %s: %s", \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__, \ + (# expr)); \ +} while (0) -#define brandt_assert_perror(errnum) (!(errnum) ? (void)(0) : \ -eprintf("Assertion failed in file %s line %d function %s:", \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__)) +#define brandt_assert_perror(errnum) do { \ + !(errnum) ? (void)(0) : eprintf ( \ + "Assertion failed in file %s line %d function %s:", \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__); \ +} while (0) -#define brandt_assert_gpgerr(errnum) (!(errnum) ? (void)(0) : \ -eprintf("Assertion failed in file %s line %d function %s: %s", \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__, \ - gcry_strerror((errnum)))) +#define brandt_assert_gpgerr(errnum) do { \ + !(errnum) ? (void)(0) : eprintf ( \ + "Assertion failed in file %s line %d function %s: %s", \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__, \ + gcry_strerror ((errnum))); \ +} while (0) -#define DP(point) ((void)(gcry_log_debugpnt (#point, point, ec_ctx))) -#define DM(mpi) ((void)(gcry_log_debugmpi (#mpi, mpi, ec_ctx))) +#define DP(point) ((void)(gcry_log_debugpnt (# point, point, ec_ctx))) +#define DM(mpi) ((void)(gcry_log_debugmpi (# mpi, mpi, ec_ctx))) -#else +#else /* ifdef NDEBUG */ #define brandt_assert(expr) ((void)(expr)) #define brandt_assert_perror(errnum) ((void)(errnum)) #define brandt_assert_gpgerr(errnum) ((void)(errnum)) -#endif +#endif /* ifdef NDEBUG */ -#endif +#endif /* ifndef _BRANDT_UTIL_H */