{"thread":{"id":"52363","subject":"[PATCH 0/1] grep: don't return an expression from pcre2_free()","startedAt":"2019-11-27T20:24:18Z","lastAt":"2019-11-27T20:24:20Z","messageCount":2,"participants":["Hans Jerry Illikainen"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"387245","messageId":"20191127202411.4298-1-hji@dyntopia.com","threadId":"52363","inReplyTo":null,"subject":"[PATCH 0/1] grep: don't return an expression from pcre2_free()","fromName":"Hans Jerry Illikainen","fromEmail":"hji@dyntopia.com","sentAt":"2019-11-27T20:24:10Z","receivedAt":"2019-11-27T20:24:18Z","isPatch":true,"sender":{"key":"hji@dyntopia.com","avatar":"https://avatars.githubusercontent.com/u/8175517?v=4"},"body":"This is a simple one-line fix for a bug I ran into when enabling\npedantic builds with DEVELOPER=1 and --with-libpcre.  Previously, the\nvoid function pcre2_free() returned an expression.  This commit changes\nthat as per section 6.8.6.4 in C99 [1] and C11 [2]:\n\n> A return statement with an expression shall not appear in a function\n> whose return type is void.\n\n[1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n[2] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf\n\nHans Jerry Illikainen (1):\n  grep: don't return an expression from pcre2_free()\n\n grep.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\n--\n2.24.0.156.g00c62833a5\n"},{"id":"387246","messageId":"20191127202411.4298-2-hji@dyntopia.com","threadId":"52363","inReplyTo":"20191127202411.4298-1-hji@dyntopia.com","subject":"[PATCH 1/1] grep: don't return an expression from pcre2_free()","fromName":"Hans Jerry Illikainen","fromEmail":"hji@dyntopia.com","sentAt":"2019-11-27T20:24:11Z","receivedAt":"2019-11-27T20:24:20Z","isPatch":true,"sender":{"key":"hji@dyntopia.com","avatar":"https://avatars.githubusercontent.com/u/8175517?v=4"},"body":"Previously, the void pcre2_free() function in grep.c returned free().\nWhile free() itself is void, afaict it's still an expression as per\nsection A.2.3, subsection 6.8.6 (jump-statement) in both C99 [1] and C11\n[2]:\n\n> return expression\n\nSection 6.8.6.4 in C99 [1] and C11 [2] says that:\n\n> A return statement with an expression shall not appear in a function\n> whose return type is void.\n\nThe consequence of the old behavior was that developer builds with\npedantic errors enabled broke Git if PCRE2 was enabled and a\nsmart-enough compiler to detect these errors was used.  This commit\nfixes pedantic builds of Git that enables --with-libpcre.\n\n[1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n[2] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf\n\nSigned-off-by: Hans Jerry Illikainen <hji@dyntopia.com>\n---\n grep.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/grep.c b/grep.c\nindex b7ae5a442a..0552b127c1 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -26,7 +26,7 @@ static void *pcre2_malloc(PCRE2_SIZE size, MAYBE_UNUSED void *memory_data)\n \n static void pcre2_free(void *pointer, MAYBE_UNUSED void *memory_data)\n {\n-\treturn free(pointer);\n+\tfree(pointer);\n }\n #endif\n \n-- \n2.24.0.156.g00c62833a5\n\n"}]}