PCI / PM: enforce type casting for pci_power_t
PATCH 1/1 PCI / PM: enforce type casting for pci_power_t
When cast pci_power_t type of variables a static analizer tool complains on that.
include/linux/pci.h:119:37: warning: cast from restricted pci_power_t
Enforce type casting to make static analizer happy.
--- include/linux/pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/pci.h +1 -1
@@ -116,7 +116,7 @@ extern const char *pci_power_names[];static inline const char *pci_power_name (pci_power_t state) { -return pci_power_names[1 + (int ) state]; +return pci_power_names[1 + (__force int ) state]; }#define PCI_PM_D2_DELAY 200
Signature · 1 line
2.8.1
Quoted 8 lines · Andy Shevchenko
When cast
pci_power_ttype of variables a static analizer tool complains on that.
include/linux/pci.h:119:37: warning: cast from restrictedpci_power_tEnforce type casting to make static analizer happy.
Signed-off-by Andy Shevchenko <[email protected]>
ACK
Quoted 18 lines
--- include/linux/pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/pci.h +1
-1@@ -116,7 +116,7 @@ extern const char *pci_power_names[];static inline const char *pci_power_name (pci_power_t state) { -return pci_power_names[1 + (int ) state]; +return pci_power_names[1 + (__force int ) state]; }#define PCI_PM_D2_DELAY 200
Bjorn Helgaas
AppliedQuoted 8 lines · Andy Shevchenko
When cast
pci_power_ttype of variables a static analizer tool complains on that.
include/linux/pci.h:119:37: warning: cast from restrictedpci_power_tEnforce type casting to make static analizer happy.
Signed-off-by Andy Shevchenko <[email protected]>
Applied to pci/pm for v4.8, thanks, Andy.
Quoted 24 lines
--- include/linux/pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/pci.h +1
-1@@ -116,7 +116,7 @@ extern const char *pci_power_names[];static inline const char *pci_power_name (pci_power_t state) { -return pci_power_names[1 + (int ) state]; +return pci_power_names[1 + (__force int ) state]; }#define PCI_PM_D2_DELAY 200Signature · 6 lines
2.8.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Bjorn Helgaas
Quoted 4 lines · Andy Shevchenko
When cast
pci_power_ttype of variables a static analizer tool complains on
that.
Quoted 8 lines
Quoted 6 lines
include/linux/pci.h:119:37: warning: cast from restrictedpci_power_tEnforce type casting to make static analizer happy.
Signed-off-by Andy Shevchenko <[email protected]>Applied to pci/pm for v4.8, thanks, Andy.
Thanks.
By the way, what was the main point to use __bitwise annotation to this type in the first place?
Quoted 26 lines
Quoted 26 lines
---
include/linux/pci.h | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)include/linux/pci.h +0
-0@@ -116,7 +116,7 @@ extern const char *pci_power_names[];
static inline const char *pci_power_name(pci_power_t state) {include/linux/pci.h +1
-1-return pci_power_names[1 + (int ) state]; +return pci_power_names[1 + (__force int ) state];}
#definePCI_PM_D2_DELAY200
--
2.8.1--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 11 lines · Andy Shevchenko
Quoted 10 lines · Bjorn Helgaas
Quoted 9 lines · Andy Shevchenko
When cast
pci_power_ttype of variables a static analizer tool complains on
that.
include/linux/pci.h:119:37: warning: cast from restrictedpci_power_tEnforce type casting to make static analizer happy.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Andy Shevchenko <[email protected]>Applied to pci/pm for v4.8, thanks, Andy.
Thanks.
By the way, what was the main point to use
__bitwiseannotation to this type in the first place?
I don't know. It looks like pci_power_t was the first use of __bitwise in pci.h, added by e8191db240d2 ("[PATCH] PCI: Cleanup PCI power states"). That changelog mentions type-safety, but I must admit that doesn't make it obvious to me.
Bjorn
Quoted 24 lines · Bjorn Helgaas
Quoted 15 lines · Andy Shevchenko
Quoted 14 lines · Bjorn Helgaas
Quoted 12 lines · Andy Shevchenko
When cast
pci_power_ttype of variables a static analizer tool complains on
that.include/linux/pci.h:119:37: warning: cast fromrestricted
pci_power_tEnforce type casting to make static analizer happy.
Signed-off-by Andy Shevchenko <[email protected]m>
Quoted 7 lines
Quoted 1 line
Applied to pci/pm for v4.8, thanks, Andy.
Thanks.
By the way, what was the main point to use
__bitwiseannotation to this
type in the first place?
Quoted 7 lines
I don't know. It looks like
pci_power_twas the first use of__bitwiseinpci.h, added bye8191db240d2("[PATCH] PCI: Cleanup PCI power states").
That changelog mentions type-safety, but I must admit that doesn't make it
obvious to me.
I'm asking since any code which is using this type (all direct assignments or comparisons) brings a static analyzer complain. You may check by yourself with (my usual command to build kernel)
% make C=1 CF=-D__CHECK_ENDIAN__ W=1 -j64
--
Andy Shevchenko <[email protected]> Intel Finland Oy