From: Ben Pfaff Date: Sun, 7 Jun 2015 16:48:14 +0000 (-0700) Subject: configure: Stop avoiding -Wformat-zero-length. X-Git-Tag: v2.4.0~116 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=40e7cf5607052d3b4fa09fd433fa630352c115b6 configure: Stop avoiding -Wformat-zero-length. Debian likes to enable -Wformat-zero-length, even over our code trying to disable it. It isn't too hard to make our code warning-free against this option, so this commit both stops disabling it and fixes the warnings. The first fix is to change set_subprogram_name() to take a plain string instead of a format string, and to adjust its few callers. This fixes one warning since one of those callers passed in an empty string. The second fix is to remove a test for ovs_scan() against an empty string. I couldn't find a way to avoid a warning for this test, and it isn't too valuable in any case. This allows us to drop filtering for -Wformat from the Debian rules file, so this commit removes it. Signed-off-by: Ben Pfaff --- diff --git a/configure.ac b/configure.ac index 068674ee7..be5cf086c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. +# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -144,7 +144,6 @@ OVS_ENABLE_OPTION([-Wextra]) OVS_ENABLE_OPTION([-Wno-sign-compare]) OVS_ENABLE_OPTION([-Wpointer-arith]) OVS_ENABLE_OPTION([-Wformat-security]) -OVS_ENABLE_OPTION([-Wno-format-zero-length]) OVS_ENABLE_OPTION([-Wswitch-enum]) OVS_ENABLE_OPTION([-Wunused-parameter]) OVS_ENABLE_OPTION([-Wbad-function-cast]) diff --git a/debian/rules b/debian/rules index fc6ce57eb..38ecd6227 100755 --- a/debian/rules +++ b/debian/rules @@ -35,13 +35,6 @@ endif buildflags := $(shell if dpkg-buildflags --export=configure >/dev/null 2>&1; \ then dpkg-buildflags --export=configure; fi) -# dpkg-buildflags tends to turn on -Wformat, which is admirable, but -# the -Wformat-zero-length subset of that option triggers a couple of -# false positives in Open vSwitch so turn it right back off again. -# (We do this in configure.ac also, but the Debian buildflags override -# those.) -buildflags := $(patsubst -Wformat,-Wformat -Wno-format-zero-length,$(buildflags)) - configure: configure-stamp configure-stamp: dh_testdir diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c index b2d05a6cb..88b92d1d7 100644 --- a/lib/ovs-thread.c +++ b/lib/ovs-thread.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014 Nicira, Inc. + * Copyright (c) 2013, 2014, 2015 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -332,7 +332,9 @@ ovsthread_wrapper(void *aux_) /* The order of the following calls is important, because * ovsrcu_quiesce_end() saves a copy of the thread name. */ - set_subprogram_name("%s%u", aux.name, id); + char *subprogram_name = xasprintf("%s%u", aux.name, id); + set_subprogram_name(subprogram_name); + free(subprogram_name); ovsrcu_quiesce_end(); return aux.start(aux.arg); diff --git a/lib/util.c b/lib/util.c index 947398507..a7e027976 100644 --- a/lib/util.c +++ b/lib/util.c @@ -500,24 +500,13 @@ get_subprogram_name(void) return name ? name : ""; } -/* Sets the formatted value of 'format' as the name of the currently running - * thread or process. (This appears in log messages and may also be visible in - * system process listings and debuggers.) */ +/* Sets 'subprogram_name' as the name of the currently running thread or + * process. (This appears in log messages and may also be visible in system + * process listings and debuggers.) */ void -set_subprogram_name(const char *format, ...) +set_subprogram_name(const char *subprogram_name) { - char *pname; - - if (format) { - va_list args; - - va_start(args, format); - pname = xvasprintf(format, args); - va_end(args); - } else { - pname = xstrdup(program_name); - } - + char *pname = xstrdup(subprogram_name ? subprogram_name : program_name); free(subprogram_name_set(pname)); #if HAVE_GLIBC_PTHREAD_SETNAME_NP diff --git a/lib/util.h b/lib/util.h index d1e470a41..59276e357 100644 --- a/lib/util.h +++ b/lib/util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -263,7 +263,7 @@ extern "C" { ovs_set_program_name(name, OVS_PACKAGE_VERSION) const char *get_subprogram_name(void); -void set_subprogram_name(const char *format, ...) OVS_PRINTF_FORMAT(1, 2); + void set_subprogram_name(const char *); void ovs_print_version(uint8_t min_ofp, uint8_t max_ofp); diff --git a/tests/test-util.c b/tests/test-util.c index 1d63d68d1..8eedaf09e 100644 --- a/tests/test-util.c +++ b/tests/test-util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, 2013, 2014 Nicira, Inc. + * Copyright (c) 2011, 2012, 2013, 2014, 2015 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -497,7 +497,6 @@ test_ovs_scan(struct ovs_cmdl_context *ctx OVS_UNUSED) long l, l2; int i, i2; - ovs_assert(ovs_scan("", "")); ovs_assert(ovs_scan("", " ")); ovs_assert(ovs_scan(" ", " ")); ovs_assert(ovs_scan(" ", " "));