[LTP] [PATCH v2 1/2] open: fix cleanup condition and use snprintf
Jinseok Kim
always.starving0@gmail.com
Wed Feb 18 15:47:26 CET 2026
Replace remaining sprintf() with snprintf() in setup()
Thanks for the review.
Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
---
testcases/kernel/syscalls/open/open04.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/open/open04.c b/testcases/kernel/syscalls/open/open04.c
index 3dc3486d3..5d39c1569 100644
--- a/testcases/kernel/syscalls/open/open04.c
+++ b/testcases/kernel/syscalls/open/open04.c
@@ -30,7 +30,7 @@ static void setup(void)
fds[0] = first;
for (i = first + 1; i < fds_limit; i++) {
- sprintf(fname, FNAME ".%d", i);
+ snprintf(fname, sizeof(fname), FNAME ".%d", i);
fd = open(fname, O_RDWR | O_CREAT, 0777);
if (fd == -1) {
if (errno != EMFILE)
@@ -44,13 +44,13 @@ static void setup(void)
static void run(void)
{
- sprintf(fname, FNAME ".%d", fds_limit);
+ snprintf(fname, sizeof(fname), FNAME ".%d", fds_limit);
TST_EXP_FAIL2(open(fname, O_RDWR | O_CREAT, 0777), EMFILE);
}
static void cleanup(void)
{
- if (!first || !fds)
+ if (first < 0 || !fds)
return;
for (i = first; i < fds_limit; i++)
--
2.43.0
More information about the ltp
mailing list