From 5ca54c1ba2db849dfaef5fe3aec60329b3df0bd1 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 24 Jan 2023 20:54:48 -0700 Subject: [PATCH] Makefile: add -Wno-stringop-truncation for y.tab.o MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This file is auto-generated, and it currently spews the following warning for me: In function ‘setup_to_parse_string’, inlined from ‘evaluate_arithmetic_expression’ at y.tab.c:1571:2: y.tab.c:1559:9: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-truncation] 1559 | strncpy(lexer_input_buffer, string, len); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ y.tab.c:1556:19: note: length computed here 1556 | if (len > strlen(string)) | ^~~~~~~~~~~~~~ when compiled with: gcc (Debian 12.2.0-14) 12.2.0 Just set -Wno-stringop-truncation unconditionally in the Makefile for this file, don't think there's any point in checking if this warning has been enabled manually. Signed-off-by: Jens Axboe --- Makefile | 6 +++++- configure | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9fd8f59b..5f4e6562 100644 --- a/Makefile +++ b/Makefile @@ -554,11 +554,15 @@ ifneq (,$(findstring -Wimplicit-fallthrough,$(CFLAGS))) LEX_YY_CFLAGS := -Wno-implicit-fallthrough endif +ifdef CONFIG_HAVE_NO_STRINGOP +YTAB_YY_CFLAGS := -Wno-stringop-truncation +endif + lex.yy.o: lex.yy.c y.tab.h $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(LEX_YY_CFLAGS) -c $< y.tab.o: y.tab.c y.tab.h - $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< + $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(YTAB_YY_CFLAGS) -c $< y.tab.c: exp/expression-parser.y $(QUIET_YACC)$(YACC) -o $@ -l -d -b y $< diff --git a/configure b/configure index 6d8e3a87..a17d1cda 100755 --- a/configure +++ b/configure @@ -2826,6 +2826,22 @@ if compile_prog "-Wimplicit-fallthrough=2" "" "-Wimplicit-fallthrough=2"; then fi print_config "-Wimplicit-fallthrough=2" "$fallthrough" +########################################## +# check if the compiler has -Wno-stringop-concatenation +no_stringop="no" +cat > $TMPC << EOF +#include + +int main(int argc, char **argv) +{ + return printf("%s\n", argv[0]); +} +EOF +if compile_prog "-Wno-stringop-truncation -Werror" "" "no_stringop"; then + no_stringop="yes" +fi +print_config "-Wno-stringop-truncation" "$no_stringop" + ########################################## # check for MADV_HUGEPAGE support if test "$thp" != "yes" ; then @@ -3271,6 +3287,9 @@ fi if test "$fallthrough" = "yes"; then CFLAGS="$CFLAGS -Wimplicit-fallthrough" fi +if test "$no_stringop" = "yes"; then + output_sym "CONFIG_HAVE_NO_STRINGOP" +fi if test "$thp" = "yes" ; then output_sym "CONFIG_HAVE_THP" fi -- 2.25.1