* [Patch] selinux: remove an unreachable line @ 2009-12-01 7:41 Amerigo Wang 2009-12-01 7:45 ` Joe Perches 0 siblings, 1 reply; 8+ messages in thread From: Amerigo Wang @ 2009-12-01 7:41 UTC (permalink / raw) To: linux-kernel Cc: Eric Paris, linux-security-module, akpm, Amerigo Wang, James Morris This line is unreachable, remove it. Signed-off-by: WANG Cong <amwang@redhat.com> Cc: James Morris <jmorris@namei.org> Cc: Eric Paris <eparis@parisplace.org> --- diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c index b5407f1..a2f1034 100644 --- a/security/selinux/ss/mls.c +++ b/security/selinux/ss/mls.c @@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext, default: return -EINVAL; } - return -EINVAL; } #ifdef CONFIG_NETLABEL ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Patch] selinux: remove an unreachable line 2009-12-01 7:41 [Patch] selinux: remove an unreachable line Amerigo Wang @ 2009-12-01 7:45 ` Joe Perches 2009-12-01 8:31 ` Cong Wang 0 siblings, 1 reply; 8+ messages in thread From: Joe Perches @ 2009-12-01 7:45 UTC (permalink / raw) To: Amerigo Wang Cc: linux-kernel, Eric Paris, linux-security-module, akpm, James Morris On Tue, 2009-12-01 at 02:41 -0500, Amerigo Wang wrote: > This line is unreachable, remove it. [] > diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c > index b5407f1..a2f1034 100644 > --- a/security/selinux/ss/mls.c > +++ b/security/selinux/ss/mls.c > @@ -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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch] selinux: remove an unreachable line 2009-12-01 7:45 ` Joe Perches @ 2009-12-01 8:31 ` Cong Wang 2009-12-01 10:33 ` James Morris 2009-12-02 12:35 ` Dan Carpenter 0 siblings, 2 replies; 8+ messages in thread From: Cong Wang @ 2009-12-01 8:31 UTC (permalink / raw) To: Joe Perches Cc: linux-kernel, Eric Paris, linux-security-module, akpm, James Morris Joe Perches wrote: > On Tue, 2009-12-01 at 02:41 -0500, Amerigo Wang wrote: >> This line is unreachable, remove it. > [] >> diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c >> index b5407f1..a2f1034 100644 >> --- a/security/selinux/ss/mls.c >> +++ b/security/selinux/ss/mls.c >> @@ -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? ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch] selinux: remove an unreachable line 2009-12-01 8:31 ` Cong Wang @ 2009-12-01 10:33 ` James Morris 2009-12-03 8:38 ` Cong Wang 2009-12-02 12:35 ` Dan Carpenter 1 sibling, 1 reply; 8+ messages in thread From: James Morris @ 2009-12-01 10:33 UTC (permalink / raw) To: Cong Wang Cc: Joe Perches, linux-kernel, Eric Paris, linux-security-module, akpm On Tue, 1 Dec 2009, Cong Wang wrote: > > > 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? Leave the default: there but with a comment /* fall through */ instead of the return. -- James Morris <jmorris@namei.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch] selinux: remove an unreachable line 2009-12-01 10:33 ` James Morris @ 2009-12-03 8:38 ` Cong Wang 0 siblings, 0 replies; 8+ messages in thread From: Cong Wang @ 2009-12-03 8:38 UTC (permalink / raw) To: James Morris Cc: Joe Perches, linux-kernel, Eric Paris, linux-security-module, akpm James Morris wrote: > On Tue, 1 Dec 2009, Cong Wang wrote: > >>>> 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? > > Leave the default: there but with a comment /* fall through */ > instead of the return. > Ok, will do, thanks. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch] selinux: remove an unreachable line 2009-12-01 8:31 ` Cong Wang 2009-12-01 10:33 ` James Morris @ 2009-12-02 12:35 ` Dan Carpenter 2009-12-03 8:39 ` Cong Wang 1 sibling, 1 reply; 8+ messages in thread From: Dan Carpenter @ 2009-12-02 12:35 UTC (permalink / raw) To: Cong Wang Cc: Joe Perches, linux-kernel, Eric Paris, linux-security-module, akpm, James Morris On Tue, Dec 01, 2009 at 04:31:36PM +0800, Cong Wang wrote: > Joe Perches wrote: >> On Tue, 2009-12-01 at 02:41 -0500, Amerigo Wang wrote: >>> This line is unreachable, remove it. >> [] >>> diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c >>> index b5407f1..a2f1034 100644 >>> --- a/security/selinux/ss/mls.c >>> +++ b/security/selinux/ss/mls.c >>> @@ -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? 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch] selinux: remove an unreachable line 2009-12-02 12:35 ` Dan Carpenter @ 2009-12-03 8:39 ` Cong Wang 2009-12-03 19:38 ` Joe Perches 0 siblings, 1 reply; 8+ messages in thread From: Cong Wang @ 2009-12-03 8:39 UTC (permalink / raw) To: Dan Carpenter, Cong Wang, Joe Perches, linux-kernel, Eric Paris, linux-security-module, akpm, James Morris Dan Carpenter wrote: > On Tue, Dec 01, 2009 at 04:31:36PM +0800, Cong Wang wrote: >> Joe Perches wrote: >>> On Tue, 2009-12-01 at 02:41 -0500, Amerigo Wang wrote: >>>> This line is unreachable, remove it. >>> [] >>>> diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c >>>> index b5407f1..a2f1034 100644 >>>> --- a/security/selinux/ss/mls.c >>>> +++ b/security/selinux/ss/mls.c >>>> @@ -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? > > 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... ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch] selinux: remove an unreachable line 2009-12-03 8:39 ` Cong Wang @ 2009-12-03 19:38 ` Joe Perches 0 siblings, 0 replies; 8+ messages in thread From: Joe Perches @ 2009-12-03 19:38 UTC (permalink / raw) To: Cong Wang Cc: Dan Carpenter, linux-kernel, Eric Paris, linux-security-module, akpm, James Morris On Thu, 2009-12-03 at 16:39 +0800, Cong Wang wrote: > Dan Carpenter wrote: > > On Tue, Dec 01, 2009 at 04:31:36PM +0800, Cong Wang wrote: > >> Joe Perches wrote: > >>> On Tue, 2009-12-01 at 02:41 -0500, Amerigo Wang wrote: > >>>> This line is unreachable, remove it. > >>> [] > >>>> diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c > >>>> index b5407f1..a2f1034 100644 > >>>> --- a/security/selinux/ss/mls.c > >>>> +++ b/security/selinux/ss/mls.c > >>>> @@ -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? > > > > 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-12-03 19:38 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-12-01 7:41 [Patch] selinux: remove an unreachable line Amerigo Wang 2009-12-01 7:45 ` Joe Perches 2009-12-01 8:31 ` Cong Wang 2009-12-01 10:33 ` James Morris 2009-12-03 8:38 ` Cong Wang 2009-12-02 12:35 ` Dan Carpenter 2009-12-03 8:39 ` Cong Wang 2009-12-03 19:38 ` Joe Perches
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox