[PATCH] Input: sparcspkr - Avoid unannotated fall-through

WangYuli posted 1 patch 8 months, 1 week ago
drivers/input/misc/sparcspkr.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
[PATCH] Input: sparcspkr - Avoid unannotated fall-through
Posted by WangYuli 8 months, 1 week ago
1. Fix follow warnings with clang-21:
  drivers/input/misc/sparcspkr.c:78:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
     78 |                 case SND_TONE: break;
        |                 ^
  drivers/input/misc/sparcspkr.c:78:3: note: insert 'break;' to avoid fall-through
     78 |                 case SND_TONE: break;
        |                 ^
        |                 break;
  drivers/input/misc/sparcspkr.c:113:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
    113 |                 case SND_TONE: break;
        |                 ^
  drivers/input/misc/sparcspkr.c:113:3: note: insert 'break;' to avoid fall-through
    113 |                 case SND_TONE: break;
        |                 ^
        |                 break;
  2 warnings generated.
2. Reformat this code block to enhance readability.

Fixes: 215ea853a9 ("[INPUT]: Add EBUS/ISA speaker input driver for Sparc.")  #In history tree
Signed-off-by: WangYuli <wangyuli@uniontech.com>
---
 drivers/input/misc/sparcspkr.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
index 8d7303fc13bc..1cfadd73829f 100644
--- a/drivers/input/misc/sparcspkr.c
+++ b/drivers/input/misc/sparcspkr.c
@@ -74,9 +74,14 @@ static int bbc_spkr_event(struct input_dev *dev, unsigned int type, unsigned int
 		return -1;
 
 	switch (code) {
-		case SND_BELL: if (value) value = 1000;
-		case SND_TONE: break;
-		default: return -1;
+	case SND_BELL:
+		if (value)
+			value = 1000;
+		break;
+	case SND_TONE:
+		break;
+	default:
+		return -1;
 	}
 
 	if (value > 20 && value < 32767)
@@ -109,9 +114,14 @@ static int grover_spkr_event(struct input_dev *dev, unsigned int type, unsigned
 		return -1;
 
 	switch (code) {
-		case SND_BELL: if (value) value = 1000;
-		case SND_TONE: break;
-		default: return -1;
+	case SND_BELL:
+		if (value)
+			value = 1000;
+		break;
+	case SND_TONE:
+		break;
+	default:
+		return -1;
 	}
 
 	if (value > 20 && value < 32767)
-- 
2.49.0
Re: [PATCH] Input: sparcspkr - Avoid unannotated fall-through
Posted by Dmitry Torokhov 8 months ago
On Tue, Apr 15, 2025 at 01:24:39PM +0800, WangYuli wrote:
> 1. Fix follow warnings with clang-21:
>   drivers/input/misc/sparcspkr.c:78:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
>      78 |                 case SND_TONE: break;
>         |                 ^
>   drivers/input/misc/sparcspkr.c:78:3: note: insert 'break;' to avoid fall-through
>      78 |                 case SND_TONE: break;
>         |                 ^
>         |                 break;
>   drivers/input/misc/sparcspkr.c:113:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
>     113 |                 case SND_TONE: break;
>         |                 ^
>   drivers/input/misc/sparcspkr.c:113:3: note: insert 'break;' to avoid fall-through
>     113 |                 case SND_TONE: break;
>         |                 ^
>         |                 break;
>   2 warnings generated.
> 2. Reformat this code block to enhance readability.
> 
> Fixes: 215ea853a9 ("[INPUT]: Add EBUS/ISA speaker input driver for Sparc.")  #In history tree

Thank you for the patch. There is actually no bug, so I dropped the
"Fixes" tag, but otherwise everything looks good and I applied it.

Thanks.

-- 
Dmitry