From: Joe Perches <joe@perches.com>
To: Cong Wang <amwang@redhat.com>
Cc: Dan Carpenter <error27@gmail.com>,
linux-kernel@vger.kernel.org, Eric Paris <eparis@parisplace.org>,
linux-security-module@vger.kernel.org, akpm@linux-foundation.org,
James Morris <jmorris@namei.org>
Subject: Re: [Patch] selinux: remove an unreachable line
Date: Thu, 03 Dec 2009 11:38:47 -0800 [thread overview]
Message-ID: <1259869127.22783.70.camel@Joe-Laptop.home> (raw)
In-Reply-To: <4B17793F.7050708@redhat.com>
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.
prev parent reply other threads:[~2009-12-03 19:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-01 7:41 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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1259869127.22783.70.camel@Joe-Laptop.home \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=amwang@redhat.com \
--cc=eparis@parisplace.org \
--cc=error27@gmail.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®