Skip to contentSkip to conversation

Enable extra compiler warnings by default

PATCH Superseded Steffan Karger 4 participants 17 messages Jan 20, 2018 – Feb 20, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Enable extra compiler warnings by default

This by default enables the compiler warnings any could previously enable using the --enable-strict configure option. I think it is okay to do so now, because we've taken care of many warnings in the more standard builds. (Most of those were totally harmless, but they prevented us from spotting new more serious mistakes.)

Those who prefer a more silent build can use --disable-strict to revert to the old default behaviour.

---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
configure.ac +2 -2
index 2c1937e5..2b5fa533 100644
@@ -209,9 +209,9 @@ AC_ARG_ENABLE(
 
 AC_ARG_ENABLE(
 	[strict],
-	[AS_HELP_STRING([--enable-strict], [enable strict compiler warnings (debugging option) @<:@default=no@:>@])],
+	[AS_HELP_STRING([--disable-strict], [enable strict compiler warnings (debugging option) @<:@default=yes@:>@])],
 	,
-	[enable_strict="no"]
+	[enable_strict="yes"]
 )
 
 AC_ARG_ENABLE(
Signature · 1 line
2.14.1
#1 lore raw

Hi,

Quoted 9 lines · Steffan Karger

This by default enables the compiler warnings any could previously enable using the --enable-strict configure option. I think it is okay to do so now, because we've taken care of many warnings in the more standard builds. (Most of those were totally harmless, but they prevented us from spotting new more serious mistakes.)

Those who prefer a more silent build can use --disable-strict to revert to the old default behaviour.

I think --enable-strict by default is good to have. In fact its needed to keep on bugging us about many of those printf format spec issues we still have with mingw.

Quoted 12 lines
---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
configure.ac +0 -0
index 2c1937e5..2b5fa533 100644

configure.ac AC_ARG_ENABLE( · line 212

Quoted 5 lines
configure.ac +1 -1
@@ -209,9 +209,9 @@ AC_ARG_ENABLE(
 
 AC_ARG_ENABLE(
        [strict],
-       [AS_HELP_STRING([--enable-strict], [enable strict compiler warnings (debugging option) @<:@default=no@:>@])],
+       [AS_HELP_STRING([--disable-strict], [enable strict compiler warnings (debugging option) @<:@default=yes@:>@])],

The description should now read "disable strict compiler warnings...", isn't it? Could be fixed while merging..

configure.ac AC_ARG_ENABLE( · line 217

Quoted 7 lines
configure.ac +1 -1
        ,
-       [enable_strict="no"]
+       [enable_strict="yes"]
 )
 
 AC_ARG_ENABLE(

Selva

#2 lore raw

Hi,

Quoted 28 lines · Selva Nair
Quoted 9 lines · Steffan Karger

This by default enables the compiler warnings any could previously enable using the --enable-strict configure option. I think it is okay to do so now, because we've taken care of many warnings in the more standard builds. (Most of those were totally harmless, but they prevented us from spotting new more serious mistakes.)

Those who prefer a more silent build can use --disable-strict to revert to the old default behaviour.

I think --enable-strict by default is good to have. In fact its needed to keep on bugging us about many of those printf format spec issues we still have with mingw.

Quoted 12 lines
---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
configure.ac +0 -0
index 2c1937e5..2b5fa533 100644
@@ -209,9 +209,9 @@ AC_ARG_ENABLE(
 
Quoted 8 lines

configure.ac AC_ARG_ENABLE( · line 212

Quoted 4 lines
configure.ac +1 -1
 AC_ARG_ENABLE(
        [strict],
-       [AS_HELP_STRING([--enable-strict], [enable strict compiler warnings (debugging option) @<:@default=no@:>@])],
+       [AS_HELP_STRING([--disable-strict], [enable strict compiler warnings (debugging option) @<:@default=yes@:>@])],

The description should now read "disable strict compiler warnings...", isn't it? Could be fixed while merging..

Yeah, it should. Though while brushing my teeth last night, I was wondering whether it's worth to have --disable-strict at all. Shouldn't we just unconditionally enable the current strict compiler flags? We could then make the --enable-strict flags a bit stricter to catch more mistakes.

-Steffan

#3 lore raw

Hi,

Quoted 40 lines · Steffan Karger

Hi,

Quoted 28 lines · Selva Nair
Quoted 9 lines · Steffan Karger

This by default enables the compiler warnings any could previously enable using the --enable-strict configure option. I think it is okay to do so now, because we've taken care of many warnings in the more standard builds. (Most of those were totally harmless, but they prevented us from spotting new more serious mistakes.)

Those who prefer a more silent build can use --disable-strict to revert to the old default behaviour.

I think --enable-strict by default is good to have. In fact its needed to keep on bugging us about many of those printf format spec issues we still have with mingw.

Quoted 12 lines
---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
configure.ac +0 -0
index 2c1937e5..2b5fa533 100644
@@ -209,9 +209,9 @@ AC_ARG_ENABLE(
 
Quoted 8 lines

configure.ac AC_ARG_ENABLE( · line 212

Quoted 4 lines
configure.ac +1 -1
 AC_ARG_ENABLE(
        [strict],
-       [AS_HELP_STRING([--enable-strict], [enable strict compiler warnings (debugging option) @<:@default=no@:>@])],
+       [AS_HELP_STRING([--disable-strict], [enable strict compiler warnings (debugging option) @<:@default=yes@:>@])],

The description should now read "disable strict compiler warnings...", isn't it? Could be fixed while merging..

Quoted 5 lines

Yeah, it should. Though while brushing my teeth last night, I was wondering whether it's worth to have --disable-strict at all. Shouldn't we just unconditionally enable the current strict compiler flags? We could then make the --enable-strict flags a bit stricter to catch more mistakes.

Personally either way would be great improvement as I forget to enable -Wall almost every time and have to re-configure.

Selva

#4 lore raw

PATCH v2 1/1 Enable stricter compiler warnings by default

In reply to Steffan Karger

This by default enables the compiler warnings one could previously enable using the --enable-strict configure option. I think it is okay to do so now, because we've taken care of many warnings in the more standard builds. (Most of those were totally harmless, but they prevented us from spotting new more serious mistakes.)

The --enable-strict flag now enables two extra warning flags that I think can be useful:

-Wsign-compare warns when the compiler promotes a signed type to unsigned before comparing, which can lead to unexpected behaviour.

-Wuninitialized adds extra warnings about usage of uninitialized variables or struct elements.

---
v2: Just move forward with warnings, don't add --disable-strict.

 configure.ac | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
configure.ac +2 -1
index 2c1937e5..4d415565 100644
@@ -1292,13 +1292,14 @@ if test "${enable_pkcs11}" = "yes"; then
 	)
 fi
 
+CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"
 if test "${enable_pedantic}" = "yes"; then
 	enable_strict="yes"
 	CFLAGS="${CFLAGS} -pedantic"
 	AC_DEFINE([PEDANTIC], [1], [Enable pedantic mode])
 fi
 if test "${enable_strict}" = "yes"; then
-	CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"
+	CFLAGS="${CFLAGS} -Wsign-compare -Wuninitialized"
 fi
 if test "${enable_werror}" = "yes"; then
 	CFLAGS="${CFLAGS} -Werror"
Signature · 1 line
2.14.1
#5 lore raw

Re: [Openvpn-devel] [PATCH v2] Enable stricter compiler warnings by default

Hi,

Quoted 27 lines · Steffan Karger

This by default enables the compiler warnings one could previously enable using the --enable-strict configure option. I think it is okay to do so now, because we've taken care of many warnings in the more standard builds. (Most of those were totally harmless, but they prevented us from spotting new more serious mistakes.)

The --enable-strict flag now enables two extra warning flags that I think can be useful:

-Wsign-compare warns when the compiler promotes a signed type to unsigned before comparing, which can lead to unexpected behaviour.

-Wuninitialized adds extra warnings about usage of uninitialized variables or struct elements.

---
v2: Just move forward with warnings, don't add --disable-strict.

 configure.ac | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
configure.ac +0 -0
index 2c1937e5..4d415565 100644

configure.ac if test "${enable_pkcs11}" = "yes"; then · line 1295

Quoted 4 lines
configure.ac +1 -0
@@ -1292,13 +1292,14 @@ if test "${enable_pkcs11}" = "yes"; then
        )
 fi
 
+CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"

As this is added by default (not in response to --enable/--disable directives), may be better to prepend to user's CFLAGS? I'm not sure what the standard practice is, though.. Considering the complexity of configury, preserving user's input is hard, so may be ok like this.

configure.ac if test "${enable_pkcs11}" = "yes"; then · line 1302

Quoted 8 lines
configure.ac +1 -1
 if test "${enable_pedantic}" = "yes"; then
        enable_strict="yes"
        CFLAGS="${CFLAGS} -pedantic"
        AC_DEFINE([PEDANTIC], [1], [Enable pedantic mode])
 fi
 if test "${enable_strict}" = "yes"; then
-       CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"
+       CFLAGS="${CFLAGS} -Wsign-compare -Wuninitialized"

I'm no fan of -Wsign-compare, but it does warn against some sloppy coding, is not on by default, so fine by me.

And, I very much like -Wall -Wno-unused-foo becoming the "new normal".

Just one thing: if we support compilers other than gcc/clang (say, xlc) this would need a test like AX_CHECK_COMPILE_FLAG(). Otherwise looks good.

Selva

#6 lore raw

Re: [Openvpn-devel] [PATCH v2] Enable stricter compiler warnings by default

Hi,

Quoted 4 lines · Selva Nair

As this is added by default (not in response to --enable/--disable directives), may be better to prepend to user's CFLAGS? I'm not sure what the standard practice is, though.. Considering the complexity of configury, preserving user's input is hard, so may be ok like this.

Good point. I'll send a v3 with CFLAGS last (for default flags).

Quoted 2 lines

Just one thing: if we support compilers other than gcc/clang (say, xlc) this would need a test like AX_CHECK_COMPILE_FLAG().

Hm, I don't think we do for configure.ac. We do sort-of support MSVC, but that doesn't use this build system. Gert, David, any opinions?

-Steffan

#7 lore raw

Re: [Openvpn-devel] [PATCH v2] Enable stricter compiler warnings by default

Hi,

Quoted 5 lines · Steffan Karger
Quoted 2 lines

Just one thing: if we support compilers other than gcc/clang (say, xlc) this would need a test like AX_CHECK_COMPILE_FLAG().

Hm, I don't think we do for configure.ac. We do sort-of support MSVC, but that doesn't use this build system. Gert, David, any opinions?

Well, on systems that have no gcc, configure will use whatever it finds
- on Solaris this could be some Sun CC, on AIX it will be xlc. We should not break that gratuitously.

So, gcc-specific flags need a test on whether they work with "OS cc"

gert

Signature · 3 lines
now what should I write here...

Gert Doering - Munich, Germany                             [email protected]...
#8 lore raw

PATCH v3 1/1 Enable stricter compiler warnings by default

This by default enables the compiler warnings one could previously enable using the --enable-strict configure option. I think it is okay to do so now, because we've taken care of many warnings in the more standard builds. (Most of those were totally harmless, but they prevented us from spotting new more serious mistakes.)

The --enable-strict flag now enables two extra warning flags that I think can be useful:

-Wsign-compare warns when the compiler promotes a signed type to unsigned before comparing, which can lead to unexpected behaviour.

-Wuninitialized adds extra warnings about usage of uninitialized variables or struct elements.

---
v2: Just move forward with warnings, don't add --disable-strict.
v3: Nothing is as simple as it seems: put user-supplied CFLAGS behind
default flags, check that potential esotheric compiler supports flags before enabling them.

 configure.ac                | 12 +++++++-
 m4/ax_check_compile_flag.m4 | 74 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 m4/ax_check_compile_flag.m4
configure.ac +11 -1
index 2cbf3358..33b6bc8e 100644
@@ -1292,13 +1292,23 @@ if test "${enable_pkcs11}" = "yes"; then
 	)
 fi
 
+AX_CHECK_COMPILE_FLAG(
+    [-Wno-unused-function],
+    [CFLAGS="-Wno-unused-function ${CFLAGS}"]
+)
+AX_CHECK_COMPILE_FLAG(
+    [-Wno-unused-parameter],
+    [CFLAGS="-Wno-unused-parameter ${CFLAGS}"]
+)
+AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="-Wall ${CFLAGS}"])
+
 if test "${enable_pedantic}" = "yes"; then
 	enable_strict="yes"
 	CFLAGS="${CFLAGS} -pedantic"
 	AC_DEFINE([PEDANTIC], [1], [Enable pedantic mode])
 fi
 if test "${enable_strict}" = "yes"; then
-	CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"
+	CFLAGS="${CFLAGS} -Wsign-compare -Wuninitialized"
 fi
 if test "${enable_werror}" = "yes"; then
 	CFLAGS="${CFLAGS} -Werror"
m4/ax_check_compile_flag.m4 new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.14.1
#9 lore raw

Re: [Openvpn-devel] [PATCH v3] Enable stricter compiler warnings by default

configure.ac if test "${enable_pkcs11}" = "yes"; then · line 1302

Quoted 8 lines · Steffan Karger
configure.ac +8 -0
+AX_CHECK_COMPILE_FLAG(
+    [-Wno-unused-function],
+    [CFLAGS="-Wno-unused-function ${CFLAGS}"]
+)
+AX_CHECK_COMPILE_FLAG(
+    [-Wno-unused-parameter],
+    [CFLAGS="-Wno-unused-parameter ${CFLAGS}"]
+)

Gah, those should have been tab-indented like the surrounding code. If all else looks good, maybe the committed can fix that when applying? O-)

-Steffan

Acked-by on v3 1/1
#10 lore raw

Re: [Openvpn-devel] [PATCH v3] Enable stricter compiler warnings by default

In reply to Steffan Karger

Hi,

Quoted 12 lines · Steffan Karger

This by default enables the compiler warnings one could previously enable using the --enable-strict configure option. I think it is okay to do so now, because we've taken care of many warnings in the more standard builds. (Most of those were totally harmless, but they prevented us from spotting new more serious mistakes.)

The --enable-strict flag now enables two extra warning flags that I think can be useful:

-Wsign-compare warns when the compiler promotes a signed type to unsigned before comparing, which can lead to unexpected behaviour.

Quoted 7 lines

-Wuninitialized adds extra warnings about usage of uninitialized variables or struct elements.

---
v2: Just move forward with warnings, don't add --disable-strict.
v3: Nothing is as simple as it seems:

:)

Quoted 14 lines

put user-supplied CFLAGS behind
default flags, check that potential esotheric compiler supports flags before enabling them.

 configure.ac                | 12 +++++++-
 m4/ax_check_compile_flag.m4 | 74 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 m4/ax_check_compile_flag.m4
configure.ac +0 -0
index 2cbf3358..33b6bc8e 100644

configure.ac if test "${enable_pkcs11}" = "yes"; then · line 1298

Quoted 7 lines
configure.ac +4 -0
@@ -1292,13 +1292,23 @@ if test "${enable_pkcs11}" = "yes"; then
        )
 fi
 
+AX_CHECK_COMPILE_FLAG(
+    [-Wno-unused-function],
+    [CFLAGS="-Wno-unused-function ${CFLAGS}"]
+)

As Steffan himself noted, need tabs instead of spaces for consistency

configure.ac if test "${enable_pkcs11}" = "yes"; then · line 1302

Quoted 4 lines
configure.ac +4 -0
+AX_CHECK_COMPILE_FLAG(
+    [-Wno-unused-parameter],
+    [CFLAGS="-Wno-unused-parameter ${CFLAGS}"]
+)

same here

configure.ac if test "${enable_pkcs11}" = "yes"; then · line 1303

Quoted 1 line
configure.ac +1 -0
+AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="-Wall ${CFLAGS}"])

The three options could have checked together, but this is fine too.

All said and done, the check is not as useful as I had imagined.. AX_CHECK_COMPLIE_FLAG only catches errors, not warnings.
For instance, IBM's xlc, at least on Linux, only warns about unknown options. So nothing gained -- in fact 4 warning lines per source file caused by these options.
Hopefully, its still useful on some other never used build envs..

Anyway, the check protects against probable build failures on some unknown systems, and I won't waste any more time dwelling on this.

Quoted 93 lines
configure.ac +2 -1
+
 if test "${enable_pedantic}" = "yes"; then
        enable_strict="yes"
        CFLAGS="${CFLAGS} -pedantic"
        AC_DEFINE([PEDANTIC], [1], [Enable pedantic mode])
 fi
 if test "${enable_strict}" = "yes"; then
-       CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"
+       CFLAGS="${CFLAGS} -Wsign-compare -Wuninitialized"
 fi
 if test "${enable_werror}" = "yes"; then
        CFLAGS="${CFLAGS} -Werror"
m4/ax_check_compile_flag.m4 new file +74 -1
new file mode 100644
index 00000000..dcabb92a
@@ -0,0 +1,74 @@
+# ===========================================================================
+#  https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+#   Check whether the given FLAG works with the current language's compiler
+#   or gives an error.  (Warnings, however, are ignored)
+#
+#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+#   success/failure.
+#
+#   If EXTRA-FLAGS is defined, it is added to the current language's default
+#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with
+#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to
+#   force the compiler to issue an error when a bad flag is given.
+#
+#   INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+#   macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <[email protected]...>
+#   Copyright (c) 2011 Maarten Bosmans <[email protected]...>
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 5
+
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+  AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+    [AS_VAR_SET(CACHEVAR,[yes])],
+    [AS_VAR_SET(CACHEVAR,[no])])
+  _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+  [m4_default([$2], :)],
+  [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
--
Quoted 1 line

2.14.1

This macro is a part of autoconf archive which, I thought, is prerequisite for building from the repo. One anyway needs autotools installed. Can't we not insist on having these common macros be present as well? After all this is for building from git sources, not from a dist tarball
which needs no autotools.

Also the notes in the macro file says "Please keep this macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG." which is easier to do if we use the system's installed copy.

Anyway, if including such m4 macros in the repo is the policy, this is fine.

Having done the self-satisfying nitpicking:

(compile tested: --Wall is surprisingly quiet on linux, but exposes lots of warnings on Windows (mingw) some of which are not benign)

Selva

#11 lore raw

Re: [Openvpn-devel] [PATCH v3] Enable stricter compiler warnings by default

Hi,

Quoted 28 lines · Selva Nair
Quoted 3 lines · Steffan Karger

[...]

+AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="-Wall ${CFLAGS}"])

The three options could have checked together, but this is fine too.

All said and done, the check is not as useful as I had imagined.. AX_CHECK_COMPLIE_FLAG only catches errors, not warnings.
For instance, IBM's xlc, at least on Linux, only warns about unknown options. So nothing gained -- in fact 4 warning lines per source file caused by these options.
Hopefully, its still useful on some other never used build envs..

Anyway, the check protects against probable build failures on some unknown systems, and I won't waste any more time dwelling on this.

m4/ax_check_compile_flag.m4

Quoted 3 lines
m4/ax_check_compile_flag.m4 new file +0 -0
new file mode 100644
[...]

This macro is a part of autoconf archive which, I thought, is prerequisite for building from the repo. One anyway needs autotools installed. Can't we not insist on having these common macros be present as well? After all this is for building from git sources, not from a dist tarball
which needs no autotools.

Quoted 6 lines

Also the notes in the macro file says "Please keep this macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG." which is easier to do if we use the system's installed copy.

Anyway, if including such m4 macros in the repo is the policy, this is fine.

We previously did not depend on it (I didn't have the archive installed) and thought we didn't want to pull in another dependency. Also, the error when the archive is missing is quite terrible and will cost a lot of people time to understand. Autoconf happily continues, then configure fails with:

./configure: line 17861: syntax error near unexpected token newline' ./configure: line 17861: AX_CHECK_COMPILE_FLAG('

That said, if we prefer to not include the macro, it can simply be removed from the commit. I could even rewrite then to directly use AC_COMPILE_IFELSE, which is bulkier and less clear but doesn't need the include.

Quoted 3 lines

Having done the self-satisfying nitpicking:

Thanks :)

-Steffan

#12 lore raw

Re: [Openvpn-devel] [PATCH v3] Enable stricter compiler warnings by default

Quoted 44 lines · Steffan Karger

Hi,

Quoted 28 lines · Selva Nair
Quoted 3 lines · Steffan Karger

[...]

+AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="-Wall ${CFLAGS}"])

The three options could have checked together, but this is fine too.

All said and done, the check is not as useful as I had imagined.. AX_CHECK_COMPLIE_FLAG only catches errors, not warnings.
For instance, IBM's xlc, at least on Linux, only warns about unknown options. So nothing gained -- in fact 4 warning lines per source file caused by these options.
Hopefully, its still useful on some other never used build envs..

Anyway, the check protects against probable build failures on some unknown systems, and I won't waste any more time dwelling on this.

m4/ax_check_compile_flag.m4

Quoted 3 lines
m4/ax_check_compile_flag.m4 new file +0 -0
new file mode 100644
[...]

This macro is a part of autoconf archive which, I thought, is prerequisite for building from the repo. One anyway needs autotools installed. Can't we not insist on having these common macros be present as well? After all this is for building from git sources, not from a dist tarball
which needs no autotools.

Quoted 6 lines

Also the notes in the macro file says "Please keep this macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG." which is easier to do if we use the system's installed copy.

Anyway, if including such m4 macros in the repo is the policy, this is fine.

We previously did not depend on it (I didn't have the archive installed) and thought we didn't want to pull in another dependency. Also, the error when the archive is missing is quite terrible and will cost a lot of people time to understand. Autoconf happily continues, then configure fails with:

Quoted 7 lines

./configure: line 17861: syntax error near unexpected token newline' ./configure: line 17861: AX_CHECK_COMPILE_FLAG('

That said, if we prefer to not include the macro, it can simply be removed from the commit. I could even rewrite then to directly use AC_COMPILE_IFELSE, which is bulkier and less clear but doesn't need the include.

I've just done a quick check where/how ax_check_compile_flag.m4 can be found on Fedora 27, RHEL-7 and RHEL-6.

For Fedora 27 and RHEL-7, it is found in a package named "autoconf-archive". For RHEL-6, no such package exists and I could also not find any other packages which provides that .m4 file.

We could check this on other platforms as well (*BSD, Solaris, AIX) to see how they handle this. But if there's a similar situation there, I think it makes perfect sense to ship this macro file. What I don't like about that, is that we should have some process to ensure we keep these m4 files up-to-date. Which we have not really done so far :/

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#13 lore raw

[Openvpn-devel] [PATCH applied] Re: Enable stricter compiler warnings by default

In reply to Steffan Karger

Your patch has been applied to the master and release/2.4 branch.

Tested on FreeBSD 10, Linux and, indeed, AIX 7 :-) - Linux/gcc is nicely clean, FreeBSD/clang finds a few that are silly and want fixing...

    ../../../openvpn/src/openvpn/push.c:42:13: warning: unused variable
	  'push_reply_cmd' [-Wunused-variable]
    static char push_reply_cmd[] = "PUSH_REPLY";

    ../../../openvpn/src/openvpn/ssl_verify.c:1222:1: warning: unused label
	  'cleanup' [-Wunused-label]
    cleanup:

AIX 7 with gcc has quite a few warnings, but those are "AIX is annoying" style things like these two:

options.c:4947:16: warning: missing braces around initializer [-Wmissing-braces] options.c:4947:16: warning: (near initialization for 'remote.u6_addr') [-Wmissing-braces]

tun.c:1791:13: warning: implicit declaration of function 'if_nametoindex' [-Wimplicit-function-declaration]

and interesting enough, one that should have been visible on the other platforms as well - maybe different OpenSSL version?

ssl_openssl.c: In function 'backend_tls_ctx_reload_crl':
ssl_openssl.c:967:13: warning: value computed is not used [-Wunused-value]

.. but overall, AIX is much less noisy than I would have expected (like, 20 warnings in total, half of them format warnings that Selva's patch will address). Good :-)

I have applied the patch to release/2.4 as well, as my worries about "breaking some platform that previously was compiling nicely" shouldn't be triggered (this is just turning on *warnings*, after all), and also because the amount of warnings triggered is so small.

commit adbf68c00bf40089489c5e039138f855fc5e2392 (master) commit b9d186211c87f52711592f1c29399a088912bf39 (release/2.4)

Author: Steffan Karger
Date:   Thu Feb 1 16:45:21 2018 +0100
     Enable stricter compiler warnings by default

     Signed-off-by: Steffan Karger <[email protected]...>
     Acked-by: Selva Nair <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg16426.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#14 lore raw

Re: [Openvpn-devel] [PATCH applied] Re: Enable stricter compiler warnings by default

Hi,

Quoted 4 lines · Gert Doering

Your patch has been applied to the master and release/2.4 branch.

Tested on FreeBSD 10, Linux and, indeed, AIX 7 :-) - Linux/gcc is nicely clean, FreeBSD/clang finds a few that are silly and want fixing...

Yeah. Right. And it blows up on centos-6 and opensolaris-10.

Now I can't claim that I understand this... David double-checked this macro and m4/ stuff, so "everything should have been good", but it isn't.

CentOS 6:

checking lz4.h usability... no
checking lz4.h presence... no
checking for lz4.h... no
usable LZ4 library or header not found, using version in src/com
+pat/compat-lz4.*
checking git checkout... yes
./configure: line 24067: syntax error near unexpected token newline' ./configure: line 24067: AX_CHECK_COMPILE_FLAG('
make: *** [config.status] Error 2

OpenSolaris blows up at the same point, but with less detail ("unexpected (" or something like this)

Now what...?

gert

Signature · 3 lines
now what should I write here...

Gert Doering - Munich, Germany                             [email protected]...
#15 lore raw

Re: [Openvpn-devel] [PATCH applied] Re: Enable stricter compiler warnings by default

Hi,

Quoted 14 lines · Gert Doering
Quoted 4 lines · Gert Doering

Your patch has been applied to the master and release/2.4 branch.

Tested on FreeBSD 10, Linux and, indeed, AIX 7 :-) - Linux/gcc is nicely clean, FreeBSD/clang finds a few that are silly and want fixing...

Yeah. Right. And it blows up on centos-6 and opensolaris-10.

Now I can't claim that I understand this... David double-checked this macro and m4/ stuff, so "everything should have been good", but it isn't.

CentOS 6:

Quoted 9 lines

checking lz4.h usability... no
checking lz4.h presence... no
checking for lz4.h... no
usable LZ4 library or header not found, using version in src/com
+pat/compat-lz4.*
checking git checkout... yes
./configure: line 24067: syntax error near unexpected token newline' ./configure: line 24067: AX_CHECK_COMPILE_FLAG('
make: *** [config.status] Error 2

They both already fail in the step before it seems:

Quoted 1 line

configure.ac:1295: error: Autoconf version 2.64 or higher is required

ContOS 6 ships with autoconf 2.63, I don't know what opensolaris-10 has.

We could revert to an older version of the macro we ship, or to a simpler (though less clear) AC_CHECK_COMPILE-based check.

I'm tempted to ditch the macro and go for the AC_CHECK_COMPILE.

-Steffan

#16 lore raw

Re: [Openvpn-devel] [PATCH applied] Re: Enable stricter compiler warnings by default

Hi,

Quoted 4 lines · Steffan Karger

We could revert to an older version of the macro we ship, or to a simpler (though less clear) AC_CHECK_COMPILE-based check.

I'm tempted to ditch the macro and go for the AC_CHECK_COMPILE.

The macro seems to be more painful than expected - so I tend to agree with you :-) - patches welcome.

Though with the state of the sf.net list, patch handling is quite annoying :-/ (read: some mails get through, some mails take ages, patchwork isn't seeing stuff, the list archive isn't seeing stuff that I could reference on merging, etc. - gah)

gert

Signature · 3 lines
now what should I write here...

Gert Doering - Munich, Germany                             [email protected]...