DPDK patches and discussions
 help / color / mirror / Atom feed
From: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
To: dev@dpdk.org
Cc: rasland@mellanox.com, matan@mellanox.com, ferruh.yigit@intel.com,
	stephen@networkplumber.org
Subject: [dpdk-dev] [PATCH v3] net/mlx5: fix compilation issue with gcc pragma
Date: Wed,  2 Oct 2019 12:36:55 +0000	[thread overview]
Message-ID: <1570019815-16177-1-git-send-email-viacheslavo@mellanox.com> (raw)
In-Reply-To: <1569928223-6600-1-git-send-email-viacheslavo@mellanox.com>

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, so 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 <viacheslavo@mellanox.com>
---
 v3: replace with RTE_STR stringifier

 v2: http://patches.dpdk.org/patch/60415/
     code rewritten with stringification

 v1: http://patches.dpdk.org/patch/60310/
     initial version with pragmas and compiler type check

 drivers/net/mlx5/mlx5.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 951b9f5..13d112e 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -2295,12 +2295,9 @@ 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"
+	assert(atol(RTE_STR(IF_NAMESIZE)) == IF_NAMESIZE);
+	while (fscanf(file, "%" RTE_STR(IF_NAMESIZE) "s", ifname) == 1) {
 		char tmp_str[IF_NAMESIZE + 32];
 		struct rte_pci_addr pci_addr;
 		struct mlx5_switch_info	info;
-- 
1.8.3.1


  parent reply	other threads:[~2019-10-02 12:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-01 11:10 [dpdk-dev] [PATCH] " Viacheslav Ovsiienko
2019-10-01 14:54 ` Stephen Hemminger
2019-10-01 17:15   ` Slava Ovsiienko
2019-10-01 23:41     ` Stephen Hemminger
2019-10-02  6:15       ` Slava Ovsiienko
2019-10-02  6:55         ` Slava Ovsiienko
2019-10-02 11:54           ` Ferruh Yigit
2019-10-02 12:40             ` Slava Ovsiienko
2019-10-02  6:08 ` [dpdk-dev] [PATCH v2] " Viacheslav Ovsiienko
2019-10-02 12:36 ` Viacheslav Ovsiienko [this message]
2019-10-02 16:19   ` [dpdk-dev] [PATCH v3] " Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1570019815-16177-1-git-send-email-viacheslavo@mellanox.com \
    --to=viacheslavo@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=matan@mellanox.com \
    --cc=rasland@mellanox.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).