]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cocci: allow xcalloc(1, size)
authorJunio C Hamano <gitster@pobox.com>
Tue, 16 Mar 2021 00:56:07 +0000 (17:56 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Mar 2021 00:56:07 +0000 (17:56 -0700)
Allocating a pre-cleared single element is quite common and it is
misleading to use CALLOC_ARRAY(); these allocations that would be
affected without this change are not allocating an array.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/coccinelle/array.cocci

index 9a17d2a121445b8b5c60843eb2620427ffb97c80..9a4f00cb1bdc2e189fa3ccb41d842988e2430a92 100644 (file)
@@ -92,7 +92,7 @@ expression n;
 @@
 type T;
 T *ptr;
-expression n;
+expression n != 1;
 @@
 - ptr = xcalloc(n, \( sizeof(*ptr) \| sizeof(T) \) )
 + CALLOC_ARRAY(ptr, n)