Skip to contentSkip to conversation

drivers/gpu/drm/drm_dp_helper.c:492 drm_dp_downstream_max_bpc() warn: ignoring unreachable code.

PATCH In review Dan Carpenter 2 participants 3 messages Jul 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 144/560 drivers/gpu/drm/drm_dp_helper.c:492 drm_dp_downstream_max_bpc() warn: ignoring unreachable code.

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

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;
                                                                ^^^^^^^^^^^
7529d6af1cd16b Mika Kahola         2016-09-09  493  	default:
7529d6af1cd16b Mika Kahola         2016-09-09  494  		return 0;
7529d6af1cd16b Mika Kahola         2016-09-09  495  	}
7529d6af1cd16b Mika Kahola         2016-09-09  496  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#1 lore raw

Hi,

I think there is room for improvement here. Please, see my comments below...

Quoted 41 lines · Dan Carpenter
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

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:
Quoted 8 lines
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.

Thanks
--
Gustavo

Quoted 9 lines
7529d6af1cd16b Mika Kahola         2016-09-09  493  	default:
7529d6af1cd16b Mika Kahola         2016-09-09  494  		return 0;
7529d6af1cd16b Mika Kahola         2016-09-09  495  	}
7529d6af1cd16b Mika Kahola         2016-09-09  496  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
Quoted 57 lines · Gustavo A. R. Silva

Hi,

I think there is room for improvement here. Please, see my comments below...

Quoted 41 lines · Dan Carpenter
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

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:
Quoted 8 lines
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;
                                                                ^^^^^^^^^^^
Quoted 2 lines

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