Skip to content

Commit

Permalink
Merge pull request #102 from opentechinstitute/debug-check-fixes
Browse files Browse the repository at this point in the history
make CHECK macro calls safer for multistatement operation; Tested by @jheretic.
  • Loading branch information
jheretic committed May 12, 2014
2 parents 9a9f864 + d9f5083 commit 0723270
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
#define LOG_DEBUG "LOG_DEBUG"
#endif

#if defined(NDEBUG) && !defined(OPENWRT)
#if defined(NDEBUG)
#define DEBUG(M, ...)
#else
#define DEBUG(M, ...) LOG(LOG_DEBUG, "(%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
Expand All @@ -104,12 +104,12 @@

#define INFO(M, ...) LOG(LOG_INFO, "(%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)

#define CHECK(A, M, ...) if(!(A)) { ERROR(M, ##__VA_ARGS__); errno=0; goto error; }
#define CHECK(A, M, ...) do { if(!(A)) { ERROR(M, ##__VA_ARGS__); errno=0; goto error; } } while (0)

#define SENTINEL(M, ...) { ERROR(M, ##__VA_ARGS__); errno=0; goto error; }

#define CHECK_MEM(A) CHECK((A), "Out of memory.")

#define CHECK_DEBUG(A, M, ...) if(!(A)) { DEBUG(M, ##__VA_ARGS__); errno=0; goto error; }
#define CHECK_DEBUG(A, M, ...) do { if(!(A)) { DEBUG(M, ##__VA_ARGS__); errno=0; goto error; } } while(0)

#endif

0 comments on commit 0723270

Please sign in to comment.