git-compat-util: make UNLEAK less error-prone

Commit 0e5bba5 ("add UNLEAK annotation for reducing leak false positives", 2017-09-08) introduced an UNLEAK macro to be used as "UNLEAK(var);", but its existing definitions leave semicolons that act as empty statements, which will lead to syntax errors, e.g. if (condition) UNLEAK(var); else something_else(var); would be broken with two statements between if (condition) and else. Lose the excess semicolon from the end of the macro replacement text. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Sep 19, 2017 at 15:10 UTC 5de3de329ac2fafa4b5762a6d0384312897793e5
1 file changed +2 -2
git-compat-util.h
+2 -2
@@ -1184,9 +1184,9 @@ extern int cmd_main(int, const char **);
1184 */
1185 #ifdef SUPPRESS_ANNOTATED_LEAKS
1186 extern void unleak_memory(const void *ptr, size_t len);
1187 -#define UNLEAK(var) unleak_memory(&(var), sizeof(var));
1187 +#define UNLEAK(var) unleak_memory(&(var), sizeof(var))
1188 #else
1189 -#define UNLEAK(var)
1189 +#define UNLEAK(var) do {} while (0)
1190 #endif
1191
1192 #endif