patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: stable@dpdk.org
Cc: ktraynor@redhat.com, Ali Alnubani <alialnu@mellanox.com>,
	Matan Azrad <matan@mellanox.com>
Subject: [dpdk-stable] [18.11 4/7] net/mlx: fix build with clang 9
Date: Thu,  9 Jan 2020 13:34:30 +0000
Message-ID: <20200109133433.12494-5-ktraynor@redhat.com> (raw)
In-Reply-To: <20200109133433.12494-1-ktraynor@redhat.com>

From: Ali Alnubani <alialnu@mellanox.com>

[ upstream commit c3e89f69facbbfe131b6a6723665d48801ac943d ]

This rewrites the MKSTR macro appending an empty string to its arguments
to resolve build failures similar to:

  drivers/net/mlx4/mlx4.c:461:14: fatal error: format string is not a
  string literal [-Wformat-nonliteral]
          MKSTR(path, "%s/device/uevent", device->ibdev_path);

  drivers/net/mlx4/mlx4_utils.h:82:30: note: expanded from macro 'MKSTR'
          char name[snprintf(NULL, 0, __VA_ARGS__) + 1]; \

  drivers/net/mlx5/mlx5_stats.c:144:15: fatal error: format string is not a
  string literal [-Wformat-nonliteral]
  	MKSTR(path, "%s/ports/%d/hw_counters/%s",

  drivers/net/mlx5/mlx5_utils.h:149:30: note: expanded from macro 'MKSTR'
  	char name[snprintf(NULL, 0, __VA_ARGS__) + 1]; \

The errors reproduce with clang version 9.0.0, and the release notes
don't mention what could have caused them.

Fixes: 7fae69eeff13 ("mlx4: new poll mode driver")
Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")

Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx4/mlx4_utils.h | 5 +++--
 drivers/net/mlx5/mlx5_utils.h | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_utils.h b/drivers/net/mlx4/mlx4_utils.h
index 2a550df88..a774ccba3 100644
--- a/drivers/net/mlx4/mlx4_utils.h
+++ b/drivers/net/mlx4/mlx4_utils.h
@@ -78,7 +78,8 @@ pmd_drv_log_basename(const char *s)
 /** Allocate a buffer on the stack and fill it with a printf format string. */
 #define MKSTR(name, ...) \
-	char name[snprintf(NULL, 0, __VA_ARGS__) + 1]; \
+	int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \
+	char name[mkstr_size_##name + 1]; \
 	\
-	snprintf(name, sizeof(name), __VA_ARGS__)
+	snprintf(name, sizeof(name), "" __VA_ARGS__)
 
 /** Generate a string out of the provided arguments. */
diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h
index 97092c749..fa495b378 100644
--- a/drivers/net/mlx5/mlx5_utils.h
+++ b/drivers/net/mlx5/mlx5_utils.h
@@ -147,7 +147,8 @@ extern int mlx5_logtype;
 /* Allocate a buffer on the stack and fill it with a printf format string. */
 #define MKSTR(name, ...) \
-	char name[snprintf(NULL, 0, __VA_ARGS__) + 1]; \
+	int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \
+	char name[mkstr_size_##name + 1]; \
 	\
-	snprintf(name, sizeof(name), __VA_ARGS__)
+	snprintf(name, sizeof(name), "" __VA_ARGS__)
 
 /**
-- 
2.21.1


  parent reply	other threads:[~2020-01-09 13:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-09 13:34 [dpdk-stable] [18.11 0/7] Build fixes for 18.11 branch Kevin Traynor
2020-01-09 13:34 ` [dpdk-stable] [18.11 1/7] eal: drop unused macros for primary process check Kevin Traynor
2020-01-09 13:34 ` [dpdk-stable] [18.11 2/7] eventdev: use same log macro for all unsupported calls Kevin Traynor
2020-01-09 13:34 ` [dpdk-stable] [18.11 3/7] eal: remove legacy PMD log macro Kevin Traynor
2020-01-09 13:34 ` Kevin Traynor [this message]
2020-01-09 13:34 ` [dpdk-stable] [18.11 5/7] kni: fix ethtool build for gcc 9 Kevin Traynor
2020-01-09 13:34 ` [dpdk-stable] [18.11 6/7] pmdinfogen: fix freebsd build Kevin Traynor
2020-01-09 15:50   ` Neil Horman
2020-01-09 15:53   ` Neil Horman
2020-01-09 16:53     ` Kevin Traynor
2020-01-09 13:34 ` [dpdk-stable] [18.11 7/7] net/mlx: allow build only on Linux Kevin Traynor
2020-01-13 16:16 ` [dpdk-stable] [18.11 0/7] Build fixes for 18.11 branch Kevin Traynor
2020-01-14 14:29   ` Kevin Traynor

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=20200109133433.12494-5-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=alialnu@mellanox.com \
    --cc=matan@mellanox.com \
    --cc=stable@dpdk.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

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git