From patchwork Wed Oct 2 06:08:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 60415 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DE95E1BE86; Wed, 2 Oct 2019 08:08:31 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id D91C41BE84 for ; Wed, 2 Oct 2019 08:08:30 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 2 Oct 2019 09:08:29 +0300 Received: from pegasus12.mtr.labs.mlnx (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x9268T6V021836; Wed, 2 Oct 2019 09:08:29 +0300 Received: from pegasus12.mtr.labs.mlnx (localhost [127.0.0.1]) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id x9268T7j017789; Wed, 2 Oct 2019 06:08:29 GMT Received: (from viacheslavo@localhost) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7/Submit) id x9268RS0017780; Wed, 2 Oct 2019 06:08:27 GMT X-Authentication-Warning: pegasus12.mtr.labs.mlnx: viacheslavo set sender to viacheslavo@mellanox.com using -f From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: rasland@mellanox.com, matan@mellanox.com, ferruh.yigit@intel.com, stephen@networkplumber.org Date: Wed, 2 Oct 2019 06:08:25 +0000 Message-Id: <1569996505-17707-1-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1569928223-6600-1-git-send-email-viacheslavo@mellanox.com> References: <1569928223-6600-1-git-send-email-viacheslavo@mellanox.com> Subject: [dpdk-dev] [PATCH v2] net/mlx5: fix compilation issue with gcc pragma X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The GCC compiler might generate warning or error if format parameter of fscanf is not literal. This was suppressed with GCC specific pragms. Some compilers (i.e Intel icc) do not recognize GCC diagnostic pragma. The code was refactored with stringification, pragmas are not needed anymore. Fixes: a46a42b5cd03 ("net/mlx5: add VF LAG mode bonding device recognition") Signed-off-by: Viacheslav Ovsiienko --- v2: code rewritten with stringification v1: http://patches.dpdk.org/patch/60310/ drivers/net/mlx5/mlx5.c | 6 +----- drivers/net/mlx5/mlx5_utils.h | 4 ++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 951b9f5..f751728 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2295,12 +2295,8 @@ struct mlx5_dev_spawn_data { } if (!file) return -1; - MKSTR(format, "%c%us", '%', (unsigned int)(sizeof(ifname) - 1)); - /* Use safe format to check maximal buffer length. */ -#pragma GCC diagnostic ignored "-Wformat-nonliteral" - while (fscanf(file, format, ifname) == 1) { -#pragma GCC diagnostic error "-Wformat-nonliteral" + while (fscanf(file, "%" STRINGIFY(IF_NAMESIZE) "s", ifname) == 1) { char tmp_str[IF_NAMESIZE + 32]; struct rte_pci_addr pci_addr; struct mlx5_switch_info info; diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h index 97092c7..8bafeaa 100644 --- a/drivers/net/mlx5/mlx5_utils.h +++ b/drivers/net/mlx5/mlx5_utils.h @@ -150,6 +150,10 @@ \ snprintf(name, sizeof(name), __VA_ARGS__) +/* Stringification macros. */ +#define STRINGIFY1(x) #x +#define STRINGIFY(x) STRINGIFY1(x) + /** * Return nearest power of two above input value. *