git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sparse: ignore warning from new glibc headers
@ 2024-07-16 23:17 Đoàn Trần Công Danh
  2024-07-17 16:54 ` Junio C Hamano
  2025-04-08 20:56 ` Johannes Schindelin
  0 siblings, 2 replies; 15+ messages in thread
From: Đoàn Trần Công Danh @ 2024-07-16 23:17 UTC (permalink / raw)
  To: git; +Cc: Đoàn Trần Công Danh

With at least glibc 2.39, glibc provides a function declaration that
matches with this POSIX interface:

    int regexec(const regex_t *restrict preg, const char *restrict string,
           size_t nmatch, regmatch_t pmatch[restrict], int eflags);

such prototype requires variable-length-array for `pmatch'.

Thus, sparse reports this error:

> ../add-patch.c: note: in included file (through ../git-compat-util.h):
> /usr/include/regex.h:682:41: error: undefined identifier '__nmatch'
> /usr/include/regex.h:682:41: error: bad constant expression type
> /usr/include/regex.h:682:41: error: Variable length array is used.

Note: `__nmatch' is POSIX's nmatch.

The glibc's intention is informing their users to provides a large
enough buffer to hold `__nmatch' results and provides diagnosis if
necessary.  It's merely a glibc' implementation detail.

Hide that usage from sparse by using standard C11's macro:
__STDC_NO_VLA__

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index bc81d3395032a..4b9daca1dcc58 100644
--- a/Makefile
+++ b/Makefile
@@ -1381,7 +1381,7 @@ ARFLAGS = rcs
 PTHREAD_CFLAGS =
 
 # For the 'sparse' target
-SPARSE_FLAGS ?= -std=gnu99
+SPARSE_FLAGS ?= -std=gnu99 -D__STDC_NO_VLA__
 SP_EXTRA_FLAGS = -Wno-universal-initializer
 
 # For informing GIT-BUILD-OPTIONS of the SANITIZE=leak,address targets
-- 
2.45.2.599.g51c0d632d3b6f


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

end of thread, other threads:[~2025-04-08 22:35 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-16 23:17 [PATCH] sparse: ignore warning from new glibc headers Đoàn Trần Công Danh
2024-07-17 16:54 ` Junio C Hamano
2024-07-17 18:40   ` Ramsay Jones
2024-07-17 18:51     ` Junio C Hamano
2024-07-17 19:20       ` Ramsay Jones
2024-07-17 22:36         ` Ramsay Jones
2024-07-17 22:53           ` Junio C Hamano
2024-07-18  0:02             ` Ramsay Jones
2024-07-18  2:39               ` Đoàn Trần Công Danh
2024-07-18  7:07                 ` Junio C Hamano
2024-07-18  8:46                 ` Đoàn Trần Công Danh
2024-07-18  4:47               ` Junio C Hamano
2024-07-19  2:03                 ` Ramsay Jones
2025-04-08 20:56 ` Johannes Schindelin
2025-04-08 22:35   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).