diff mbox series

[XEN,v2,3/3] xen/pci: address violations of MISRA C Rule 20.7

Message ID df48ce446cf6409eda04460109f3082b39c4f618.1714487169.git.nicola.vetrini@bugseng.com (mailing list archive)
State Superseded
Headers show
Series address violations of MISRA C Rule 20.7 | expand

Commit Message

Nicola Vetrini April 30, 2024, 2:28 p.m. UTC
MISRA C Rule 20.7 states: "Expressions resulting from the expansion
of macro parameters shall be enclosed in parentheses". Therefore, some
macro definitions should gain additional parentheses to ensure that all
current and future users will be safe with respect to expansions that
can possibly alter the semantics of the passed-in macro parameter.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
 xen/include/xen/pci_regs.h | 6 +++---
 xen/include/xen/vpci.h     | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Jan Beulich April 30, 2024, 3:15 p.m. UTC | #1
On 30.04.2024 16:28, Nicola Vetrini wrote:
> MISRA C Rule 20.7 states: "Expressions resulting from the expansion
> of macro parameters shall be enclosed in parentheses". Therefore, some
> macro definitions should gain additional parentheses to ensure that all
> current and future users will be safe with respect to expansions that
> can possibly alter the semantics of the passed-in macro parameter.
> 
> No functional change.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
Jan Beulich May 14, 2024, 9:11 a.m. UTC | #2
On 30.04.2024 16:28, Nicola Vetrini wrote:
> MISRA C Rule 20.7 states: "Expressions resulting from the expansion
> of macro parameters shall be enclosed in parentheses". Therefore, some
> macro definitions should gain additional parentheses to ensure that all
> current and future users will be safe with respect to expansions that
> can possibly alter the semantics of the passed-in macro parameter.
> 
> No functional change.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> ---
>  xen/include/xen/pci_regs.h | 6 +++---
>  xen/include/xen/vpci.h     | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)

I notice you committed this with just my ack. I'm pretty sure Roger doesn't
mind, but formally his ack would have been required (hence why I didn't
commit it already before my vacation).

Jan
diff mbox series

Patch

diff --git a/xen/include/xen/pci_regs.h b/xen/include/xen/pci_regs.h
index 9909b27425a5..0bc18efabb74 100644
--- a/xen/include/xen/pci_regs.h
+++ b/xen/include/xen/pci_regs.h
@@ -445,9 +445,9 @@ 
 #define PCI_EXP_RTSTA		32	/* Root Status */
 
 /* Extended Capabilities (PCI-X 2.0 and Express) */
-#define PCI_EXT_CAP_ID(header)		(header & 0x0000ffff)
-#define PCI_EXT_CAP_VER(header)		((header >> 16) & 0xf)
-#define PCI_EXT_CAP_NEXT(header)	((header >> 20) & 0xffc)
+#define PCI_EXT_CAP_ID(header)		((header) & 0x0000ffff)
+#define PCI_EXT_CAP_VER(header)		(((header) >> 16) & 0xf)
+#define PCI_EXT_CAP_NEXT(header)	(((header) >> 20) & 0xffc)
 
 #define PCI_EXT_CAP_ID_ERR	1
 #define PCI_EXT_CAP_ID_VC	2
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index e89c571890b2..6e4c972f35ed 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -23,7 +23,7 @@  typedef int vpci_register_init_t(struct pci_dev *dev);
 
 #define REGISTER_VPCI_INIT(x, p)                \
   static vpci_register_init_t *const x##_entry  \
-               __used_section(".data.vpci." p) = x
+               __used_section(".data.vpci." p) = (x)
 
 /* Assign vPCI to device by adding handlers. */
 int __must_check vpci_assign_device(struct pci_dev *pdev);