Skip to content

Commit d63df29

Browse files
sgndscho
authored andcommitted
sparse: ignore warning from new glibc headers
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> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent cbfd8c0 commit d63df29

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ ARFLAGS = rcs
14241424
PTHREAD_CFLAGS =
14251425

14261426
# For the 'sparse' target
1427-
SPARSE_FLAGS ?= -std=gnu99
1427+
SPARSE_FLAGS ?= -std=gnu99 -D__STDC_NO_VLA__
14281428
SP_EXTRA_FLAGS =
14291429

14301430
# For informing GIT-BUILD-OPTIONS of the SANITIZE=leak,address targets

0 commit comments

Comments
 (0)