selinux: remove an unreachable line
PATCH 1/1 selinux: remove an unreachable line
This line is unreachable, remove it.
---
security/selinux/ss/mls.c +0 -1
@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,default :return -EINVAL ; } -return -EINVAL ; }#ifdef CONFIG_NETLABEL
Quoted 1 line · Amerigo Wang
This line is unreachable, remove it.
[]
security/selinux/ss/mls.c int mls_compute_sid(struct context *scontext, · line 547
Quoted 10 lines
security/selinux/ss/mls.c +0
-1@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,default :return -EINVAL ; } -return -EINVAL ; }
I think it's better to remove the default case.
Quoted 16 lines · Joe Perches
Quoted 1 line · Amerigo Wang
This line is unreachable, remove it.
[]
security/selinux/ss/mls.c int mls_compute_sid(struct context *scontext, · line 547
Quoted 10 lines
security/selinux/ss/mls.c +0
-1@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,default :return -EINVAL ; } -return -EINVAL ; }I think it's better to remove the default case.
This is totally a personal taste, I think.
Either is OK. James, any comments?
Quoted 11 lines · Cong Wang
Quoted 8 lines
security/selinux/ss/mls.c int mls_compute_sid(struct context *scontext, · line 547
Quoted 5 lines
security/selinux/ss/mls.c +0
-1default :return -EINVAL ; } -return -EINVAL ; }I think it's better to remove the default case.
This is totally a personal taste, I think.
Either is OK. James, any comments?
Leave the default: there but with a comment /* fall through */ instead of the return.
Signature · 2 lines
James Morris <[email protected]>
Quoted 18 lines · Cong Wang
Quoted 16 lines · Joe Perches
Quoted 1 line · Amerigo Wang
This line is unreachable, remove it.
[]
security/selinux/ss/mls.c int mls_compute_sid(struct context *scontext, · line 547
Quoted 10 lines
security/selinux/ss/mls.c +0
-1@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,default :return -EINVAL ; } -return -EINVAL ; }I think it's better to remove the default case.
Quoted 2 lines
This is totally a personal taste, I think.
Either is OK. James, any comments?
I think the last unreachable return might also stop certain versions of gcc complaining about control reaching the end of a non void function.
regards,
dan carpenter
Quoted 9 lines · James Morris
Quoted 7 lines · Cong Wang
Quoted 7 lines
security/selinux/ss/mls.c int mls_compute_sid(struct context *scontext, · line 547
Quoted 5 lines
security/selinux/ss/mls.c +0
-1default :return -EINVAL ; } -return -EINVAL ; }I think it's better to remove the default case.
Quoted 6 lines
Quoted 2 lines
This is totally a personal taste, I think.
Either is OK. James, any comments?Leave the default: there but with a comment /* fall through */ instead of the return.
Ok, will do, thanks.
Quoted 17 lines · Dan Carpenter
Quoted 16 lines · Cong Wang
Quoted 15 lines · Joe Perches
Quoted 1 line · Amerigo Wang
This line is unreachable, remove it.
[]
security/selinux/ss/mls.c int mls_compute_sid(struct context *scontext, · line 547
Quoted 10 lines
security/selinux/ss/mls.c +0
-1@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,default :return -EINVAL ; } -return -EINVAL ; }I think it's better to remove the default case.
Quoted 6 lines
Quoted 2 lines
This is totally a personal taste, I think.
Either is OK. James, any comments?I think the last unreachable return might also stop certain versions of gcc complaining about control reaching the end of a non void function.
Hmm, aren't those version of gcc buggy? Here we have return values in all cases of 'switch', it shouldn't complain...
Quoted 21 lines · Cong Wang
Quoted 20 lines · Dan Carpenter
Quoted 18 lines · Cong Wang
Quoted 15 lines · Joe Perches
Quoted 1 line · Amerigo Wang
This line is unreachable, remove it.
[]
security/selinux/ss/mls.c int mls_compute_sid(struct context *scontext, · line 547
Quoted 10 lines
security/selinux/ss/mls.c +0
-1@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,default :return -EINVAL ; } -return -EINVAL ; }I think it's better to remove the default case.
This is totally a personal taste, I think.
Either is OK. James, any comments?
Quoted 6 lines
Quoted 3 lines
I think the last unreachable return might also stop certain versions of gcc complaining about control reaching the end of a non void function.
Hmm, aren't those version of gcc buggy? Here we have return values in all cases of 'switch', it shouldn't complain...
Various versions of gcc do complain.
It's also a bit counter-expectation to the reader to find no return at the end of a non-void function.
As a reader, you then have to scan the cases to find the default: case which isn't necessarily at the end.
If it is a simple
default: return foo;
I think it less jarring to omit default from the switch statement and use
return foo; }
at the function exit.