usb: dwc3: trace: Refactor nested switch to make compiler happy
PATCH 1/1 usb: dwc3: trace: Refactor nested switch to make compiler happy
Quoted 33 lines · Felipe Balbi
Quoted 31 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) { ^~~~~~Refactor nested switch statements to work correctly without compilation warnings.
Fixes fa8d965d736b ("usb: dwc3: trace: pretty print high-bandwidth transfers too")Cc Felipe Balbi <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/usb/dwc3/trace.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/usb/dwc3/trace.h +1
-1@@ -238,7 +238,7 @@ DECLARE_EVENT_CLASS(dwc3_log_trb, ), TP_printk("%s: trb %p buf %08x%08x size %s%d ctrl %08x (%c%c%c%c:%c%c:%s)", __get_str(name), __entry->trb, __entry->bph, __entry->bpl, - ({char *s; + ({ char *s = ""; int pcm = ((__entry->size >> 24) & 3) + 1;
Quoted 8 lines
drivers/usb/dwc3/trace.h DECLARE_EVENT_CLASS(dwc3_log_trb, · line 256
Quoted 6 lines
drivers/usb/dwc3/trace.h +0
-0switch (__entry->type) {case USB_ENDPOINT_XFER_INT :@@ -254,8 +254,6 @@ DECLARE_EVENT_CLASS(dwc3_log_trb, s ="3x " ;break ; }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.