[libvirt] [PATCH v2 04/15] qemu: Restrict scope in qemuBuildControllerDevStr()

Andrea Bolognani posted 15 patches 7 years, 11 months ago
There is a newer version of this series
[libvirt] [PATCH v2 04/15] qemu: Restrict scope in qemuBuildControllerDevStr()
Posted by Andrea Bolognani 7 years, 11 months ago
Some variables are only used for PCI controllers, and we're going
to add more soon. We can declare them in the 'case' scope rather
than in the function scope to make it a bit nicer.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 src/qemu/qemu_command.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5e4dfcf75..2291bf5da 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2625,8 +2625,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     int address_type = def->info.type;
-    const virDomainPCIControllerOpts *pciopts;
-    const char *modelName = NULL;
 
     *devstr = NULL;
 
@@ -2726,7 +2724,10 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
 
         break;
 
-    case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
+    case VIR_DOMAIN_CONTROLLER_TYPE_PCI: {
+        const virDomainPCIControllerOpts *pciopts;
+        const char *modelName = NULL;
+
         pciopts = &def->opts.pciopts;
         if (def->model != VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT &&
             def->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST)
@@ -2781,6 +2782,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
             goto error;
         }
         break;
+    }
 
     case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
     case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 04/15] qemu: Restrict scope in qemuBuildControllerDevStr()
Posted by Peter Krempa 7 years, 11 months ago
On Fri, Feb 16, 2018 at 17:28:01 +0100, Andrea Bolognani wrote:
> Some variables are only used for PCI controllers, and we're going
> to add more soon. We can declare them in the 'case' scope rather
> than in the function scope to make it a bit nicer.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  src/qemu/qemu_command.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 5e4dfcf75..2291bf5da 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -2625,8 +2625,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
>  {
>      virBuffer buf = VIR_BUFFER_INITIALIZER;
>      int address_type = def->info.type;
> -    const virDomainPCIControllerOpts *pciopts;
> -    const char *modelName = NULL;
>  
>      *devstr = NULL;

Since the next patch changes both lines again I suggest you squash it
into the next patch.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 04/15] qemu: Restrict scope in qemuBuildControllerDevStr()
Posted by Andrea Bolognani 7 years, 11 months ago
On Mon, 2018-02-19 at 16:00 +0100, Peter Krempa wrote:
> > @@ -2625,8 +2625,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
> >  {
> >      virBuffer buf = VIR_BUFFER_INITIALIZER;
> >      int address_type = def->info.type;
> > -    const virDomainPCIControllerOpts *pciopts;
> > -    const char *modelName = NULL;
> >  
> >      *devstr = NULL;
> 
> Since the next patch changes both lines again I suggest you squash it
> into the next patch.

They're semantically independent changes so I thought it would be
better to perform them separately, but I can squash them together
if that's your preference.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list