From 1caf7d6f17fa2e9a2c3fa80579fe7d621c9cd3d5 Mon Sep 17 00:00:00 2001 From: Eero Nurkkala Date: Fri, 25 Mar 2022 12:50:18 +0200 Subject: [PATCH] rptun: fix compile-time warning Fix this compile-time warning: rptun/rptun.c:956:22: warning: '%lx' directive output may be truncated writing between 1 and 16 bytes into a region of size 14 [-Wformat-truncation=] 956 | snprintf(arg1, 16, "0x%" PRIxPTR, (uintptr_t)priv); | ^~~~~ rptun/rptun.c:956:25: note: format string is defined here 956 | snprintf(arg1, 16, "0x%" PRIxPTR, (uintptr_t)priv); rptun/rptun.c:956:22: note: directive argument in the range [1, 18446744073709551615] 956 | snprintf(arg1, 16, "0x%" PRIxPTR, (uintptr_t)priv); | ^~~~~ rptun/rptun.c:956:3: note: 'snprintf' output between 4 and 19 bytes into a destination of size 16 956 | snprintf(arg1, 16, "0x%" PRIxPTR, (uintptr_t)priv); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Eero Nurkkala --- drivers/rptun/rptun.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c index e7467c699d6..3186f7c3cf8 100644 --- a/drivers/rptun/rptun.c +++ b/drivers/rptun/rptun.c @@ -919,7 +919,7 @@ int rptun_initialize(FAR struct rptun_dev_s *dev) struct metal_init_params params = METAL_INIT_DEFAULTS; FAR struct rptun_priv_s *priv; FAR char *argv[3]; - char arg1[16]; + char arg1[19]; char name[32]; int ret; @@ -946,14 +946,14 @@ int rptun_initialize(FAR struct rptun_dev_s *dev) nxsem_init(&priv->sem, 0, RPTUN_IS_AUTOSTART(dev) ? 1 : 0); nxsem_set_protocol(&priv->sem, SEM_PRIO_NONE); - snprintf(name, 32, "/dev/rptun/%s", RPTUN_GET_CPUNAME(dev)); + snprintf(name, sizeof(name), "/dev/rptun/%s", RPTUN_GET_CPUNAME(dev)); ret = register_driver(name, &g_rptun_devops, 0222, priv); if (ret < 0) { goto err_driver; } - snprintf(arg1, 16, "0x%" PRIxPTR, (uintptr_t)priv); + snprintf(arg1, sizeof(arg1), "0x%" PRIxPTR, (uintptr_t)priv); argv[0] = (void *)RPTUN_GET_CPUNAME(dev); argv[1] = arg1; argv[2] = NULL;