* fixing warning "else is not generally useful after a break or return"
@ 2018-02-17 12:46 Dafna Hirschfeld
2018-02-17 13:16 ` [Outreachy kernel] " Julia Lawall
2018-02-17 13:19 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Dafna Hirschfeld @ 2018-02-17 12:46 UTC (permalink / raw)
To: outreachy-kernel
[-- Attachment #1.1: Type: text/plain, Size: 665 bytes --]
Hi,
I see this warning "else is not generally useful after a break or return":
#532: FILE: drivers/staging/vt6655/rxtx.c:532:
+ return buf->duration_a;
+ } else {
So the standard is to remove the "else" line when it is not necessary ?
In the function s_uFillDataHead
<https://elixir.bootlin.com/linux/v3.4/source/drivers/staging/vt6655/rxtx.c#L712> there
are more "else" statements that are redundant, for example this
<https://elixir.bootlin.com/linux/v3.4/source/drivers/staging/vt6655/rxtx.c#L786> one
since the "if" it relates to always returns.
So all redundant "else / else if" should be removed ?
Thanks,
Dafna
[-- Attachment #1.2: Type: text/html, Size: 957 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Outreachy kernel] fixing warning "else is not generally useful after a break or return"
2018-02-17 12:46 fixing warning "else is not generally useful after a break or return" Dafna Hirschfeld
@ 2018-02-17 13:16 ` Julia Lawall
2018-02-17 13:19 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2018-02-17 13:16 UTC (permalink / raw)
To: Dafna Hirschfeld; +Cc: outreachy-kernel
[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]
On Sat, 17 Feb 2018, Dafna Hirschfeld wrote:
> Hi,
> I see this warning "else is not generally useful after a break or return":
>
> #532: FILE: drivers/staging/vt6655/rxtx.c:532:
> + return buf->duration_a;
> + } else {
>
> So the standard is to remove the "else" line when it is not necessary ?
>
> In the function s_uFillDataHead there are more "else" statements that are
> redundant, for example this one since the "if" it relates to always
> returns.
>
> So all redundant "else / else if" should be removed ?
Not sure. Because in these cases the branches are declaring local
variables. And the then and else branches seem kind of parallel. So it
is probably better to leave them as they are.
julia
>
> Thanks,
> Dafna
>
> --
> You received this message because you are subscribed to the Google Groups
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/f8e55043-fbe6-4046-baee-
> c3ca4e8d3c8e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Outreachy kernel] fixing warning "else is not generally useful after a break or return"
2018-02-17 12:46 fixing warning "else is not generally useful after a break or return" Dafna Hirschfeld
2018-02-17 13:16 ` [Outreachy kernel] " Julia Lawall
@ 2018-02-17 13:19 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2018-02-17 13:19 UTC (permalink / raw)
To: Dafna Hirschfeld; +Cc: outreachy-kernel
On Sat, Feb 17, 2018 at 04:46:35AM -0800, Dafna Hirschfeld wrote:
> Hi,
> I see this warning "else is not generally useful after a break or return":
>
> #532: FILE: drivers/staging/vt6655/rxtx.c:532:
> + return buf->duration_a;
> + } else {
>
> So the standard is to remove the "else" line when it is not necessary ?
>
> In the function s_uFillDataHead
> <https://elixir.bootlin.com/linux/v3.4/source/drivers/staging/vt6655/rxtx.c#L712> there
> are more "else" statements that are redundant, for example this
Note, the v3.4 kernel is _very_ old (it was released back in May of
2012). Please look at the most recent kernel source tree.
That being said, yes, removing the else line after a return statement is
a good thing to do.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-17 13:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-17 12:46 fixing warning "else is not generally useful after a break or return" Dafna Hirschfeld
2018-02-17 13:16 ` [Outreachy kernel] " Julia Lawall
2018-02-17 13:19 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.