[ovs-dev] [PATCH 1/4] acinclude: Fix -Wstrict-prototypes and -Wold-style-definition detection.
Ben Pfaff
blp at ovn.org
Mon Dec 5 22:38:50 UTC 2016
AC_LANG_PROGRAM(,) uses a program like this:
int main() { return 0; }
but that triggers warnings for -Wstrict-prototypes and for
-Wold-style-definition, since this definition of main() lacks a prototype
and is therefore old-style. This meant that -Wstrict-prototypes and
-Wold-style-definition weren't being turned on for new-enough GCC. This
commit fixes the problem by changing the program that is test-compiled to:
int x;
which doesn't make any compilers mad, as far as I know.
I recently upgraded to GCC 6.1 and just now noticed the issue, so I think
that GCC somewhere between version 4.9 and version 6.1 must have started
warning about main() when it's declared this way.
Also, fix a few functions that lacked prototypes.
Signed-off-by: Ben Pfaff <blp at ovn.org>
---
acinclude.m4 | 12 ++++++++++--
lib/perf-counter.c | 6 +++---
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index c4f331c..d253dee 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,6 +1,6 @@
# -*- autoconf -*-
-# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
+# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -784,7 +784,15 @@ AC_DEFUN([_OVS_CHECK_CC_OPTION], [dnl
dnl 0
dnl %
CFLAGS="$CFLAGS $WERROR $1"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], [if test -s conftest.err && grep "unrecognized option" conftest.err; then ovs_cv_name[]=no; else ovs_cv_name[]=yes; fi], [ovs_cv_name[]=no])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([int x;])],
+ [if test -s conftest.err && grep "unrecognized option" conftest.err
+ then
+ ovs_cv_name[]=no
+ else
+ ovs_cv_name[]=yes
+ fi],
+ [ovs_cv_name[]=no])
CFLAGS="$ovs_save_CFLAGS"])
if test $ovs_cv_name = yes; then
m4_if([$2], [], [:], [$2])
diff --git a/lib/perf-counter.c b/lib/perf-counter.c
index da60df7..c4458d2 100644
--- a/lib/perf-counter.c
+++ b/lib/perf-counter.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Nicira, Inc.
+ * Copyright (c) 2015, 2016 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -146,7 +146,7 @@ perf_counters_to_ds(struct ds *ds)
* Caller is responsible for free memory.
*/
char *
-perf_counters_to_string()
+perf_counters_to_string(void)
{
struct ds ds;
@@ -176,7 +176,7 @@ perf_counters_clear(void)
}
void
-perf_counters_destroy()
+perf_counters_destroy(void)
{
struct shash_node *node, *next;
--
2.10.2
More information about the dev
mailing list