]> git.ipfire.org Git - thirdparty/git.git/commitdiff
grep: don't return an expression from pcre2_free()
authorHans Jerry Illikainen <hji@dyntopia.com>
Wed, 27 Nov 2019 20:24:11 +0000 (20:24 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sat, 30 Nov 2019 22:06:58 +0000 (14:06 -0800)
Previously, the void pcre2_free() function in grep.c returned free().
While free() itself is void, afaict it's still an expression as per
section A.2.3, subsection 6.8.6 (jump-statement) in both C99 [1] and C11
[2]:

> return expression

Section 6.8.6.4 in C99 [1] and C11 [2] says that:

> A return statement with an expression shall not appear in a function
> whose return type is void.

The consequence of the old behavior was that developer builds with
pedantic errors enabled broke Git if PCRE2 was enabled and a
smart-enough compiler to detect these errors was used.  This commit
fixes pedantic builds of Git that enables --with-libpcre.

[1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
[2] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf

Signed-off-by: Hans Jerry Illikainen <hji@dyntopia.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c

diff --git a/grep.c b/grep.c
index b7ae5a442a624810471cc4dc8ab84cd1a35c963a..0552b127c1ac11f06852be42d60b992aa2891fcf 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -26,7 +26,7 @@ static void *pcre2_malloc(PCRE2_SIZE size, MAYBE_UNUSED void *memory_data)
 
 static void pcre2_free(void *pointer, MAYBE_UNUSED void *memory_data)
 {
-       return free(pointer);
+       free(pointer);
 }
 #endif