From e8ca6c07b22ceb89692c17b7f51c4a8f03a268ba Mon Sep 17 00:00:00 2001 From: Madelyn Olson Date: Fri, 3 Apr 2026 21:40:06 +0100 Subject: [PATCH] Fix VLA warning in linenoise and enable -Werror (#3439) Replace 'const int seqBufferMaxLength' with a #define to avoid a variable-length array warning (-Wgnu-folding-constant) in C. Also add -Werror to the linenoise Makefile so future warnings are caught at build time. Signed-off-by: Madelyn Olson --- deps/linenoise/Makefile | 2 +- deps/linenoise/linenoise.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/deps/linenoise/Makefile b/deps/linenoise/Makefile index 1dd894b49..da71733a0 100644 --- a/deps/linenoise/Makefile +++ b/deps/linenoise/Makefile @@ -1,5 +1,5 @@ STD= -WARN= -Wall +WARN= -Wall -Werror OPT= -Os R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) diff --git a/deps/linenoise/linenoise.c b/deps/linenoise/linenoise.c index b35622214..76c9f23f6 100644 --- a/deps/linenoise/linenoise.c +++ b/deps/linenoise/linenoise.c @@ -839,6 +839,9 @@ void linenoiseEditDeletePrevWord(struct linenoiseState *l) { * when ctrl+d is typed. * * The function returns the length of the current buffer. */ +/* Max length for CSI escape sequence parameter buffer */ +#define SEQ_BUFFER_MAX_LENGTH 8 + static int linenoiseEdit(int stdin_fd, int stdout_fd, char *buf, size_t buflen, const char *prompt) { struct linenoiseState l; @@ -964,14 +967,13 @@ static int linenoiseEdit(int stdin_fd, int stdout_fd, char *buf, size_t buflen, if (seq[1] >= '0' && seq[1] <= '9') { /* Extended escape, read additional bytes. * Examples: ESC [1;5C ESC [3~ */ - const int seqBufferMaxLength = 8; - char seqBuffer[seqBufferMaxLength]; + char seqBuffer[SEQ_BUFFER_MAX_LENGTH]; int i = 0; seqBuffer[i++] = seq[1]; /* If first param is digit or ';', read more until we see a final in @~ */ char additionalChar; - while (i < seqBufferMaxLength-1 && read(l.ifd, &additionalChar, 1) != -1) { + while (i < SEQ_BUFFER_MAX_LENGTH-1 && read(l.ifd, &additionalChar, 1) != -1) { seqBuffer[i++] = additionalChar; if (additionalChar >= '@' && additionalChar <= '~') { /* CSI final byte */ seqBuffer[i] = '\0';