Skip to contentSkip to conversation

Remove break after return

PATCH New Petr Vorel 4 participants 9 messages Mar 28, 2019 – Apr 5, 2019

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

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
index b19a1d1bf..29ebbc5ee 100644
@@ -20,7 +20,6 @@ static int do_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
 	switch (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
index ce0d2ff79..d75807d77 100644
@@ -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
#1 lore raw

PATCH 1/1 Remove break after return

LGTM!

Quoted 45 lines · Petr Vorel

---
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
index b19a1d1bf..29ebbc5ee 100644
@@ -20,7 +20,6 @@ static int do_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
   switch (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
index ce0d2ff79..d75807d77 100644
@@ -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
#2 lore raw

PATCH 1/1 Remove break after return

In reply to Petr Vorel

Hi 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);
#else
tst_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
---
 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
index b19a1d1bf..29ebbc5ee 100644
@@ -20,7 +20,6 @@ static int do_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
 	switch (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
index ce0d2ff79..d75807d77 100644
@@ -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;
 }
#3 lore raw

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]
author
#4 lore raw

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

#5 lore raw

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

author
#6 lore raw

PATCH 1/1 Remove break after return

In reply to Petr Vorel

Hi,

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

#7 lore raw

PATCH 1/1 Remove break after return

In reply to Petr Vorel
Quoted 24 lines · Petr Vorel
---
 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
index b19a1d1bf..29ebbc5ee 100644
@@ -20,7 +20,6 @@ static int do_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
 	switch (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
index ce0d2ff79..d75807d77 100644

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 -2
 	case 1:
 		return tst_syscall(__NR_sigpending, sigset);
-	break;
 	case 2:
 		return tst_syscall(__NR_rt_sigpending, sigset, SIGSETSIZE);
-	break;
 	}
 	return -1;
 }