All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: Megan Kamiya <megan.a.kamiya@intel.com>, linux-pci@vger.kernel.org
Subject: Re: [PATCH] pci: Parenthesize parameters in PCI_DEVID and PCI_VPD_LRDT_ID macros
Date: Tue, 16 Sep 2014 17:10:40 -0600	[thread overview]
Message-ID: <20140916231040.GF5050@google.com> (raw)
In-Reply-To: <1409973550-29434-1-git-send-email-jeffrey.t.kirsher@intel.com>

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
> 

  parent reply	other threads:[~2014-09-16 23:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-06  3:19 [PATCH] pci: Parenthesize parameters in PCI_DEVID and PCI_VPD_LRDT_ID macros Jeff Kirsher
2014-09-16 16:08 ` Jeff Kirsher
2014-09-16 23:10 ` Bjorn Helgaas [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-09-06 10:49 Jeff Kirsher
2014-09-06 10:55 ` Jeff Kirsher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140916231040.GF5050@google.com \
    --to=bhelgaas@google.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=megan.a.kamiya@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.