[v2] net/mlx5: fix compilation issue with gcc pragma
Checks
Commit Message
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 <viacheslavo@mellanox.com>
---
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(-)
@@ -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;
@@ -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.
*