linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci: Parenthesize parameters in PCI_DEVID and PCI_VPD_LRDT_ID macros
@ 2014-09-06 10:49 Jeff Kirsher
  2014-09-06 10:55 ` Jeff Kirsher
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Kirsher @ 2014-09-06 10:49 UTC (permalink / raw)
  To: bhelgaas; +Cc: Megan Kamiya, linux-pci, Jeff Kirsher

From: Megan Kamiya <megan.a.kamiya@intel.com>

Add parentheses around parameters in PCI_DEVID and PCI_VPD_LRDT_ID
macros to prevent possible expansion errors as described by the CERT
Secure Coding Standard: PRE01-C: Use parentheses within macros around
parameter names

Signed-off-by: Megan Kamiya <megan.a.kamiya@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 include/linux/pci.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index 61978a4..cb744f3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -45,7 +45,7 @@
  * In the interest of not exposing interfaces to user-space unnecessarily,
  * the following kernel-only defines are being added here.
  */
-#define PCI_DEVID(bus, devfn)  ((((u16)bus) << 8) | devfn)
+#define PCI_DEVID(bus, devfn)  ((((u16)(bus)) << 8) | (devfn))
 /* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */
 #define PCI_BUS_NUM(x) (((x) >> 8) & 0xff)
 
@@ -1701,7 +1701,7 @@ bool pci_acs_path_enabled(struct pci_dev *start,
 			  struct pci_dev *end, u16 acs_flags);
 
 #define PCI_VPD_LRDT			0x80	/* Large Resource Data Type */
-#define PCI_VPD_LRDT_ID(x)		(x | PCI_VPD_LRDT)
+#define PCI_VPD_LRDT_ID(x)		((x) | PCI_VPD_LRDT)
 
 /* Large Resource Data Type Tag Item Names */
 #define PCI_VPD_LTIN_ID_STRING		0x02	/* Identifier String */
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] pci: Parenthesize parameters in PCI_DEVID and PCI_VPD_LRDT_ID macros
  2014-09-06 10:49 [PATCH] pci: Parenthesize parameters in PCI_DEVID and PCI_VPD_LRDT_ID macros Jeff Kirsher
@ 2014-09-06 10:55 ` Jeff Kirsher
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Kirsher @ 2014-09-06 10:55 UTC (permalink / raw)
  To: bhelgaas; +Cc: Megan Kamiya, linux-pci

[-- Attachment #1: Type: text/plain, Size: 685 bytes --]

On Sat, 2014-09-06 at 03:49 -0700, Jeff Kirsher wrote:
> From: Megan Kamiya <megan.a.kamiya@intel.com>
> 
> Add parentheses around parameters in PCI_DEVID and PCI_VPD_LRDT_ID
> macros to prevent possible expansion errors as described by the CERT
> Secure Coding Standard: PRE01-C: Use parentheses within macros around
> parameter names
> 
> Signed-off-by: Megan Kamiya <megan.a.kamiya@intel.com>
> Tested-by: Aaron Brown <aaron.f.brown@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
>  include/linux/pci.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Sorry for the duplicate, I did not mean to send this out a second time.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pci: Parenthesize parameters in PCI_DEVID and PCI_VPD_LRDT_ID macros
  2014-09-06  3:19 Jeff Kirsher
  2014-09-16 16:08 ` Jeff Kirsher
@ 2014-09-16 23:10 ` Bjorn Helgaas
  1 sibling, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2014-09-16 23:10 UTC (permalink / raw)
  To: Jeff Kirsher; +Cc: Megan Kamiya, linux-pci

On Fri, Sep 05, 2014 at 08:19:10PM -0700, Jeff Kirsher wrote:
> From: Megan Kamiya <megan.a.kamiya@intel.com>
> 
> Add parentheses around parameters in PCI_DEVID and PCI_VPD_LRDT_ID
> macros to prevent possible expansion errors as described by the CERT
> Secure Coding Standard: PRE01-C: Use parentheses within macros around
> parameter names
> 
> Signed-off-by: Megan Kamiya <megan.a.kamiya@intel.com>
> Tested-by: Aaron Brown <aaron.f.brown@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied to pci/misc for v3.18, thanks!

> ---
>  include/linux/pci.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 61978a4..cb744f3 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -45,7 +45,7 @@
>   * In the interest of not exposing interfaces to user-space unnecessarily,
>   * the following kernel-only defines are being added here.
>   */
> -#define PCI_DEVID(bus, devfn)  ((((u16)bus) << 8) | devfn)
> +#define PCI_DEVID(bus, devfn)  ((((u16)(bus)) << 8) | (devfn))
>  /* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */
>  #define PCI_BUS_NUM(x) (((x) >> 8) & 0xff)
>  
> @@ -1701,7 +1701,7 @@ bool pci_acs_path_enabled(struct pci_dev *start,
>  			  struct pci_dev *end, u16 acs_flags);
>  
>  #define PCI_VPD_LRDT			0x80	/* Large Resource Data Type */
> -#define PCI_VPD_LRDT_ID(x)		(x | PCI_VPD_LRDT)
> +#define PCI_VPD_LRDT_ID(x)		((x) | PCI_VPD_LRDT)
>  
>  /* Large Resource Data Type Tag Item Names */
>  #define PCI_VPD_LTIN_ID_STRING		0x02	/* Identifier String */
> -- 
> 1.9.3
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pci: Parenthesize parameters in PCI_DEVID and PCI_VPD_LRDT_ID macros
  2014-09-06  3:19 Jeff Kirsher
@ 2014-09-16 16:08 ` Jeff Kirsher
  2014-09-16 23:10 ` Bjorn Helgaas
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff Kirsher @ 2014-09-16 16:08 UTC (permalink / raw)
  To: bhelgaas; +Cc: Megan Kamiya, linux-pci

[-- Attachment #1: Type: text/plain, Size: 1619 bytes --]

On Fri, 2014-09-05 at 20:19 -0700, Jeff Kirsher wrote:
> From: Megan Kamiya <megan.a.kamiya@intel.com>
> 
> Add parentheses around parameters in PCI_DEVID and PCI_VPD_LRDT_ID
> macros to prevent possible expansion errors as described by the CERT
> Secure Coding Standard: PRE01-C: Use parentheses within macros around
> parameter names
> 
> Signed-off-by: Megan Kamiya <megan.a.kamiya@intel.com>
> Tested-by: Aaron Brown <aaron.f.brown@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
>  include/linux/pci.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Ping Bjorn?

> 
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 61978a4..cb744f3 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -45,7 +45,7 @@
>   * In the interest of not exposing interfaces to user-space unnecessarily,
>   * the following kernel-only defines are being added here.
>   */
> -#define PCI_DEVID(bus, devfn)  ((((u16)bus) << 8) | devfn)
> +#define PCI_DEVID(bus, devfn)  ((((u16)(bus)) << 8) | (devfn))
>  /* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */
>  #define PCI_BUS_NUM(x) (((x) >> 8) & 0xff)
>  
> @@ -1701,7 +1701,7 @@ bool pci_acs_path_enabled(struct pci_dev *start,
>  			  struct pci_dev *end, u16 acs_flags);
>  
>  #define PCI_VPD_LRDT			0x80	/* Large Resource Data Type */
> -#define PCI_VPD_LRDT_ID(x)		(x | PCI_VPD_LRDT)
> +#define PCI_VPD_LRDT_ID(x)		((x) | PCI_VPD_LRDT)
>  
>  /* Large Resource Data Type Tag Item Names */
>  #define PCI_VPD_LTIN_ID_STRING		0x02	/* Identifier String */



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] pci: Parenthesize parameters in PCI_DEVID and PCI_VPD_LRDT_ID macros
@ 2014-09-06  3:19 Jeff Kirsher
  2014-09-16 16:08 ` Jeff Kirsher
  2014-09-16 23:10 ` Bjorn Helgaas
  0 siblings, 2 replies; 5+ messages in thread
From: Jeff Kirsher @ 2014-09-06  3:19 UTC (permalink / raw)
  To: bhelgaas; +Cc: Megan Kamiya, linux-pci, Jeff Kirsher

From: Megan Kamiya <megan.a.kamiya@intel.com>

Add parentheses around parameters in PCI_DEVID and PCI_VPD_LRDT_ID
macros to prevent possible expansion errors as described by the CERT
Secure Coding Standard: PRE01-C: Use parentheses within macros around
parameter names

Signed-off-by: Megan Kamiya <megan.a.kamiya@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 include/linux/pci.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index 61978a4..cb744f3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -45,7 +45,7 @@
  * In the interest of not exposing interfaces to user-space unnecessarily,
  * the following kernel-only defines are being added here.
  */
-#define PCI_DEVID(bus, devfn)  ((((u16)bus) << 8) | devfn)
+#define PCI_DEVID(bus, devfn)  ((((u16)(bus)) << 8) | (devfn))
 /* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */
 #define PCI_BUS_NUM(x) (((x) >> 8) & 0xff)
 
@@ -1701,7 +1701,7 @@ bool pci_acs_path_enabled(struct pci_dev *start,
 			  struct pci_dev *end, u16 acs_flags);
 
 #define PCI_VPD_LRDT			0x80	/* Large Resource Data Type */
-#define PCI_VPD_LRDT_ID(x)		(x | PCI_VPD_LRDT)
+#define PCI_VPD_LRDT_ID(x)		((x) | PCI_VPD_LRDT)
 
 /* Large Resource Data Type Tag Item Names */
 #define PCI_VPD_LTIN_ID_STRING		0x02	/* Identifier String */
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-09-16 23:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-06 10:49 [PATCH] pci: Parenthesize parameters in PCI_DEVID and PCI_VPD_LRDT_ID macros Jeff Kirsher
2014-09-06 10:55 ` Jeff Kirsher
  -- strict thread matches above, loose matches on Subject: below --
2014-09-06  3:19 Jeff Kirsher
2014-09-16 16:08 ` Jeff Kirsher
2014-09-16 23:10 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).