linux-5.3-rc4/drivers/staging/comedi/drivers/dt3000.c:373: (error) Signed integer overflow for expression 'divider*base'
Hello there, Source code is prescale = 15; base = timer_base * (1 << prescale); divider = 65535; *nanosec = divider * base; timer_base seems to be 500 or 100. nanosec is a pointer to int, so it can only hold about 2,000,000,000 nanoseconds, or about 2 seconds. Suggest rework code to use longs. Regards David Binderman time-_Base seems to be 50 or 100. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
drivers/staging/media/ipu3/ipu3-css.c:1831: bad compare ?
Hello there, drivers/staging/media/ipu3/ipu3-css.c:1831:30: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] Source code is css->pipes[pipe].bindex = ipu3_css_find_binary(css, pipe, q, r); if (css->pipes[pipe].bindex < 0) { dev_err(css->dev, "failed to find suitable binary\n"); return -EINVAL; } Suggest sanity check return value from function first, then if it is ok, assign it to an unsigned variable. Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
linux-5.0-rc1/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c:412]: (style) Expression is always false
Hello there, linux-5.0-rc1/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c:412]: (style) Expression is always false because 'else if' condition matches previous condition at line 410. Source code is else if (pRaInfo->HighestRate > 0x0b) pRaInfo->PTModeSS = 2; else if (pRaInfo->HighestRate > 0x0b) pRaInfo->PTModeSS = 1; Suggest code rework. Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
linux-4.18-rc8/tools/hv/hv_kvp_daemon.c:289: dead code block ?
Hello there, linux-4.18-rc8/tools/hv/hv_kvp_daemon.c:282] -> [linux-4.18-rc8/tools/hv/hv_kvp_daemon.c:289]: (warning) Opposite inner 'if' condition leads to a dead code block. Source code is for (i = 0; i < num_records; i++) { if (memcmp(key, record[i].key, key_size)) continue; /* * Found a match; just move the remaining * entries up. */ if (i == num_records) { Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
drivers/staging/wilc1000/host_interface.c:: 6 * pointless test ?
Hello there, drivers/staging/wilc1000/host_interface.c:512:36: warning: comparison is always true due to limited range of data type [-Wtype-limits] Source code is cfg_param_attr->auth_timeout < 65536) { Suggest remove pointless test. Some duplicates: drivers/staging/wilc1000/host_interface.c:581:37: warning: comparison is always true due to limited range of data type [-Wtype-limits] drivers/staging/wilc1000/host_interface.c:634:39: warning: comparison is always true due to limited range of data type [-Wtype-limits] drivers/staging/wilc1000/host_interface.c:675:45: warning: comparison is always true due to limited range of data type [-Wtype-limits] drivers/staging/wilc1000/host_interface.c:689:40: warning: comparison is always true due to limited range of data type [-Wtype-limits] drivers/staging/wilc1000/host_interface.c:703:41: warning: comparison is always true due to limited range of data type [-Wtype-limits] Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
linux-4.12-rc1/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c:2966: cart before the horse ?
Hello there, linux-4.12-rc1/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c:2966]: (style) Array index 'i' is used before limits check. Source code is while (szLine[i] != '{' && i < strlen(szLine)) i++; Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
linux-4.12-rc1/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/string_support.h:76: cart before the horse ?
Hello there, linux-4.12-rc1/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/string_support.h:76]: (style) Array index 'ix' is used before limits check. Source code is for (ix=0; ((src_str[ix] != '\0') && (ix< max_len)); ++ix) /*Nothing else to do*/; Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
linux-4.9-rc1/drivers/staging/lustre/lustre/osc/osc_request.c:973: always false test ?
Hello there, linux-4.9-rc1/drivers/staging/lustre/lustre/osc/osc_request.c:973]: (style) Checking if unsigned variable 'cli.cl_avail_grant' is less than zero. Source code is if (cli->cl_avail_grant < 0) { Suggest code rework. Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
linux-4.8-rc3/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c:3533: pointless test ?
Hello there, linux-4.8-rc3/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c:3533]: (style) Condition 'pBtMgnt.ExtConfig.HCIExtensionVer>=1' is always true Source code is if (pBtMgnt->ExtConfig.HCIExtensionVer < 1) { } else if (pBtMgnt->ExtConfig.HCIExtensionVer >= 1) { Suggest remove second test. Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
drivers/staging/ks7010/ks_wlan_net.c:1287: suspicious if ?
Hello there, drivers/staging/ks7010/ks_wlan_net.c:1287:13: warning: duplicated ‘if’ condition [-Wduplicated-cond] Source code is } else if (enabled) { /* 1 */ if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) priv->reg.powermgt = POWMGT_SAVE1_MODE; else return -EINVAL; } else if (enabled) { /* 2 */ I am not sure of a suitable fix for this. Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
linux-4.1-rc1/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c:424: bad if test ?
Hello there Greg, Static analyser cppcheck says [linux-4.1-rc1/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c:424]: (style) Expression is always false because 'else if' condition matches previous condition at line 422. Source code is else if (pRaInfo-HighestRate 0x0b) pRaInfo-PTModeSS = 2; else if (pRaInfo-HighestRate 0x0b) pRaInfo-PTModeSS = 1; Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
staging/dgap/dgap.c:981: bad if test ?
Hello there, [linux-3.19-rc5/drivers/staging/dgap/dgap.c:981]: (warning) Logical disjunction always evaluates to true: conc_type != 65 || conc_type != 66. Source code is if (conc_type == 0 || conc_type != CX || conc_type != EPC) { Suggest code rework. Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: staging/dgap/dgap.c:981: bad if test ?
Hello there, Thanks for the confirmation. More of the same in the same file: [linux-3.19-rc5/drivers/staging/dgap/dgap.c:1022]: (warning) Logical disjunction always evaluates to true: module_type != 68 || module_type != 73. Source code is if (module_type == 0 || module_type != PORTS || module_type != MODEM) { I used the static analyser cppcheck to find these two bugs, but you might be able to find similar problems by using gcc compiler flag -Wlogical-op. Regards David Binderman Date: Thu, 22 Jan 2015 13:14:22 +0300 From: dan.carpen...@oracle.com To: dcb...@hotmail.com; daeseok.y...@gmail.com CC: driverdev-devel@linuxdriverproject.org Subject: Re: staging/dgap/dgap.c:981: bad if test ? On Thu, Jan 22, 2015 at 10:05:53AM +, David Binderman wrote: Hello there, [linux-3.19-rc5/drivers/staging/dgap/dgap.c:981]: (warning) Logical disjunction always evaluates to true: conc_type != 65 || conc_type != 66. Source code is if (conc_type == 0 || conc_type != CX || conc_type != EPC) { Suggest code rework. Thanks. This bug was introduced in: commit f6aa0164cd3b1c5192e87f5651ec382c3bc3abac Author: Daeseok Youn daeseok.y...@gmail.com Date: Sat Aug 9 14:38:41 2014 +0900 staging: dgap: Simplify to set a concentrator type It is same manner with setting a board type. For example of config file for concentrator, conc ccon or conc epcon After allocating a type of CNODE then set a type of concentrator. So remove cases in swith statement, just get a token from string and set to conc.type. And also it doesn't need to conc.v_type. Signed-off-by: Daeseok Youn daeseok.y...@gmail.com Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org Let's CC Daeseok. regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: staging/dgap/dgap.c:981: bad if test ?
Hello there, On Thu, Jan 22, 2015 at 10:20:44AM +, David Binderman wrote: I used the static analyser cppcheck to find these two bugs, but you might be able to find similar problems by using gcc compiler flag -Wlogical-op. I turned it on, but GCC 4.7.2 doesn't find anything for me. Surprising. I note that gcc 4.7.2 is dated Sep 2012 and the current release of gcc is 4.9.2, dated Oct 2014. I am not sure upgrading gcc will help. Smatch is similar to GCC in this regard... cppcheck is available from sourceforge. Regards David Binderman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel