From 3416fa678a9b634910faffbf9479a82f4969f7b1 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Fri, 2 Mar 2018 19:09:22 +0100 Subject: [PATCH 1/3] BaseTools/header.makefile: add "-Wno-stringop-truncation" gcc-8 (which is part of Fedora 28) enables the new warning "-Wstringop-truncation" in "-Wall". This warning is documented in detail at ; the introduction says > Warn for calls to bounded string manipulation functions such as strncat, > strncpy, and stpncpy that may either truncate the copied string or leave > the destination unchanged. It breaks the BaseTools build with: > EfiUtilityMsgs.c: In function 'PrintMessage': > EfiUtilityMsgs.c:484:9: error: 'strncat' output may be truncated copying > between 0 and 511 bytes from a string of length 511 > [-Werror=stringop-truncation] > strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > EfiUtilityMsgs.c:469:9: error: 'strncat' output may be truncated copying > between 0 and 511 bytes from a string of length 511 > [-Werror=stringop-truncation] > strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > EfiUtilityMsgs.c:511:5: error: 'strncat' output may be truncated copying > between 0 and 511 bytes from a string of length 511 > [-Werror=stringop-truncation] > strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The right way to fix the warning would be to implement string concat with snprintf(). However, Microsoft does not appear to support snprintf() before VS2015 , so we just have to shut up the warning. The strncat() calls flagged above are valid BTW. Cc: Ard Biesheuvel Cc: Cole Robinson Cc: Liming Gao Cc: Paolo Bonzini Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek Message-Id: <20180302180924.4312-2-lersek@redhat.com> Signed-off-by: Paolo Bonzini --- BaseTools/Source/C/Makefiles/header.makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile index 063982b82f..6c3826aecb 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -47,9 +47,9 @@ INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKE BUILD_CPPFLAGS = $(INCLUDE) -O2 ifeq ($(DARWIN),Darwin) # assume clang or clang compatible flags on OS X -BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -c -g +BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-self-assign -Wno-unused-result -nostdlib -c -g else -BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-unused-result -nostdlib -c -g +BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-unused-result -nostdlib -c -g endif BUILD_LFLAGS = BUILD_CXXFLAGS = -Wno-unused-result -- 2.14.3