diff mbox

[ovs-dev] tests: Disable no-format-truncation warnings

Message ID 0a4b61109a907609083bb47ddd5d4720175a2ecb.1499956107.git.tredaelli@redhat.com
State Accepted
Headers show

Commit Message

Timothy Redaelli July 13, 2017, 2:29 p.m. UTC
test_snprintf function (tests/test-util.c) tests snprintf with shorter length,
but this emit a warning on GCC 7.0 or later.

This commit disables that warning on tests only.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
---
 configure.ac      | 1 +
 tests/automake.mk | 5 +++++
 2 files changed, 6 insertions(+)

Comments

Aaron Conole July 13, 2017, 3:07 p.m. UTC | #1
Timothy Redaelli <tredaelli@redhat.com> writes:

> test_snprintf function (tests/test-util.c) tests snprintf with shorter length,
> but this emit a warning on GCC 7.0 or later.
>
> This commit disables that warning on tests only.
>
> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
> ---

As an alternative, would it make sense to modify the test in question to
use xasprintf?  Such function calls into ovs_snprintf on WIN32
platforms, anyway.

I think the warning itself is busted here anyway, so I guess it's such a
big deal, but sometimes I get scared to disable warnings.
Lance Richardson July 13, 2017, 3:21 p.m. UTC | #2
> From: "Timothy Redaelli" <tredaelli@redhat.com>
> To: dev@openvswitch.org
> Sent: Thursday, 13 July, 2017 10:29:33 AM
> Subject: [ovs-dev] [PATCH] tests: Disable no-format-truncation warnings
> 
> test_snprintf function (tests/test-util.c) tests snprintf with shorter
> length,
> but this emit a warning on GCC 7.0 or later.
> 
> This commit disables that warning on tests only.
> 
> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
> ---
>  configure.ac      | 1 +
>  tests/automake.mk | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/configure.ac b/configure.ac
> index 9ef6aad3a..256a3b83d 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -169,6 +169,7 @@ OVS_ENABLE_OPTION([-Wduplicated-cond])
>  OVS_ENABLE_OPTION([-Qunused-arguments])
>  OVS_CONDITIONAL_CC_OPTION([-Wno-unused], [HAVE_WNO_UNUSED])
>  OVS_CONDITIONAL_CC_OPTION([-Wno-unused-parameter],
>  [HAVE_WNO_UNUSED_PARAMETER])
> +OVS_CONDITIONAL_CC_OPTION([-Wno-format-truncation],
> [HAVE_WNO_FORMAT_TRUNCATION])
>  OVS_ENABLE_WERROR
>  OVS_ENABLE_SPARSE
>  
> diff --git a/tests/automake.mk b/tests/automake.mk
> index 3118bbc27..1011acf65 100644
> --- a/tests/automake.mk
> +++ b/tests/automake.mk
> @@ -364,6 +364,11 @@ tests_ovstest_SOURCES += \
>  endif
>  
>  tests_ovstest_LDADD = lib/libopenvswitch.la ovn/lib/libovn.la
> +tests_ovstest_CFLAGS = $(AM_CFLAGS)
> +if HAVE_WNO_FORMAT_TRUNCATION
> +tests_ovstest_CFLAGS += -Wno-format-truncation
> +endif
> +
>  dist_check_SCRIPTS = tests/flowgen.pl
>  
>  noinst_PROGRAMS += tests/test-strtok_r
> --
> 2.13.0
> 

I've run into this as well after upgrading to F26. I dislike suppressing
warnings, but I think this is about as good as we'll be able to do. I do
like the fact that the warning is suppressed only for a single file.

So:
Acked-by: Lance Richardson <lrichard@redhat.com>
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index 9ef6aad3a..256a3b83d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -169,6 +169,7 @@  OVS_ENABLE_OPTION([-Wduplicated-cond])
 OVS_ENABLE_OPTION([-Qunused-arguments])
 OVS_CONDITIONAL_CC_OPTION([-Wno-unused], [HAVE_WNO_UNUSED])
 OVS_CONDITIONAL_CC_OPTION([-Wno-unused-parameter], [HAVE_WNO_UNUSED_PARAMETER])
+OVS_CONDITIONAL_CC_OPTION([-Wno-format-truncation], [HAVE_WNO_FORMAT_TRUNCATION])
 OVS_ENABLE_WERROR
 OVS_ENABLE_SPARSE
 
diff --git a/tests/automake.mk b/tests/automake.mk
index 3118bbc27..1011acf65 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -364,6 +364,11 @@  tests_ovstest_SOURCES += \
 endif
 
 tests_ovstest_LDADD = lib/libopenvswitch.la ovn/lib/libovn.la
+tests_ovstest_CFLAGS = $(AM_CFLAGS)
+if HAVE_WNO_FORMAT_TRUNCATION
+tests_ovstest_CFLAGS += -Wno-format-truncation
+endif
+
 dist_check_SCRIPTS = tests/flowgen.pl
 
 noinst_PROGRAMS += tests/test-strtok_r