summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-01-10 21:10:49 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2022-01-17 21:06:06 -0500
commit3db53eb1a2e9116c7566913fa6384e73c9ba4967 (patch)
tree91dcee48a4aedd21c7f5e09a3bd6a50e36b8bb32
parentdf4448f2b1f3eafd564f4ae61d0d0f21e84916d5 (diff)
downloadlibgit2-3db53eb1a2e9116c7566913fa6384e73c9ba4967.tar.gz
common: update the error checking macros
-rw-r--r--src/common.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common.h b/src/common.h
index 640f94806..549bddb59 100644
--- a/src/common.h
+++ b/src/common.h
@@ -121,12 +121,16 @@
/**
* 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.
*/
-#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.