Bug 44151

Summary: cpqphp_ctrl.c: 2 * bad if test
Product: Drivers Reporter: David Binderman (dcb314)
Component: HotPlugAssignee: Greg Kroah-Hartman (greg)
Status: RESOLVED CODE_FIX    
Severity: normal CC: alan, florian
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.5-rc5 Subsystem:
Regression: No Bisected commit-id:

Description David Binderman 2012-07-02 20:44:33 UTC
I just ran the static analyser cppcheck over the source code of the
linux kernel version 3.5-rc5.

It said

1.

[linux-3.5-rc5/drivers/pci/hotplug/cpqphp_ctrl.c:2893]: (style) Expression '(X & 0xb) == 0x4' is always false

The source code is

                } else if ((temp_register & 0x0BL) == 0x04) {

Clearly broken code. I am not sure what the fix is.

2.

[linux-3.5-rc5/drivers/pci/hotplug/cpqphp_ctrl.c:2909]: (style) Expression '(X & 0xb) == 0x6' is always false

The source code is

                } else if ((temp_register & 0x0BL) == 0x06) {

Duplicate.
Comment 1 Alan 2012-08-29 14:34:44 UTC
It will always take the 0x00 path instead of the 0x04 or 0x06 paths. This appears harmless.
Comment 2 Florian Mickler 2012-10-15 21:24:31 UTC
A patch referencing this bug report has been merged in Linux v3.7-rc1:

commit b161dabc3d3004ea56a8d20b0f5ec9bf68e67180
Author: Alan Cox <alan@linux.intel.com>
Date:   Tue Sep 4 15:39:57 2012 +0100

    PCI: cpqphp: Remove unreachable path