git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] sparse: ignore warning from new glibc headers

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
Jul 16, 2024, 23:17 UTC
Message-ID
<a667da3985a0fe943cc0ff6ee8513d731d75a299.1721171853.git.congdanhqx@gmail.com>

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
Next: Junio C Hamano
Message 1 of 15 in “sparse: ignore warning from new glibc headers”
  1. sparse: ignore warning from new glibc headersĐoàn Trần Công Danh, Jul 16, 2024
  2. Junio C HamanoJul 17, 2024
  3. Ramsay JonesJul 17, 2024
  4. Junio C HamanoJul 17, 2024
  5. Ramsay JonesJul 17, 2024
  6. Ramsay JonesJul 17, 2024
  7. Junio C HamanoJul 17, 2024
  8. Ramsay JonesJul 18, 2024
  9. Đoàn Trần Công DanhJul 18, 2024
  10. Junio C HamanoJul 18, 2024
  11. Đoàn Trần Công DanhJul 18, 2024
  12. Junio C HamanoJul 18, 2024
  13. Ramsay JonesJul 19, 2024
  14. Johannes SchindelinApr 8, 2025
  15. Junio C HamanoApr 8, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.