All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: Re: [gustavoars-linux:testing/fallthrough 144/560] drivers/gpu/drm/drm_dp_helper.c:492 drm_dp_downstream_max_bpc() warn: ignoring unreachable code.
Date: Tue, 07 Jul 2020 20:19:44 +0300	[thread overview]
Message-ID: <20200707171944.GY2571@kadam> (raw)
In-Reply-To: <20200707152554.GC11125@embeddedor>

[-- Attachment #1: Type: text/plain, Size: 3959 bytes --]

On Tue, Jul 07, 2020 at 10:25:54AM -0500, Gustavo A. R. Silva wrote:
> 
> Hi,
> 
> I think there is room for improvement here. Please, see my comments
> below...
> 
> On Tue, Jul 07, 2020 at 05:07:17PM +0300, Dan Carpenter wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git testing/fallthrough
> > head:   d7f10c2411ed9283df8d763139de9468b88c89ce
> > commit: 62708a516a6b158e213c46ff731260cb988dbc11 [144/560] drm: Use fallthrough pseudo-keyword
> > config: i386-randconfig-m021-20200703 (attached as .config)
> > compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
> > 
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > smatch warnings:
> > drivers/gpu/drm/drm_dp_helper.c:492 drm_dp_downstream_max_bpc() warn: ignoring unreachable code.
> > 
> > # https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/commit/?id=62708a516a6b158e213c46ff731260cb988dbc11
> > git remote add gustavoars-linux https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git
> > git remote update gustavoars-linux
> > git checkout 62708a516a6b158e213c46ff731260cb988dbc11
> > vim +492 drivers/gpu/drm/drm_dp_helper.c
> > 
> > 7529d6af1cd16b Mika Kahola         2016-09-09  464  int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
> > 7529d6af1cd16b Mika Kahola         2016-09-09  465  			      const u8 port_cap[4])
> > 7529d6af1cd16b Mika Kahola         2016-09-09  466  {
> > 7529d6af1cd16b Mika Kahola         2016-09-09  467  	int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  468  	bool detailed_cap_info = dpcd[DP_DOWNSTREAMPORT_PRESENT] &
> > 7529d6af1cd16b Mika Kahola         2016-09-09  469  		DP_DETAILED_CAP_INFO_AVAILABLE;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  470  	int bpc;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  471  
> > 7529d6af1cd16b Mika Kahola         2016-09-09  472  	if (!detailed_cap_info)
> > 7529d6af1cd16b Mika Kahola         2016-09-09  473  		return 0;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  474  
> > 7529d6af1cd16b Mika Kahola         2016-09-09  475  	switch (type) {
> > 7529d6af1cd16b Mika Kahola         2016-09-09  476  	case DP_DS_PORT_TYPE_VGA:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  477  	case DP_DS_PORT_TYPE_DVI:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  478  	case DP_DS_PORT_TYPE_HDMI:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  479  	case DP_DS_PORT_TYPE_DP_DUALMODE:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  480  		bpc = port_cap[2] & DP_DS_MAX_BPC_MASK;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  481  
> > 7529d6af1cd16b Mika Kahola         2016-09-09  482  		switch (bpc) {
> > 7529d6af1cd16b Mika Kahola         2016-09-09  483  		case DP_DS_8BPC:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  484  			return 8;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  485  		case DP_DS_10BPC:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  486  			return 10;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  487  		case DP_DS_12BPC:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  488  			return 12;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  489  		case DP_DS_16BPC:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  490  			return 16;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  491  		}
> > 62708a516a6b15 Gustavo A. R. Silva 2020-07-02 @492  		fallthrough;
> >                                                                 ^^^^^^^^^^^
> 
> Notice that the statement above and the code below is actually reachable
> if _bpc_ doesn't match any of the switch cases.

There are only 4 possible cases and all of them are handled.

# define DP_DS_MAX_BPC_MASK                 (3 << 0)

regards,
dan carpenter

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: Re: [gustavoars-linux:testing/fallthrough 144/560] drivers/gpu/drm/drm_dp_helper.c:492 drm_dp_downstream_max_bpc() warn: ignoring unreachable code.
Date: Tue, 07 Jul 2020 20:19:44 +0300	[thread overview]
Message-ID: <20200707171944.GY2571@kadam> (raw)
In-Reply-To: <20200707152554.GC11125@embeddedor>

[-- Attachment #1: Type: text/plain, Size: 3959 bytes --]

On Tue, Jul 07, 2020 at 10:25:54AM -0500, Gustavo A. R. Silva wrote:
> 
> Hi,
> 
> I think there is room for improvement here. Please, see my comments
> below...
> 
> On Tue, Jul 07, 2020 at 05:07:17PM +0300, Dan Carpenter wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git testing/fallthrough
> > head:   d7f10c2411ed9283df8d763139de9468b88c89ce
> > commit: 62708a516a6b158e213c46ff731260cb988dbc11 [144/560] drm: Use fallthrough pseudo-keyword
> > config: i386-randconfig-m021-20200703 (attached as .config)
> > compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
> > 
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > smatch warnings:
> > drivers/gpu/drm/drm_dp_helper.c:492 drm_dp_downstream_max_bpc() warn: ignoring unreachable code.
> > 
> > # https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/commit/?id=62708a516a6b158e213c46ff731260cb988dbc11
> > git remote add gustavoars-linux https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git
> > git remote update gustavoars-linux
> > git checkout 62708a516a6b158e213c46ff731260cb988dbc11
> > vim +492 drivers/gpu/drm/drm_dp_helper.c
> > 
> > 7529d6af1cd16b Mika Kahola         2016-09-09  464  int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
> > 7529d6af1cd16b Mika Kahola         2016-09-09  465  			      const u8 port_cap[4])
> > 7529d6af1cd16b Mika Kahola         2016-09-09  466  {
> > 7529d6af1cd16b Mika Kahola         2016-09-09  467  	int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  468  	bool detailed_cap_info = dpcd[DP_DOWNSTREAMPORT_PRESENT] &
> > 7529d6af1cd16b Mika Kahola         2016-09-09  469  		DP_DETAILED_CAP_INFO_AVAILABLE;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  470  	int bpc;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  471  
> > 7529d6af1cd16b Mika Kahola         2016-09-09  472  	if (!detailed_cap_info)
> > 7529d6af1cd16b Mika Kahola         2016-09-09  473  		return 0;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  474  
> > 7529d6af1cd16b Mika Kahola         2016-09-09  475  	switch (type) {
> > 7529d6af1cd16b Mika Kahola         2016-09-09  476  	case DP_DS_PORT_TYPE_VGA:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  477  	case DP_DS_PORT_TYPE_DVI:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  478  	case DP_DS_PORT_TYPE_HDMI:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  479  	case DP_DS_PORT_TYPE_DP_DUALMODE:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  480  		bpc = port_cap[2] & DP_DS_MAX_BPC_MASK;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  481  
> > 7529d6af1cd16b Mika Kahola         2016-09-09  482  		switch (bpc) {
> > 7529d6af1cd16b Mika Kahola         2016-09-09  483  		case DP_DS_8BPC:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  484  			return 8;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  485  		case DP_DS_10BPC:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  486  			return 10;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  487  		case DP_DS_12BPC:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  488  			return 12;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  489  		case DP_DS_16BPC:
> > 7529d6af1cd16b Mika Kahola         2016-09-09  490  			return 16;
> > 7529d6af1cd16b Mika Kahola         2016-09-09  491  		}
> > 62708a516a6b15 Gustavo A. R. Silva 2020-07-02 @492  		fallthrough;
> >                                                                 ^^^^^^^^^^^
> 
> Notice that the statement above and the code below is actually reachable
> if _bpc_ doesn't match any of the switch cases.

There are only 4 possible cases and all of them are handled.

# define DP_DS_MAX_BPC_MASK                 (3 << 0)

regards,
dan carpenter

  reply	other threads:[~2020-07-07 17:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 14:07 [gustavoars-linux:testing/fallthrough 144/560] drivers/gpu/drm/drm_dp_helper.c:492 drm_dp_downstream_max_bpc() warn: ignoring unreachable code Dan Carpenter
2020-07-07 14:07 ` Dan Carpenter
2020-07-07 15:25 ` Gustavo A. R. Silva
2020-07-07 17:19   ` Dan Carpenter [this message]
2020-07-07 17:19     ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2020-07-03 16:09 kernel test robot

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=20200707171944.GY2571@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.