From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jani Nikula <jani.nikula@linux.intel.com>
Cc: malat@debian.org, dri-devel@lists.freedesktop.org
Subject: Re: [bug report] drm/dp: annotate implicit fall throughs
Date: Mon, 31 Aug 2020 12:06:55 +0300 [thread overview]
Message-ID: <20200831090655.GA8321@kadam> (raw)
In-Reply-To: <87v9h33xlv.fsf@intel.com>
On Fri, Aug 28, 2020 at 12:53:32PM +0300, Jani Nikula wrote:
> On Tue, 25 Aug 2020, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > Hello Mathieu Malaterre,
> >
> > The patch e9c0c874711b: "drm/dp: annotate implicit fall throughs"
> > from Jan 14, 2019, leads to the following static checker warning:
> >
> > drivers/gpu/drm/drm_dp_helper.c:495 drm_dp_downstream_max_bpc()
> > warn: ignoring unreachable code.
> >
> > drivers/gpu/drm/drm_dp_helper.c
> > 467 int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
> > 468 const u8 port_cap[4])
> > 469 {
> > 470 int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
> > 471 bool detailed_cap_info = dpcd[DP_DOWNSTREAMPORT_PRESENT] &
> > 472 DP_DETAILED_CAP_INFO_AVAILABLE;
> > 473 int bpc;
> > 474
> > 475 if (!detailed_cap_info)
> > 476 return 0;
> > 477
> > 478 switch (type) {
> > 479 case DP_DS_PORT_TYPE_VGA:
> > 480 case DP_DS_PORT_TYPE_DVI:
> > 481 case DP_DS_PORT_TYPE_HDMI:
> > 482 case DP_DS_PORT_TYPE_DP_DUALMODE:
> > 483 bpc = port_cap[2] & DP_DS_MAX_BPC_MASK;
> > ^^^^^^^^^^^^^^^^^^
> > This is 0x3.
> >
> > 484
> > 485 switch (bpc) {
> > 486 case DP_DS_8BPC:
> > 487 return 8;
> > 488 case DP_DS_10BPC:
> > 489 return 10;
> > 490 case DP_DS_12BPC:
> > 491 return 12;
> > 492 case DP_DS_16BPC:
> > 493 return 16;
> > 494 }
> > 495 fallthrough;
> >
> > This fallthrough is impossible. Probably the way to work around the
> > bogus warning is the change the fallthough to "return 0; /* impossible */"
> > otherwise the fallthrough is sort of misleading...
>
> Won't that be unreachable as well?
>
> Maybe just add the default label to switch (bpc)?
A default switch is going to be unreachable as well... But adding a
return 0 is the older more traditional ways way of marking these so
people and checkers are used to it.
regards,
dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
prev parent reply other threads:[~2020-08-31 9:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-25 11:27 [bug report] drm/dp: annotate implicit fall throughs Dan Carpenter
2020-08-28 9:53 ` Jani Nikula
2020-08-31 9:06 ` Dan Carpenter [this message]
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=20200831090655.GA8321@kadam \
--to=dan.carpenter@oracle.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=malat@debian.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