From patchwork Thu Feb 1 04:45:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffan Karger X-Patchwork-Id: 228 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director5.mail.ord1d.rsapps.net ([172.28.255.1]) by backend31.mail.ord1d.rsapps.net (Dovecot) with LMTP id A5p6GLE7c1rKLwAAgoeIoA for ; Thu, 01 Feb 2018 11:09:21 -0500 Received: from proxy1.mail.ord1c.rsapps.net ([172.28.255.1]) by director5.mail.ord1d.rsapps.net (Dovecot) with LMTP id G7ZLGLE7c1rrGwAAsdCWiw ; Thu, 01 Feb 2018 11:09:21 -0500 Received: from smtp46.gate.ord1a ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy1.mail.ord1c.rsapps.net (Dovecot) with LMTP id qGwAGLE7c1onEQAA2VeTtA ; Thu, 01 Feb 2018 11:09:21 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.34.181.88] Authentication-Results: smtp46.gate.ord1a.rsapps.net; iprev=pass policy.iprev="216.34.181.88"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=karger-me.20150623.gappssmtp.com; dmarc=none (p=nil; dis=none) header.from=karger.me X-Classification-ID: 428d0ce6-076a-11e8-9b13-0019b9c89ddc-1-1 Received: from [216.34.181.88] ([216.34.181.88:34643] helo=lists.sourceforge.net) by smtp46.gate.ord1a.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 3C/D1-27910-0BB337A5; Thu, 01 Feb 2018 11:09:20 -0500 Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1ehHPV-0007O9-2H; Thu, 01 Feb 2018 16:08:25 +0000 Received: from sfi-mx-3.v28.ch3.sourceforge.com ([172.29.28.193] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1ehHPT-0007NL-BR for openvpn-devel@lists.sourceforge.net; Thu, 01 Feb 2018 16:08:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=YjZnJz+G+nhWPlM9BANBaIOcYmzcstxWROBj7pWp8tQ=; b=U2kc8+PxfeDHL+RYSXJTYG5Jy7 68G1u+lW4KrV8jSbl8/bbpWjEWZ4yo3MYnN7Tr9C1Ap1xIvfpG4p/LTtGHm0p+WFm1JTCK3F7hqb/ S3VNzyxHTFABfvJg4UqSbX3KmTRqQrsnn0Xee/ookCdWd+eIRpVXCwre3im49S59j3E8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=YjZnJz+G+nhWPlM9BANBaIOcYmzcstxWROBj7pWp8tQ=; b=Ky++HbAHLRCHJ0OGlFeUKeMVEc S8t6ZpmzbyoZNxqu/U9wh7OL+/4ZCgg5qw8HXcpSm7lPCY4M1KGJHFfwwQF6d4HvBcld9yHwD1oYQ /RmrBItFJWCHXJk6LVndJPieJqeeB3BVsQdbSfCpax2izHrKv3a93jFMpwW5gkSDXMWE=; Received: from mail-wr0-f172.google.com ([209.85.128.172]) by sfi-mx-3.v28.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) id 1ehHPP-0002aE-OS for openvpn-devel@lists.sourceforge.net; Thu, 01 Feb 2018 16:08:23 +0000 Received: by mail-wr0-f172.google.com with SMTP id v15so19560229wrb.8 for ; Thu, 01 Feb 2018 08:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=karger-me.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YjZnJz+G+nhWPlM9BANBaIOcYmzcstxWROBj7pWp8tQ=; b=EK41tg3TO9w8vhBjdmodyHiSU7CnoqM94ZCPs2FQ/J2gf96Lu7YpLbWoRVF2qnbXUa p0IWZWm09CaJrOUj4fXh6sgsQO0phIy9osfU7/0XuuMatk1rbxoYwPDvGVeYQDpXN+cY Ei8wOZ9So9BZ9m6klTw6POGw+JjLJ082e9VpmzScx6RqhuSsSoJ2WPJCbV0C/o4sk8o7 YRpgfGcZuxubPVKO7JPJArChKZWO2D8q/D7wzGCcdkiYfMu86nL7NkGTI826Xn+TasUC P5lzDN2LMzJBf5qxnvqb55AQ1Ry8upW3AD8WfDEjTwXGmGQcZBMg4E9ulnuA6MOiuydF oI7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YjZnJz+G+nhWPlM9BANBaIOcYmzcstxWROBj7pWp8tQ=; b=dx3ypHiYvSQYsSoRHdEk7d9PZSKoQHZYpOZbRHvaETuODEMF75mxcOjlRUt11ghS6h 4kHLNHF4N9MIIJhWOVaLzuzKlB9dtUFkrRq2Z8iLbEDI9/kCr53xQywe8sxTw93pPYCy Ya1uRBdBxN98pbKoo4RdwntfScTLXaiWqGq46sTxB9oq75Qa4SMUChbyovML4VAtqL4K WMf47iNguOmY/O9xc7WzOm6PJs3ibcraA9AcAfJaub7SQkJ0WuCj3xwZX5MBIKG1Clv3 C1l3NhTN+TBMQ9Gk/iZOgSnHfOyfpgWRqWUZOf5oXOgmYBcCbUmFTGyERzvVoti32Ztx pGHg== X-Gm-Message-State: AKwxyteAjKX+y92vCoH6zXQAIjBxlXz+pWue/U4L+6jV6wxZCZ37inlv U+s8U6nt76NhGkfcsAJvcaSqS+hCX9w= X-Google-Smtp-Source: AH8x225zvUglnScJ+MdsChCMxuJh02ki+X3RjsWQdTnDQ697zBZmmrtLogrIdZ3LWTXT2/dC+UeFkQ== X-Received: by 10.223.164.23 with SMTP id d23mr14898411wra.72.1517499942341; Thu, 01 Feb 2018 07:45:42 -0800 (PST) Received: from vesta.homenet.telecomitalia.it (host147-119-static.58-79-b.business.telecomitalia.it. [79.58.119.147]) by smtp.gmail.com with ESMTPSA id d63sm235851wmd.9.2018.02.01.07.45.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2018 07:45:41 -0800 (PST) From: Steffan Karger To: openvpn-devel@lists.sourceforge.net Date: Thu, 1 Feb 2018 16:45:21 +0100 Message-Id: <20180201154521.7642-1-steffan@karger.me> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180201072731.GU69387@greenie.muc.de> References: <20180201072731.GU69387@greenie.muc.de> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.128.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1ehHPP-0002aE-OS Subject: [Openvpn-devel] [PATCH v3] Enable stricter compiler warnings by default X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox 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 Acked-by: Selva Nair --- 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 diff --git a/configure.ac b/configure.ac index 2cbf3358..33b6bc8e 100644 --- a/configure.ac +++ b/configure.ac @@ -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" diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 00000000..dcabb92a --- /dev/null +++ b/m4/ax_check_compile_flag.m4 @@ -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 +# Copyright (c) 2011 Maarten Bosmans +# +# 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 . +# +# 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