Hi,

On Fri, Jan 26, 2018 at 5:58 AM, Steffan Karger <stef...@karger.me> wrote:
> 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.
>
> Signed-off-by: Steffan Karger <stef...@karger.me>
> ---
> v2: Just move forward with warnings, don't add --disable-strict.
>
>  configure.ac | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/configure.ac b/configure.ac
> index 2c1937e5..4d415565 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -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.

>  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

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to