Remove break after return
PATCH 1/1 Remove break after return
--- testcases/kernel/syscalls/select/select_var.h | 1 - testcases/kernel/syscalls/sigpending/sigpending02.c | 3 --- 2 files changed, 4 deletions(-)
testcases/kernel/syscalls/select/select_var.h +0 -1
@@ -20,7 +20,6 @@ static int do_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptswitch (tst_variant) {case 0 :return select (nfds, readfds, writefds, exceptfds, timeout); -break ;case 1 : {#ifdef __LP64__return tst_syscall (__NR_select, nfds, readfds, writefds, exceptfds, timeout);
testcases/kernel/syscalls/sigpending/sigpending02.c +0 -3
@@ -37,13 +37,10 @@ static int tested_sigpending(sigset_t *sigset)switch (tst_variant) {case 0 :return sigpending (sigset); -break ;case 1 :return tst_syscall (__NR_sigpending, sigset); -break ;case 2 :return tst_syscall (__NR_rt_sigpending, sigset,SIGSETSIZE ); -break ; }return -1 ; }
Signature · 1 line
2.20.1
PATCH 1/1 Remove break after return
LGTM!
Quoted 45 lines · Petr Vorel
Reported-by Xiao Yang <[email protected]>Signed-off-by Petr Vorel <[email protected]>---
testcases/kernel/syscalls/select/select_var.h| 1 -testcases/kernel/syscalls/sigpending/sigpending02.c| 3 ---2 files changed, 4 deletions(-)testcases/kernel/syscalls/select/select_var.h +0
-1@@ -20,7 +20,6 @@ static int do_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptswitch (tst_variant) {case 0 :return select (nfds, readfds, writefds, exceptfds, timeout); -break ;case 1 : {#ifdef __LP64__return tst_syscall (__NR_select, nfds, readfds, writefds, exceptfds, timeout);testcases/kernel/syscalls/sigpending/sigpending02.c +0
-3@@ -37,13 +37,10 @@ static int tested_sigpending(sigset_t *sigset)switch (tst_variant) {case 0 :return sigpending (sigset); -break ;case 1 :return tst_syscall (__NR_sigpending, sigset); -break ;case 2 :return tst_syscall (__NR_rt_sigpending, sigset,SIGSETSIZE ); -break ; }return -1 ; }Signature · 5 lines
2.20.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/1 Remove break after return
In reply to Petr VorelHi Petr,
Thanks for your cleanup. :-)
Can we also remove break after calling tst_brk()?
For example:
1) The code at do_select(...) in select_var.h
-------------------------------------------------
case 3:
#ifdef __NR__newselect
return tst_syscall(__NR__newselect, nfds, readfds, writefds, exceptfds, timeout);
#elsetst_brk(TCONF, "__NR__newselect not implemented");
#endif
break;
-------------------------------------------------
2) The code at do_test(...) in newlib_tests/variant.c
-------------------------------------------------
switch (tst_variant) {
case 0:
/* This is skipped after first iteration */ tst_brk(TCONF, "Test skipped");
break;
case 1:
/* This test is correctly looped with -i opt */ tst_res(TPASS, "Test passed");
break;
case 2:
/* This exits the test immediatelly */ tst_brk(TBROK, "Test broken");
break;
}
tst_res(TINFO, "test() function exitting normaly");
-------------------------------------------------
Best Regards,
Xiao Yang
Quoted 37 lines · Petr Vorel
Reported-by Xiao Yang <[email protected]>Signed-off-by Petr Vorel <[email protected]>--- testcases/kernel/syscalls/select/select_var.h | 1 - testcases/kernel/syscalls/sigpending/sigpending02.c | 3 --- 2 files changed, 4 deletions(-)testcases/kernel/syscalls/select/select_var.h +0
-1@@ -20,7 +20,6 @@ static int do_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptswitch (tst_variant) {case 0 :return select (nfds, readfds, writefds, exceptfds, timeout); -break ;case 1 : {#ifdef __LP64__return tst_syscall (__NR_select, nfds, readfds, writefds, exceptfds, timeout);testcases/kernel/syscalls/sigpending/sigpending02.c +0
-3@@ -37,13 +37,10 @@ static int tested_sigpending(sigset_t *sigset)switch (tst_variant) {case 0 :return sigpending (sigset); -break ;case 1 :return tst_syscall (__NR_sigpending, sigset); -break ;case 2 :return tst_syscall (__NR_rt_sigpending, sigset,SIGSETSIZE ); -break ; }return -1 ; }
PATCH 1/1 Remove break after return
Hi!
Quoted 3 lines
Thanks for your cleanup. :-)
Can we also remove break after calling
tst_brk()?
AFAIK that would generate warnings, since compiler cannot deduce on it's own that the call will not return.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 Remove break after return
Hi,
Quoted 4 lines
Quoted 1 line
Can we also remove break after calling
tst_brk()?AFAIK that would generate warnings, since compiler cannot deduce on it's own that the call will not return.
Agree.
Kind regards,
Petr
PATCH 1/1 Remove break after return
Quoted 5 lines · Petr Vorel
Quoted 3 lines
Quoted 3 lines
Can we also remove break after calling
tst_brk()?
AFAIK that would generate warnings, since compiler cannot deduce on it's own that the call will not return.Agree.
Hi,
Thanks for your explanation.
Other than the question, it looks good to me.
Best Regards,
Xiao Yang
PATCH 1/1 Remove break after return
In reply to Petr VorelHi,
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
Can we also remove break after calling
tst_brk()?AFAIK that would generate warnings, since compiler cannot deduce on it's own that the call will not return.
Agree.
patchset merged (short variant).
NOTE: Warning is produced only on gcc (to my surprise only new versions: up to gcc 6 it's ok, 7 and 8 warns):
In file included from variant.c:6:variant.c: In function ‘do_test’:../../include/tst_test.h:76:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
tst_brk_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__);\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
variant.c:13:3: note: in expansion of macro ‘tst_brk’
tst_brk(TCONF, "Test skipped");
Kind regards,
Petr
PATCH 1/1 Remove break after return
In reply to Petr VorelQuoted 24 lines · Petr Vorel
Reported-by Xiao Yang <[email protected]>Signed-off-by Petr Vorel <[email protected]>--- testcases/kernel/syscalls/select/select_var.h | 1 - testcases/kernel/syscalls/sigpending/sigpending02.c | 3 --- 2 files changed, 4 deletions(-)testcases/kernel/syscalls/select/select_var.h +0
-1@@ -20,7 +20,6 @@ static int do_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptswitch (tst_variant) {case 0 :return select (nfds, readfds, writefds, exceptfds, timeout); -break ;case 1 : {#ifdef __LP64__return tst_syscall (__NR_select, nfds, readfds, writefds, exceptfds, timeout);testcases/kernel/syscalls/sigpending/sigpending02.c +0
-0
testcases/kernel/syscalls/sigpending/sigpending02.c static int tested_sigpending(sigset_t *sigset) · line 40
Quoted 4 lines
testcases/kernel/syscalls/sigpending/sigpending02.c +0
-1@@ -37,13 +37,10 @@ static int tested_sigpending(sigset_t *sigset)switch (tst_variant) {case 0 :return sigpending (sigset); -break ;
Hi Petr,
I have added libc sigpending() detection by the following patch:
http://lists.linux.it/pipermail/ltp/2019-April/011590.html
Perhaps, we should avoid potential compiler warnings by keeping the break here.
Best Regards,
Xiao Yang
Quoted 9 lines
testcases/kernel/syscalls/sigpending/sigpending02.c +0
-2case 1 :return tst_syscall (__NR_sigpending, sigset); -break ;case 2 :return tst_syscall (__NR_rt_sigpending, sigset,SIGSETSIZE ); -break ; }return -1 ; }
PATCH 1/1 Remove break after return
Hi Xiao,
Quoted 5 lines
I have added libc
sigpending()detection by the following patch:
http://lists.linux.it/pipermail/ltp/2019-April/011590.htmlPerhaps, we should avoid potential compiler warnings by keeping the break here.
Oh yes, adding break after tst_brk in [1] (in case of #ifndef HAVE_STIME) is correct.
Kind regards,
Petr