[LTP] [PATCH] inotify: modernize with SAFE_ wrappers and fix minor style issues
Jinseok Kim
always.starving0@gmail.com
Sat Feb 7 18:06:29 CET 2026
These are small cleanups to align with current LTP style:
- Use SAFE_ wrappers instead of manual calls
- Remove trailing comma in tst_res() for cleaner logs
Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
---
testcases/kernel/syscalls/inotify/inotify02.c | 21 ++++---------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/testcases/kernel/syscalls/inotify/inotify02.c b/testcases/kernel/syscalls/inotify/inotify02.c
index 709a92830..314c1bd49 100644
--- a/testcases/kernel/syscalls/inotify/inotify02.c
+++ b/testcases/kernel/syscalls/inotify/inotify02.c
@@ -64,11 +64,7 @@ void verify_inotify(void)
strcpy(event_set[test_cnt].name, "");
test_cnt++;
- if ((fd = creat(FILE_NAME1, 0755)) == -1) {
- tst_brk(TBROK | TERRNO,
- "creat(\"%s\", 755) failed", FILE_NAME1);
- }
-
+ fd = SAFE_CREAT(FILE_NAME1, 0755);
event_set[test_cnt].mask = IN_CREATE;
strcpy(event_set[test_cnt].name, FILE_NAME1);
test_cnt++;
@@ -89,11 +85,7 @@ void verify_inotify(void)
strcpy(event_set[test_cnt].name, FILE_NAME2);
test_cnt++;
- if (getcwd(fname1, BUF_SIZE) == NULL) {
- tst_brk(TBROK | TERRNO,
- "getcwd(%p, %d) failed", fname1, BUF_SIZE);
- }
-
+ SAFE_GETCWD(fname1, BUF_SIZE);
snprintf(fname2, BUF_SIZE, "%s.rename1", fname1);
SAFE_RENAME(fname1, fname2);
event_set[test_cnt].mask = IN_MOVE_SELF;
@@ -120,12 +112,7 @@ void verify_inotify(void)
test_cnt++;
int len, i = 0, test_num = 0;
- if ((len = read(fd_notify, event_buf, EVENT_BUF_LEN)) == -1) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
-
- }
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
while (i < len) {
struct inotify_event *event;
@@ -208,7 +195,7 @@ static void cleanup(void)
{
if (reap_wd && myinotify_rm_watch(fd_notify, wd) < 0) {
tst_res(TWARN,
- "inotify_rm_watch (%d, %d) failed,", fd_notify, wd);
+ "inotify_rm_watch (%d, %d) failed", fd_notify, wd);
}
if (fd_notify > 0)
--
2.43.0
More information about the ltp
mailing list