Skip to contentSkip to conversation

add -Wno-stringop-truncation to CFLAGS on linux

PATCH In review Antonio Quartulli 2 participants 2 messages Nov 10, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add -Wno-stringop-truncation to CFLAGS on linux

GCC>=8 supports truncation checking, however the logic is somewhat fragile when it comes to evaluating strncpy().

In buffer.h we have implemented a wrapper called strncpynt() which ensures we always do the right hting in the code and reduce the chance of having bugs.

This said, it seems that the gcc logic is not able to always understand if we are doing the right thing and throws a false positive.

Toa void the noise, disable truncation checking on Linux by default.

---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)
configure.ac +1 -0
index 4159e450..807804e5 100644
@@ -1283,6 +1283,7 @@ AC_DEFUN([ACL_CHECK_ADD_COMPILE_FLAGS], [
         [AC_MSG_RESULT([no]); CFLAGS="$old_cflags"])]
 )
 
+ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-stringop-truncation])
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-unused-function])
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-unused-parameter])
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wall])
Signature · 1 line
2.24.0
Acked-by on v1 1/1
#1 lore raw

While I'm not exactly happy suppressing warnings, this particular one is somewhat of an annoyance - the two cases where we cause warnings today are perfectly fine, and working around spurious compiler warnings
is not what I want to spend our time on. We can revisit this later.

Your patch has been applied to the master branch.

commit 46d096074fd74e0d6c1d4756429215d22f2b3441

Author: Antonio Quartulli
Date:   Sun Nov 10 11:03:23 2019 +0100
     add -Wno-stringop-truncation to CFLAGS on linux

     Signed-off-by: Antonio Quartulli <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg19085.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering