diff mbox series

[XEN,1/4] xen/pci: rename local variable to address MISRA C:2012 Rule 5.3

Message ID c9c6dd21ec6e88895ebc15ee6fe96090168afb51.1690810346.git.nicola.vetrini@bugseng.com (mailing list archive)
State Superseded
Headers show
Series xen: address MISRA C:2012 Rule 5.3 | expand

Commit Message

Nicola Vetrini July 31, 2023, 1:34 p.m. UTC
The rename s/pdev_type/pci_dev_type/ is done to avoid shadowing
the homonymous function declaration.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
 xen/drivers/passthrough/pci.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Jan Beulich July 31, 2023, 2:16 p.m. UTC | #1
On 31.07.2023 15:34, Nicola Vetrini wrote:
> --- a/xen/drivers/passthrough/pci.c
> +++ b/xen/drivers/passthrough/pci.c
> @@ -650,12 +650,12 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
>      struct pci_seg *pseg;
>      struct pci_dev *pdev;
>      unsigned int slot = PCI_SLOT(devfn), func = PCI_FUNC(devfn);
> -    const char *pdev_type;
> +    const char *pci_dev_type;

I've always been wondering what purpose the pdev_ prefix served here.
There's no other "type" variable in the function, so why make the name
longer? (I'm okay to adjust on commit, provided you agree.)

Jan
Nicola Vetrini July 31, 2023, 2:48 p.m. UTC | #2
On 31/07/2023 16:16, Jan Beulich wrote:
> On 31.07.2023 15:34, Nicola Vetrini wrote:
>> --- a/xen/drivers/passthrough/pci.c
>> +++ b/xen/drivers/passthrough/pci.c
>> @@ -650,12 +650,12 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
>>      struct pci_seg *pseg;
>>      struct pci_dev *pdev;
>>      unsigned int slot = PCI_SLOT(devfn), func = PCI_FUNC(devfn);
>> -    const char *pdev_type;
>> +    const char *pci_dev_type;
> 
> I've always been wondering what purpose the pdev_ prefix served here.
> There's no other "type" variable in the function, so why make the name
> longer? (I'm okay to adjust on commit, provided you agree.)
> 
> Jan

No objections.
Stefano Stabellini July 31, 2023, 9:30 p.m. UTC | #3
On Mon, 31 Jul 2023, Nicola Vetrini wrote:
> On 31/07/2023 16:16, Jan Beulich wrote:
> > On 31.07.2023 15:34, Nicola Vetrini wrote:
> > > --- a/xen/drivers/passthrough/pci.c
> > > +++ b/xen/drivers/passthrough/pci.c
> > > @@ -650,12 +650,12 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
> > >      struct pci_seg *pseg;
> > >      struct pci_dev *pdev;
> > >      unsigned int slot = PCI_SLOT(devfn), func = PCI_FUNC(devfn);
> > > -    const char *pdev_type;
> > > +    const char *pci_dev_type;
> > 
> > I've always been wondering what purpose the pdev_ prefix served here.
> > There's no other "type" variable in the function, so why make the name
> > longer? (I'm okay to adjust on commit, provided you agree.)
> > 
> > Jan
> 
> No objections.

I reviewed the patch and it is correct:

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


Jan, feel free to pick any name you prefer on commit, e.g. "type".
diff mbox series

Patch

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 95846e84f2..1dc519d1b6 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -650,12 +650,12 @@  int pci_add_device(u16 seg, u8 bus, u8 devfn,
     struct pci_seg *pseg;
     struct pci_dev *pdev;
     unsigned int slot = PCI_SLOT(devfn), func = PCI_FUNC(devfn);
-    const char *pdev_type;
+    const char *pci_dev_type;
     int ret;
     bool pf_is_extfn = false;
 
     if ( !info )
-        pdev_type = "device";
+        pci_dev_type = "device";
     else if ( info->is_virtfn )
     {
         pcidevs_lock();
@@ -668,12 +668,12 @@  int pci_add_device(u16 seg, u8 bus, u8 devfn,
         if ( !pdev )
             pci_add_device(seg, info->physfn.bus, info->physfn.devfn,
                            NULL, node);
-        pdev_type = "virtual function";
+        pci_dev_type = "virtual function";
     }
     else if ( info->is_extfn )
-        pdev_type = "extended function";
+        pci_dev_type = "extended function";
     else
-        pdev_type = "device";
+        pci_dev_type = "device";
 
     ret = xsm_resource_plug_pci(XSM_PRIV, (seg << 16) | (bus << 8) | devfn);
     if ( ret )
@@ -780,7 +780,7 @@  out:
     pcidevs_unlock();
     if ( !ret )
     {
-        printk(XENLOG_DEBUG "PCI add %s %pp\n", pdev_type,  &pdev->sbdf);
+        printk(XENLOG_DEBUG "PCI add %s %pp\n", pci_dev_type,  &pdev->sbdf);
         while ( pdev->phantom_stride )
         {
             func += pdev->phantom_stride;