* fallthrough question
@ 2022-02-18 21:57 Randy Dunlap
2022-02-18 23:15 ` Gustavo A. R. Silva
2022-02-19 11:08 ` Joe Perches
0 siblings, 2 replies; 4+ messages in thread
From: Randy Dunlap @ 2022-02-18 21:57 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: linux-kernel@vger.kernel.org
Hi,
I expected this to produce a fallthrough warning, but it doesn't
(with gcc 11.1.0):
from sound/oss/dmasound/dmasound_core.c:#1481, when falling from case 1
into case 0: (in arch/m68k/ selected builds only)
case 1:
if ((size = ints[2]) < 256) /* check for small buffer specs */
size <<= 10 ;
if (size < MIN_BUFSIZE || size > MAX_BUFSIZE)
printk("dmasound_setup: invalid write buffer size, using default = %d\n", writeBufSize);
else
writeBufSize = size;
case 0:
break;
default:
Can you tell me what is going on here?
thanks.
--
~Randy
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: fallthrough question
2022-02-18 21:57 fallthrough question Randy Dunlap
@ 2022-02-18 23:15 ` Gustavo A. R. Silva
2022-02-18 23:41 ` Randy Dunlap
2022-02-19 11:08 ` Joe Perches
1 sibling, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2022-02-18 23:15 UTC (permalink / raw)
To: Randy Dunlap; +Cc: linux-kernel@vger.kernel.org
Hi there,
On Fri, Feb 18, 2022 at 01:57:58PM -0800, Randy Dunlap wrote:
> Hi,
>
> I expected this to produce a fallthrough warning, but it doesn't
> (with gcc 11.1.0):
>
> from sound/oss/dmasound/dmasound_core.c:#1481, when falling from case 1
> into case 0: (in arch/m68k/ selected builds only)
>
> case 1:
> if ((size = ints[2]) < 256) /* check for small buffer specs */
> size <<= 10 ;
> if (size < MIN_BUFSIZE || size > MAX_BUFSIZE)
> printk("dmasound_setup: invalid write buffer size, using default = %d\n", writeBufSize);
> else
> writeBufSize = size;
> case 0:
> break;
> default:
>
> Can you tell me what is going on here?
As you can see the warning is suppressed when a case label falls through to
a case that merely breaks... or returns, or continues (continue statement)
or that goes to (goto statement) some other place.
However, Clang disagrees with this. See below for more:
https://github.com/ClangBuiltLinux/linux/issues/636
https://godbolt.org/z/xgkvIh
--
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: fallthrough question
2022-02-18 23:15 ` Gustavo A. R. Silva
@ 2022-02-18 23:41 ` Randy Dunlap
0 siblings, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2022-02-18 23:41 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: linux-kernel@vger.kernel.org
On 2/18/22 15:15, Gustavo A. R. Silva wrote:
> Hi there,
>
> On Fri, Feb 18, 2022 at 01:57:58PM -0800, Randy Dunlap wrote:
>> Hi,
>>
>> I expected this to produce a fallthrough warning, but it doesn't
>> (with gcc 11.1.0):
>>
>> from sound/oss/dmasound/dmasound_core.c:#1481, when falling from case 1
>> into case 0: (in arch/m68k/ selected builds only)
>>
>> case 1:
>> if ((size = ints[2]) < 256) /* check for small buffer specs */
>> size <<= 10 ;
>> if (size < MIN_BUFSIZE || size > MAX_BUFSIZE)
>> printk("dmasound_setup: invalid write buffer size, using default = %d\n", writeBufSize);
>> else
>> writeBufSize = size;
>> case 0:
>> break;
>> default:
>>
>> Can you tell me what is going on here?
>
> As you can see the warning is suppressed when a case label falls through to
> a case that merely breaks... or returns, or continues (continue statement)
> or that goes to (goto statement) some other place.
>
> However, Clang disagrees with this. See below for more:
>
> https://github.com/ClangBuiltLinux/linux/issues/636
> https://godbolt.org/z/xgkvIh
I see. Thank you.
--
~Randy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: fallthrough question
2022-02-18 21:57 fallthrough question Randy Dunlap
2022-02-18 23:15 ` Gustavo A. R. Silva
@ 2022-02-19 11:08 ` Joe Perches
1 sibling, 0 replies; 4+ messages in thread
From: Joe Perches @ 2022-02-19 11:08 UTC (permalink / raw)
To: Randy Dunlap, Gustavo A. R. Silva; +Cc: linux-kernel@vger.kernel.org
On Fri, 2022-02-18 at 13:57 -0800, Randy Dunlap wrote:
> Hi,
>
> I expected this to produce a fallthrough warning, but it doesn't
> (with gcc 11.1.0):
>
> from sound/oss/dmasound/dmasound_core.c:#1481, when falling from case 1
> into case 0: (in arch/m68k/ selected builds only)
>
> case 1:
> if ((size = ints[2]) < 256) /* check for small buffer specs */
> size <<= 10 ;
> if (size < MIN_BUFSIZE || size > MAX_BUFSIZE)
> printk("dmasound_setup: invalid write buffer size, using default = %d\n", writeBufSize);
> else
> writeBufSize = size;
> case 0:
> break;
> default:
>
> Can you tell me what is going on here?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-02-19 11:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-18 21:57 fallthrough question Randy Dunlap
2022-02-18 23:15 ` Gustavo A. R. Silva
2022-02-18 23:41 ` Randy Dunlap
2022-02-19 11:08 ` Joe Perches
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.