apps: use sizeof array in snprintf
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
diff --git a/examples/ws2812esp32rmt/ws2812esp32rmt_main.c b/examples/ws2812esp32rmt/ws2812esp32rmt_main.c
index 4f1c7f9..892c135 100644
--- a/examples/ws2812esp32rmt/ws2812esp32rmt_main.c
+++ b/examples/ws2812esp32rmt/ws2812esp32rmt_main.c
@@ -157,15 +157,15 @@
uint32_t n_leds = atoi(argv[2]);
- char dev_name[50];
- snprintf(dev_name, 50, "/dev/rmt%d", ch_idx);
- fd = open(dev_name, O_WRONLY);
+ char devname[50];
+ snprintf(devname, sizeof(devname), "/dev/rmt%d", ch_idx);
+ fd = open(devname, O_WRONLY);
if (fd < 0)
{
fprintf(stderr,
"%s: open %s failed: %d\n",
argv[0],
- dev_name,
+ devname,
errno);
goto errout_with_dev;
}
diff --git a/graphics/nxwm/src/cnxterm.cxx b/graphics/nxwm/src/cnxterm.cxx
index d84fd1b..2df27c3 100644
--- a/graphics/nxwm/src/cnxterm.cxx
+++ b/graphics/nxwm/src/cnxterm.cxx
@@ -331,7 +331,7 @@
// Construct the driver name using this minor number
char devname[32];
- snprintf(devname, 32, "/dev/nxterm%d", m_minor);
+ snprintf(devname, sizeof(devname), "/dev/nxterm%d", m_minor);
unlink(devname);
m_nxterm = 0;
@@ -460,7 +460,7 @@
// Construct the driver name using this minor number
char devname[32];
- snprintf(devname, 32, "/dev/nxterm%d", g_nxtermvars.minor);
+ snprintf(devname, sizeof(devname), "/dev/nxterm%d", g_nxtermvars.minor);
// Increment the minor number while it is protect by the semaphore
diff --git a/graphics/twm4nx/apps/cnxterm.cxx b/graphics/twm4nx/apps/cnxterm.cxx
index d3cbd99..67a964c 100644
--- a/graphics/twm4nx/apps/cnxterm.cxx
+++ b/graphics/twm4nx/apps/cnxterm.cxx
@@ -330,7 +330,7 @@
// Construct the driver name using this minor number
char devname[32];
- snprintf(devname, 32, "/dev/nxterm%d", m_minor);
+ snprintf(devname, sizeof(devname), "/dev/nxterm%d", m_minor);
unlink(devname);
m_NxTerm = 0;
@@ -373,7 +373,7 @@
// Construct the driver name using this minor number
char devname[32];
- snprintf(devname, 32, "/dev/nxterm%d", GNxTermVars.minor);
+ snprintf(devname, sizeof(devname), "/dev/nxterm%d", GNxTermVars.minor);
// Increment the minor number while it is protect by the semaphore
diff --git a/testing/sensortest/sensortest.c b/testing/sensortest/sensortest.c
index 8544d67..ca309aa 100644
--- a/testing/sensortest/sensortest.c
+++ b/testing/sensortest/sensortest.c
@@ -350,7 +350,7 @@
goto name_err;
}
- snprintf(devname, PATH_MAX, DEVNAME_FMT, name);
+ snprintf(devname, sizeof(devname), DEVNAME_FMT, name);
fd = open(devname, O_RDONLY | O_NONBLOCK);
if (fd < 0)
{