[dpdk-dev] [PATCH] net/mrvl: fix build error with gcc
Ferruh Yigit
ferruh.yigit at intel.com
Thu Mar 22 19:18:47 CET 2018
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 at semihalf.com
Signed-off-by: Ferruh Yigit <ferruh.yigit at 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
More information about the dev
mailing list