Commit 3db53eb1 by Edward Thomson

common: update the error checking macros

parent df4448f2
...@@ -121,12 +121,16 @@ ...@@ -121,12 +121,16 @@
/** /**
* Check a pointer allocation result, returning -1 if it failed. * Check a pointer allocation result, returning -1 if it failed.
*/ */
#define GIT_ERROR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; } #define GIT_ERROR_CHECK_ALLOC(ptr) do { \
if ((ptr) == NULL) { return -1; } \
} while(0)
/** /**
* Check a string buffer allocation result, returning -1 if it failed. * Check a string buffer allocation result, returning -1 if it failed.
*/ */
#define GIT_ERROR_CHECK_ALLOC_STR(buf) if ((void *)(buf) == NULL || git_str_oom(buf)) { return -1; } #define GIT_ERROR_CHECK_ALLOC_STR(buf) do { \
if ((void *)(buf) == NULL || git_str_oom(buf)) { return -1; } \
} while(0)
/** /**
* Check a return value and propagate result if non-zero. * Check a return value and propagate result if non-zero.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment