Commit 3db53eb1a2e9116c7566913fa6384e73c9ba4967

Edward Thomson 2022-01-10T21:10:49

common: update the error checking macros

diff --git a/src/common.h b/src/common.h
index 640f948..549bddb 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.