Skip to contentSkip to conversation

fallthrough question

DISCUSSION Randy Dunlap 3 participants 4 messages Feb 18, 2022 – Feb 19, 2022

lore
Share & tools
lore
#0 lore raw

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.

Signature · 1 line
~Randy
#1 lore raw

Hi there,

Quoted 19 lines · Randy Dunlap

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:
Quoted 1 line

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

#2 lore raw
Quoted 24 lines · Gustavo A. R. Silva

Hi there,

Quoted 19 lines · Randy Dunlap

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:
Quoted 1 line

Can you tell me what is going on here?

Quoted 8 lines

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.

Signature · 1 line
~Randy
#3 lore raw
In reply to Randy Dunlap
Quoted 19 lines · Randy Dunlap

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:
Quoted 1 line

Can you tell me what is going on here?

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432