All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] git-compat-util.h: drop trailing semicolon from macro definition
@ 2021-03-13 16:10 René Scharfe.
  2021-03-13 16:17 ` [PATCH 2/2] use CALLOC_ARRAY René Scharfe.
  0 siblings, 1 reply; 5+ messages in thread
From: René Scharfe. @ 2021-03-13 16:10 UTC (permalink / raw)
  To: Git List; +Cc: Jeff King, Junio C Hamano

Make CALLOC_ARRAY usable like a function by requiring callers to supply
the trailing semicolon, which all of the current ones already do.  With
the extra semicolon e.g. the following code wouldn't compile because it
disconnects the "else" from the "if":

	if (condition)
		CALLOC_ARRAY(ptr, n);
	else
		whatever();

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 git-compat-util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 3b2738c73d..dcc786edaa 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -898,7 +898,7 @@ int xstrncmpz(const char *s, const char *t, size_t len);
 #define FREE_AND_NULL(p) do { free(p); (p) = NULL; } while (0)

 #define ALLOC_ARRAY(x, alloc) (x) = xmalloc(st_mult(sizeof(*(x)), (alloc)))
-#define CALLOC_ARRAY(x, alloc) (x) = xcalloc((alloc), sizeof(*(x)));
+#define CALLOC_ARRAY(x, alloc) (x) = xcalloc((alloc), sizeof(*(x)))
 #define REALLOC_ARRAY(x, alloc) (x) = xrealloc((x), st_mult(sizeof(*(x)), (alloc)))

 #define COPY_ARRAY(dst, src, n) copy_array((dst), (src), (n), sizeof(*(dst)) + \
--
2.30.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-16 11:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-13 16:10 [PATCH 1/2] git-compat-util.h: drop trailing semicolon from macro definition René Scharfe.
2021-03-13 16:17 ` [PATCH 2/2] use CALLOC_ARRAY René Scharfe.
     [not found]   ` <xmqq35ww1amf.fsf@gitster.g>
2021-03-15 22:35     ` René Scharfe.
     [not found]       ` <xmqqk0q8ynz0.fsf@gitster.g>
2021-03-16  0:55         ` [PATCH] xcalloc: use CALLOC_ARRAY() when applicable Junio C Hamano
2021-03-16 11:43           ` Derrick Stolee

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.