Skip to content

Commit 161c996

Browse files
pkarashchenkoraiden00pl
authored andcommitted
apps: use sizeof array in snprintf
Signed-off-by: Petro Karashchenko <[email protected]>
1 parent 6c88a1a commit 161c996

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

examples/ws2812esp32rmt/ws2812esp32rmt_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ int main(int argc, FAR char *argv[])
157157

158158
uint32_t n_leds = atoi(argv[2]);
159159

160-
char dev_name[50];
161-
snprintf(dev_name, 50, "/dev/rmt%d", ch_idx);
162-
fd = open(dev_name, O_WRONLY);
160+
char devname[50];
161+
snprintf(devname, sizeof(devname), "/dev/rmt%d", ch_idx);
162+
fd = open(devname, O_WRONLY);
163163
if (fd < 0)
164164
{
165165
fprintf(stderr,
166166
"%s: open %s failed: %d\n",
167167
argv[0],
168-
dev_name,
168+
devname,
169169
errno);
170170
goto errout_with_dev;
171171
}

graphics/nxwm/src/cnxterm.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ void CNxTerm::stop(void)
331331
// Construct the driver name using this minor number
332332

333333
char devname[32];
334-
snprintf(devname, 32, "/dev/nxterm%d", m_minor);
334+
snprintf(devname, sizeof(devname), "/dev/nxterm%d", m_minor);
335335

336336
unlink(devname);
337337
m_nxterm = 0;
@@ -460,7 +460,7 @@ int CNxTerm::nxterm(int argc, char *argv[])
460460
// Construct the driver name using this minor number
461461

462462
char devname[32];
463-
snprintf(devname, 32, "/dev/nxterm%d", g_nxtermvars.minor);
463+
snprintf(devname, sizeof(devname), "/dev/nxterm%d", g_nxtermvars.minor);
464464

465465
// Increment the minor number while it is protect by the semaphore
466466

graphics/twm4nx/apps/cnxterm.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ void CNxTerm::stop(void)
330330
// Construct the driver name using this minor number
331331

332332
char devname[32];
333-
snprintf(devname, 32, "/dev/nxterm%d", m_minor);
333+
snprintf(devname, sizeof(devname), "/dev/nxterm%d", m_minor);
334334

335335
unlink(devname);
336336
m_NxTerm = 0;
@@ -373,7 +373,7 @@ int CNxTerm::nxterm(int argc, char *argv[])
373373
// Construct the driver name using this minor number
374374

375375
char devname[32];
376-
snprintf(devname, 32, "/dev/nxterm%d", GNxTermVars.minor);
376+
snprintf(devname, sizeof(devname), "/dev/nxterm%d", GNxTermVars.minor);
377377

378378
// Increment the minor number while it is protect by the semaphore
379379

testing/sensortest/sensortest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ int main(int argc, FAR char *argv[])
350350
goto name_err;
351351
}
352352

353-
snprintf(devname, PATH_MAX, DEVNAME_FMT, name);
353+
snprintf(devname, sizeof(devname), DEVNAME_FMT, name);
354354
fd = open(devname, O_RDONLY | O_NONBLOCK);
355355
if (fd < 0)
356356
{

0 commit comments

Comments
 (0)