Skip to contentSkip to conversation

drivers/counter/microchip-tcb-capture.c:173 mchp_tc_count_action_read() warn: bitwise AND condition is false here

PATCH In review Dan Carpenter 2 participants 2 messages Oct 14, 2020 – Oct 18, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/12 drivers/counter/microchip-tcb-capture.c:173 mchp_tc_count_action_read() warn: bitwise AND condition is false here

tree:   https://github.com/dlech/linux  bone-counter
head:   f8f0ad10f30b5c1bea1a22f5de5dc9f2c6b7db1a
commit: 5251e7147d627fbe13308dc390347dc16efeb85b [1/12] counter: Internalize sysfs interface code
config: x86_64-randconfig-m001-20201014 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate

New smatch warnings:
drivers/counter/microchip-tcb-capture.c:173 mchp_tc_count_action_read() warn: bitwise AND condition is false here drivers/counter/counter-sysfs.c:109 counter_comp_u8_show() error: uninitialized symbol 'err'. drivers/counter/counter-sysfs.c:114 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:233 counter_comp_u64_show() error: uninitialized symbol 'err'. drivers/counter/counter-sysfs.c:236 counter_comp_u64_show() error: uninitialized symbol 'data'.

Old smatch warnings:
drivers/counter/counter-sysfs.c:116 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:118 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:120 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:122 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:124 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:126 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:131 counter_comp_u8_show() error: uninitialized symbol 'data'.

vim +173 drivers/counter/microchip-tcb-capture.c

5251e7147d627fb William Breathitt Gray 2020-09-26  161  static int mchp_tc_count_action_read(struct counter_device *counter,
106b104137fd5f0 Kamel Bouhara          2020-07-06  162  				     struct counter_count *count,
106b104137fd5f0 Kamel Bouhara          2020-07-06  163  				     struct counter_synapse *synapse,
5251e7147d627fb William Breathitt Gray 2020-09-26  164  				     u8 *action)
106b104137fd5f0 Kamel Bouhara          2020-07-06  165  {
106b104137fd5f0 Kamel Bouhara          2020-07-06  166  	struct mchp_tc_data *const priv = counter->priv;
106b104137fd5f0 Kamel Bouhara          2020-07-06  167  	u32 cmr;
106b104137fd5f0 Kamel Bouhara          2020-07-06  168  
106b104137fd5f0 Kamel Bouhara          2020-07-06  169  	regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr);
106b104137fd5f0 Kamel Bouhara          2020-07-06  170  
5251e7147d627fb William Breathitt Gray 2020-09-26  171  	*action = COUNTER_SYNAPSE_ACTION_NONE;
106b104137fd5f0 Kamel Bouhara          2020-07-06  172  
106b104137fd5f0 Kamel Bouhara          2020-07-06 @173  	if (cmr & ATMEL_TC_ETRGEDG_NONE)
                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^

I'm guessing ATMEL_TC_ETRGEDG_NONE is zero and that's why Smatch thinks this can't possibly be true.

5251e7147d627fb William Breathitt Gray 2020-09-26  174  		*action = COUNTER_SYNAPSE_ACTION_NONE;
106b104137fd5f0 Kamel Bouhara          2020-07-06  175  	else if (cmr & ATMEL_TC_ETRGEDG_RISING)
5251e7147d627fb William Breathitt Gray 2020-09-26  176  		*action = COUNTER_SYNAPSE_ACTION_RISING_EDGE;
106b104137fd5f0 Kamel Bouhara          2020-07-06  177  	else if (cmr & ATMEL_TC_ETRGEDG_FALLING)
5251e7147d627fb William Breathitt Gray 2020-09-26  178  		*action = COUNTER_SYNAPSE_ACTION_FALLING_EDGE;
106b104137fd5f0 Kamel Bouhara          2020-07-06  179  	else if (cmr & ATMEL_TC_ETRGEDG_BOTH)
5251e7147d627fb William Breathitt Gray 2020-09-26  180  		*action = COUNTER_SYNAPSE_ACTION_BOTH_EDGES;
106b104137fd5f0 Kamel Bouhara          2020-07-06  181  
106b104137fd5f0 Kamel Bouhara          2020-07-06  182  	return 0;
106b104137fd5f0 Kamel Bouhara          2020-07-06  183  }

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

_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org

#1 lore raw
Quoted 9 lines · Dan Carpenter
tree:   https://github.com/dlech/linux  bone-counter
head:   f8f0ad10f30b5c1bea1a22f5de5dc9f2c6b7db1a
commit: 5251e7147d627fbe13308dc390347dc16efeb85b [1/12] counter: Internalize sysfs interface code
config: x86_64-randconfig-m001-20201014 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate

Thank you for pointing out these issues. I'll work to resolve them and CC you in the next revision.

William Breathitt Gray

Quoted 55 lines

New smatch warnings:
drivers/counter/microchip-tcb-capture.c:173 mchp_tc_count_action_read() warn: bitwise AND condition is false here drivers/counter/counter-sysfs.c:109 counter_comp_u8_show() error: uninitialized symbol 'err'. drivers/counter/counter-sysfs.c:114 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:233 counter_comp_u64_show() error: uninitialized symbol 'err'. drivers/counter/counter-sysfs.c:236 counter_comp_u64_show() error: uninitialized symbol 'data'.

Old smatch warnings:
drivers/counter/counter-sysfs.c:116 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:118 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:120 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:122 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:124 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:126 counter_comp_u8_show() error: uninitialized symbol 'data'. drivers/counter/counter-sysfs.c:131 counter_comp_u8_show() error: uninitialized symbol 'data'.

vim +173 drivers/counter/microchip-tcb-capture.c

5251e7147d627fb William Breathitt Gray 2020-09-26  161  static int mchp_tc_count_action_read(struct counter_device *counter,
106b104137fd5f0 Kamel Bouhara          2020-07-06  162  				     struct counter_count *count,
106b104137fd5f0 Kamel Bouhara          2020-07-06  163  				     struct counter_synapse *synapse,
5251e7147d627fb William Breathitt Gray 2020-09-26  164  				     u8 *action)
106b104137fd5f0 Kamel Bouhara          2020-07-06  165  {
106b104137fd5f0 Kamel Bouhara          2020-07-06  166  	struct mchp_tc_data *const priv = counter->priv;
106b104137fd5f0 Kamel Bouhara          2020-07-06  167  	u32 cmr;
106b104137fd5f0 Kamel Bouhara          2020-07-06  168  
106b104137fd5f0 Kamel Bouhara          2020-07-06  169  	regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr);
106b104137fd5f0 Kamel Bouhara          2020-07-06  170  
5251e7147d627fb William Breathitt Gray 2020-09-26  171  	*action = COUNTER_SYNAPSE_ACTION_NONE;
106b104137fd5f0 Kamel Bouhara          2020-07-06  172  
106b104137fd5f0 Kamel Bouhara          2020-07-06 @173  	if (cmr & ATMEL_TC_ETRGEDG_NONE)
                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^

I'm guessing ATMEL_TC_ETRGEDG_NONE is zero and that's why Smatch thinks this can't possibly be true.

5251e7147d627fb William Breathitt Gray 2020-09-26  174  		*action = COUNTER_SYNAPSE_ACTION_NONE;
106b104137fd5f0 Kamel Bouhara          2020-07-06  175  	else if (cmr & ATMEL_TC_ETRGEDG_RISING)
5251e7147d627fb William Breathitt Gray 2020-09-26  176  		*action = COUNTER_SYNAPSE_ACTION_RISING_EDGE;
106b104137fd5f0 Kamel Bouhara          2020-07-06  177  	else if (cmr & ATMEL_TC_ETRGEDG_FALLING)
5251e7147d627fb William Breathitt Gray 2020-09-26  178  		*action = COUNTER_SYNAPSE_ACTION_FALLING_EDGE;
106b104137fd5f0 Kamel Bouhara          2020-07-06  179  	else if (cmr & ATMEL_TC_ETRGEDG_BOTH)
5251e7147d627fb William Breathitt Gray 2020-09-26  180  		*action = COUNTER_SYNAPSE_ACTION_BOTH_EDGES;
106b104137fd5f0 Kamel Bouhara          2020-07-06  181  
106b104137fd5f0 Kamel Bouhara          2020-07-06  182  	return 0;
106b104137fd5f0 Kamel Bouhara          2020-07-06  183  }

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

_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org