DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Jacek Siuda <jck@semihalf.com>,
	Tomasz Duszynski <tdu@semihalf.com>,
	Dmitri Epshtein <dima@marvell.com>,
	Natalie Samsonov <nsamsono@marvell.com>,
	Jianbo Liu <jianbo.liu@arm.com>
Cc: dev@dpdk.org, Ferruh Yigit <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH] net/mrvl: fix build error with gcc
Date: Thu, 22 Mar 2018 18:18:47 +0000	[thread overview]
Message-ID: <20180322181847.74246-1-ferruh.yigit@intel.com> (raw)

gcc version:
aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011

build error:
  CC mrvl_qos.o
.../drivers/net/mrvl/mrvl_qos.c: In function ‘mrvl_configure_rxqs’:
.../drivers/net/mrvl/mrvl_qos.c:679:17:
  error: ‘sprintf’ may write a terminating nul past the end of the
         destination [-Werror=format-overflow=]
  sprintf(match, "policer-%d:%d\n", priv->pp_id, priv->ppio_id);
                 ^~~~~~~~~~~~~~~~~
.../drivers/net/mrvl/mrvl_qos.c:679:2:
  note: ‘sprintf’ output between 13 and 17 bytes into a destination
        of size 16
  sprintf(match, "policer-%d:%d\n", priv->pp_id, priv->ppio_id);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixed by replacing sprintf to snprintf.

Fixes: 8860fd7b70f0 ("net/mrvl: add ingress policer support")
Cc: tdu@semihalf.com

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
---
 drivers/net/mrvl/mrvl_qos.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mrvl/mrvl_qos.c b/drivers/net/mrvl/mrvl_qos.c
index e9c4531fd..741d3da7a 100644
--- a/drivers/net/mrvl/mrvl_qos.c
+++ b/drivers/net/mrvl/mrvl_qos.c
@@ -676,7 +676,8 @@ setup_policer(struct mrvl_priv *priv, struct pp2_cls_plcr_params *params)
 	char match[16];
 	int ret;
 
-	sprintf(match, "policer-%d:%d\n", priv->pp_id, priv->ppio_id);
+	snprintf(match, sizeof(match), "policer-%d:%d\n",
+			priv->pp_id, priv->ppio_id);
 	params->match = match;
 
 	ret = pp2_cls_plcr_init(params, &priv->policer);
-- 
2.13.6

             reply	other threads:[~2018-03-22 18:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22 18:18 Ferruh Yigit [this message]
2018-03-23  7:52 ` Tomasz Duszynski
2018-03-27 19:11   ` 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=20180322181847.74246-1-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=dima@marvell.com \
    --cc=jck@semihalf.com \
    --cc=jianbo.liu@arm.com \
    --cc=nsamsono@marvell.com \
    --cc=tdu@semihalf.com \
    /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).