Re: [bug report] net: ipa: reduce arguments to ipa_table_init_add()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 17, 2022 at 07:47:27AM +0300, Dan Carpenter wrote:
> Heh.  It really feels like this line should have generated a checker
> warning as well.  I've created two versions.  The first complains when
> ever there is a divide used as a condition:
> 
> 	if (a / b) {
> 
> The other complains when it's part of a logical && or ||.
> 
> 	if (a && a / b) {
> 
> drivers/net/ipa/ipa_table.c:414 ipa_table_init_add() warn: divide condition: 'hash_mem->size / 8'
> drivers/net/ipa/ipa_table.c:414 ipa_table_init_add() warn: divide condition (logical): 'hash_mem->size / 8'
> 
> I'll test them out tonight and see if either gives useful results.

I modified the test to ignore macros.  Otherwise we get warnings where
macros are trying to avoid divide by zero bugs.  There was no advantage
in treating logicals as special so I dropped that.

The results are kind of mind bending.  I think maybe people sometimes
accidentally write "if (a / b) {" meaning does it divide cleanly?  When
that should be written as: "if ((a % b) == 0) {".

Anyway, attached.

regards,
dan carpenter
drivers/nvdimm/claim.c:287 nsio_rw_bytes() warn: divide condition: 'cleared / 512'
drivers/nvdimm/bus.c:210 nvdimm_account_cleared_poison() warn: divide condition: 'cleared / 512'
drivers/rtc/rtc-m48t59.c:135 m48t59_rtc_set_time() warn: divide condition: 'year / 100'
drivers/gpu/drm/i915/gvt/vgpu.c:124 intel_gvt_init_vgpu_types() warn: divide condition: 'low_avail / conf->low_mm'
drivers/regulator/aat2870-regulator.c:142 aat2870_get_regulator() warn: divide condition: '(id - 1) / 2'
drivers/leds/leds-bcm6328.c:116 bcm6328_led_mode() warn: divide condition: 'shift / 16'
drivers/leds/leds-bcm6328.c:357 bcm6328_led() warn: divide condition: 'shift / 16'
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c:22554 wlc_phy_rssi_cal_nphy_rev3() warn: divide condition: 'result_idx / 2'
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c:22926 wlc_phy_rssi_cal_nphy_rev2() warn: divide condition: 'result_idx / 2'
drivers/net/wireless/broadcom/b43/phy_n.c:2202 b43_nphy_rev3_rssi_cal() warn: divide condition: 'i / 2'
drivers/net/wireless/broadcom/b43/phy_n.c:2403 b43_nphy_rev2_rssi_cal() warn: divide condition: 'i / 2'
drivers/net/wireless/intersil/hostap/hostap_plx.c:232 hfa384x_from_bap() warn: divide condition: 'len / 2'
drivers/net/wireless/intersil/hostap/hostap_plx.c:251 hfa384x_to_bap() warn: divide condition: 'len / 2'
drivers/net/wireless/intersil/hostap/hostap_cs.c:164 hfa384x_from_bap() warn: divide condition: 'len / 2'
drivers/net/wireless/intersil/hostap/hostap_cs.c:183 hfa384x_to_bap() warn: divide condition: 'len / 2'
drivers/net/ethernet/intel/iavf/iavf_txrx.c:300 iavf_clean_tx_irq() warn: divide condition: 'j / 4'
drivers/net/ethernet/intel/i40e/i40e_txrx_common.h:77 i40e_arm_wb() warn: divide condition: 'j / 4'
drivers/net/ethernet/intel/i40e/i40e_txrx_common.h:77 i40e_arm_wb() warn: divide condition: 'j / 4'
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c:759 fm10k_uc_vlan_unsync() warn: divide condition: 'vid / 4096'
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c:779 fm10k_mc_vlan_unsync() warn: divide condition: 'vid / 4096'
drivers/net/ipa/ipa_table.c:414 ipa_table_init_add() warn: divide condition: 'hash_mem->size / 8'
drivers/gpio/gpio-exar.c:52 exar_offset_to_sel_addr() warn: divide condition: 'pin / 8'
drivers/gpio/gpio-exar.c:62 exar_offset_to_lvl_addr() warn: divide condition: 'pin / 8'
drivers/ata/ahci_imx.c:411 __sata_ahci_read_temperature() warn: divide condition: 'm2 / 1000'
fs/hfsplus/bitmap.c:46 hfsplus_block_allocate() warn: divide condition: '(size ^ offset) / (((1) << 12) * 8)'
fs/hfsplus/bitmap.c:88 hfsplus_block_allocate() warn: divide condition: '(size ^ offset) / (((1) << 12) * 8)'
fs/freevxfs/vxfs_bmap.c:62 vxfs_bmap_ext4() warn: divide condition: 'bn / (indsize * indsize * bsize / 4)'
sound/soc/codecs/rt274.c:881 rt274_set_bclk_ratio() warn: divide condition: 'ratio / 50'

[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux