common: console: move break; statement
PATCH 1/1 common: console: move break; statement
In console_setfile(), there is some #ifdef'ed code, updating monitor functions for a U-Boot proper build. This is called inside a switch/case statement, but the closing "break;" is inside the #ifdef section. This doesn't look right: we should not fall through to the error case for an SPL/TPL build.
Move the "break" to be always effective, solving a compiler warning about an untagged implicit fallthrough.
---
Hi,
this seems to be the only real bug I found after enabling -Wimplicit-fallthrough in the first phase of the CI. Please have a look to check whether I am right with this one.
I have about 20 patches that add fallthrough annotations, to fix the other warnings, and will send them out once I polished them up - and after I have figured out what to do with libbzip2.
Cheers,
Andre
common/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/console.c +1 -1
@@ -208,8 +208,8 @@ static int console_setfile(int file, struct stdio_dev * dev) gd->jt->printf = printf; break; } -break ;#endif +break ;default :/* Invalid file ID */ error =-1 ; }
Signature · 1 line
2.25.1
Quoted 10 lines · Andre Przywara
In
console_setfile(), there is some #ifdef'ed code, updating monitor functions for a U-Boot proper build. This is called inside a switch/case statement, but the closing "break;" is inside the #ifdef section. This doesn't look right: we should not fall through to the error case for an SPL/TPL build.Move the "break" to be always effective, solving a compiler warning about an untagged implicit fallthrough.
Signed-off-by Andre Przywara <[email protected]>
Looking at the whole function in context yes, I agree this is right. It probably wasn't a problem in practice because of where / when we don't error check or even call this function in the end.
Signature · 1 line
Tom
Quoted 10 lines · Andre Przywara
In
console_setfile(), there is some #ifdef'ed code, updating monitor functions for a U-Boot proper build. This is called inside a switch/case statement, but the closing "break;" is inside the #ifdef section. This doesn't look right: we should not fall through to the error case for an SPL/TPL build.Move the "break" to be always effective, solving a compiler warning about an untagged implicit fallthrough.
[...]
Applied to u-boot/master, thanks!
[1/1] common: console: move break; statement
commit: 82f5ce11e669d86ac08e6ba800d4a97ad734665b
Signature · 1 line
Tom