From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id C51EBA04E0;
	Fri, 29 Nov 2019 18:11:00 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 9A0EA4C90;
	Fri, 29 Nov 2019 18:10:45 +0100 (CET)
Received: from mga09.intel.com (mga09.intel.com [134.134.136.24])
 by dpdk.org (Postfix) with ESMTP id 3056D293C
 for <dev@dpdk.org>; Fri, 29 Nov 2019 18:10:42 +0100 (CET)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga005.fm.intel.com ([10.253.24.32])
 by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 29 Nov 2019 09:10:41 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.69,257,1571727600"; d="scan'208";a="409684850"
Received: from silpixa00399838.ir.intel.com (HELO
 silpixa00399838.ger.corp.intel.com) ([10.237.222.120])
 by fmsmga005.fm.intel.com with ESMTP; 29 Nov 2019 09:10:40 -0800
From: Kevin Laatz <kevin.laatz@intel.com>
To: dev@dpdk.org
Cc: david.marchand@redhat.com, thomas@monjalon.net, bruce.richardson@intel.com,
 ray.kinsella@intel.com
Date: Fri, 29 Nov 2019 17:10:19 +0000
Message-Id: <20191129171024.56165-3-kevin.laatz@intel.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20191129171024.56165-1-kevin.laatz@intel.com>
References: <20191023010754.65172-1-kevin.laatz@intel.com>
 <20191129171024.56165-1-kevin.laatz@intel.com>
Subject: [dpdk-dev] [PATCH v2 2/7] build: use meson warning levels
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

From: Bruce Richardson <bruce.richardson@intel.com>

Rather than trying to manage all the cflags ourselves, we can use meson
warning levels to give the user more control. We remove the Wextra flag and
rely on meson to add it, by bumping up our default warning level.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/meson.build | 40 +++++++++++++++++++++-------------------
 meson.build        |  3 ++-
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/config/meson.build b/config/meson.build
index 364a8d739..36a594970 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -158,31 +158,33 @@ endif
 # add -include rte_config to cflags
 add_project_arguments('-include', 'rte_config.h', language: 'c')
 
-# enable extra warnings and disable any unwanted warnings
+# enable extra warnings and disable any unwanted warnings. "-Wall" is added
+# by meson at warning level 1, and "-Wextra" at level 2, so we can omit
+# those. Add extra warnings at level 2 or above. (2 is default level).
 warning_flags = [
-	# -Wall is added by meson by default, so add -Wextra only
-	'-Wextra',
-
-	# additional warnings in alphabetical order
-	'-Wcast-qual',
-	'-Wdeprecated',
-	'-Wformat-nonliteral',
-	'-Wformat-security',
-	'-Wmissing-declarations',
-	'-Wmissing-prototypes',
-	'-Wnested-externs',
-	'-Wold-style-definition',
-	'-Wpointer-arith',
-	'-Wsign-compare',
-	'-Wstrict-prototypes',
-	'-Wundef',
-	'-Wwrite-strings',
-
 	# globally disabled warnings
 	'-Wno-address-of-packed-member',
 	'-Wno-packed-not-aligned',
 	'-Wno-missing-field-initializers'
 ]
+if get_option('warning_level').to_int() >= 2
+	warning_flags += [
+		# additional warnings in alphabetical order
+		'-Wcast-qual',
+		'-Wdeprecated',
+		'-Wformat-nonliteral',
+		'-Wformat-security',
+		'-Wmissing-declarations',
+		'-Wmissing-prototypes',
+		'-Wnested-externs',
+		'-Wold-style-definition',
+		'-Wpointer-arith',
+		'-Wsign-compare',
+		'-Wstrict-prototypes',
+		'-Wundef',
+		'-Wwrite-strings',
+	]
+endif
 if not dpdk_conf.get('RTE_ARCH_64')
 # for 32-bit, don't warn about casting a 32-bit pointer to 64-bit int - it's fine!!
 	warning_flags += '-Wno-pointer-to-int-cast'
diff --git a/meson.build b/meson.build
index 3b7a2e7de..7a8f97ad6 100644
--- a/meson.build
+++ b/meson.build
@@ -8,7 +8,8 @@ project('DPDK', 'C',
 		files('VERSION')).stdout().strip(),
 	license: 'BSD',
 	default_options: ['buildtype=debugoptimized',
-			'default_library=static'],
+			'default_library=static',
+			'warning_level=2'],
 	meson_version: '>= 0.47.1'
 )
 
-- 
2.17.1