inotify: modernize with SAFE_ wrappers and fix minor style issues
PATCH 1/1 inotify: modernize with SAFE_ wrappers and fix minor style issues
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
--- testcases/kernel/syscalls/inotify/inotify02.c | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-)
testcases/kernel/syscalls/inotify/inotify02.c +4 -17
@@ -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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
testcases/kernel/syscalls/inotify/inotify02.c void verify_inotify(void) · line 115
Quoted 1 line
testcases/kernel/syscalls/inotify/inotify02.c +1
-0+ len =SAFE_READ (0 , fd_notify, event_buf,EVENT_BUF_LEN );
is there a reason why you set len_strict to zero in the SAFE_READ() macro?
Kind regards,
Signature · 7 lines
Andrea Cervesato SUSE QE Automation Engineer Linux [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/1 inotify: modernize with SAFE_ wrappers and fix minor style issues
Hi Andrea,
Thanks for the review!
I set len_strict=0 intentionally.
With len_strict=1, SAFE_READ would trigger TBROK on partial reads (e.g. 240 bytes when EVENT_BUF_LEN=32768), which are normal and expected for an inotify fd.
len_strict=0 still catches real read errors (ret=-1), while allowing partial reads so the test can continue processing the events.
Thanks,
Jinseok.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
+1
This patch will be merged when it will receive a second review tag.
Thanks
Signature · 7 lines
Andrea Cervesato SUSE QE Automation Engineer Linux [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Looks obviously correct to me:
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Andrea Cervesato via ltp
AppliedMerged, thanks!
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp