Skip to contentSkip to conversation

usb: dwc3: trace: Refactor nested switch to make compiler happy

PATCH New Felipe Balbi 1 participant 1 message Dec 5, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: dwc3: trace: Refactor nested switch to make compiler happy

Quoted 14 lines · Andy Shevchenko
Quoted 12 lines · Andy Shevchenko
Quoted 11 lines · Felipe Balbi
Quoted 9 lines · Andy Shevchenko

The missed break statement in the outer switch makes the code fall through always and thus always same value will be printed.

Besides that, compiler warns about missed fall through marker:

drivers/usb/dwc3/./trace.h: In function ‘trace_raw_output_dwc3_log_trb’:
drivers/usb/dwc3/./trace.h:246:4: warning: this statement may fall through [-Wimplicit-fallthrough=]

    switch (pcm) {
    ^~~~~~
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

easier to add "break" here, no? That would be the minimal fix.

No. Then you would need to add same default to the inner switch.

Ah, you meant that pcm would be never outside of the given cases. Yes, that's fine then, consider my patch as a bugreport.

updated locally:

From ad7b607f82731eec3ed17d9d22764eb6f09609f9 Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <[email protected]>
Date: Mon, 3 Dec 2018 11:28:47 +0200
Subject: [PATCH] usb: dwc3: trace: add missing break statement to make
compiler happy
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The missed break statement in the outer switch makes the code fall through always and thus always same value will be printed.

Besides that, compiler warns about missed fall through marker:

drivers/usb/dwc3/./trace.h: In function ‘trace_raw_output_dwc3_log_trb’:
drivers/usb/dwc3/./trace.h:246:4: warning: this statement may fall through [-Wimplicit-fallthrough=]

    switch (pcm) {
    ^~~~~~

Add the missing break statement to work correctly without compilation warnings.

Fixes fa8d965d736b ("usb: dwc3: trace: pretty print high-bandwidth transfers too")
Cc Felipe Balbi <[email protected]>
---
 drivers/usb/dwc3/trace.h | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/dwc3/trace.h +1 -0
index 50fb6f2d92dd..36e5a4795fc8 100644
@@ -254,6 +254,7 @@ DECLARE_EVENT_CLASS(dwc3_log_trb,
 				s = "3x ";
 				break;
 			}
+			break;
 		default:
 			s = "";
 		} s; }),