From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Felipe Balbi <balbi@kernel.org>
Cc: linux-usb@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [v1] usb: dwc3: trace: Refactor nested switch to make compiler happy
Date: Wed, 5 Dec 2018 11:18:45 +0200 [thread overview]
Message-ID: <20181205091845.GQ10650@smile.fi.intel.com> (raw)
On Wed, Dec 05, 2018 at 11:10:46AM +0200, Felipe Balbi wrote:
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:
>
> > 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 <felipe.balbi@linux.intel.com>
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> > drivers/usb/dwc3/trace.h | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h
> > index f22714cce070..8e1625a6c19f 100644
> > --- a/drivers/usb/dwc3/trace.h
> > +++ b/drivers/usb/dwc3/trace.h
> > @@ -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;
> > switch (__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.
next reply other threads:[~2018-12-05 9:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-05 9:18 Andy Shevchenko [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-12-05 10:54 [v1] usb: dwc3: trace: Refactor nested switch to make compiler happy Felipe Balbi
2018-12-05 9:42 Andy Shevchenko
2018-12-05 9:10 Felipe Balbi
2018-12-03 9:28 Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181205091845.GQ10650@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).