[libvirt] [PATCH 1/3] conf: Rename mode parameter in virCPUDefParseXML

Jiri Denemark posted 3 patches 8 years, 9 months ago
[libvirt] [PATCH 1/3] conf: Rename mode parameter in virCPUDefParseXML
Posted by Jiri Denemark 8 years, 9 months ago
The type of this parameter is virCPUType so calling it 'mode' is pretty
strange, 'type' is a much better name.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/conf/cpu_conf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index b78531e60..623b1699f 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -230,7 +230,7 @@ virCPUDefCopy(const virCPUDef *cpu)
 virCPUDefPtr
 virCPUDefParseXML(xmlNodePtr node,
                   xmlXPathContextPtr ctxt,
-                  virCPUType mode)
+                  virCPUType type)
 {
     virCPUDefPtr def;
     xmlNodePtr *nodes = NULL;
@@ -250,7 +250,7 @@ virCPUDefParseXML(xmlNodePtr node,
     if (VIR_ALLOC(def) < 0)
         return NULL;
 
-    if (mode == VIR_CPU_TYPE_AUTO) {
+    if (type == VIR_CPU_TYPE_AUTO) {
         if (virXPathBoolean("boolean(./arch)", ctxt)) {
             if (virXPathBoolean("boolean(./@match)", ctxt)) {
                 virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -263,7 +263,7 @@ virCPUDefParseXML(xmlNodePtr node,
             def->type = VIR_CPU_TYPE_GUEST;
         }
     } else {
-        def->type = mode;
+        def->type = type;
     }
 
     if ((cpuMode = virXMLPropString(node, "mode"))) {
-- 
2.12.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3] conf: Rename mode parameter in virCPUDefParseXML
Posted by Peter Krempa 8 years, 9 months ago
On Tue, Apr 25, 2017 at 20:48:43 +0200, Jiri Denemark wrote:
> The type of this parameter is virCPUType so calling it 'mode' is pretty
> strange, 'type' is a much better name.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/conf/cpu_conf.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Briefly-looked-at-by: Peter Krempa <pkrempa@redhat.com>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3] conf: Rename mode parameter in virCPUDefParseXML
Posted by John Ferlan 8 years, 9 months ago
On 04/25/2017 02:48 PM, Jiri Denemark wrote:
> The type of this parameter is virCPUType so calling it 'mode' is pretty
> strange, 'type' is a much better name.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/conf/cpu_conf.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
> index b78531e60..623b1699f 100644
> --- a/src/conf/cpu_conf.c
> +++ b/src/conf/cpu_conf.c
> @@ -230,7 +230,7 @@ virCPUDefCopy(const virCPUDef *cpu)
>  virCPUDefPtr
>  virCPUDefParseXML(xmlNodePtr node,
>                    xmlXPathContextPtr ctxt,
> -                  virCPUType mode)
> +                  virCPUType type)

s/type/cputype

I have this faint recollection that a variable of name 'type' won't be
good for some compiler.

John

>  {
>      virCPUDefPtr def;
>      xmlNodePtr *nodes = NULL;
> @@ -250,7 +250,7 @@ virCPUDefParseXML(xmlNodePtr node,
>      if (VIR_ALLOC(def) < 0)
>          return NULL;
>  
> -    if (mode == VIR_CPU_TYPE_AUTO) {
> +    if (type == VIR_CPU_TYPE_AUTO) {
>          if (virXPathBoolean("boolean(./arch)", ctxt)) {
>              if (virXPathBoolean("boolean(./@match)", ctxt)) {
>                  virReportError(VIR_ERR_XML_ERROR, "%s",
> @@ -263,7 +263,7 @@ virCPUDefParseXML(xmlNodePtr node,
>              def->type = VIR_CPU_TYPE_GUEST;
>          }
>      } else {
> -        def->type = mode;
> +        def->type = type;
>      }
>  
>      if ((cpuMode = virXMLPropString(node, "mode"))) {
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3] conf: Rename mode parameter in virCPUDefParseXML
Posted by Peter Krempa 8 years, 9 months ago
On Thu, Apr 27, 2017 at 11:41:12 -0400, John Ferlan wrote:
> 
> On 04/25/2017 02:48 PM, Jiri Denemark wrote:
> > The type of this parameter is virCPUType so calling it 'mode' is pretty
> > strange, 'type' is a much better name.
> > 
> > Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> > ---
> >  src/conf/cpu_conf.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
> > index b78531e60..623b1699f 100644
> > --- a/src/conf/cpu_conf.c
> > +++ b/src/conf/cpu_conf.c
> > @@ -230,7 +230,7 @@ virCPUDefCopy(const virCPUDef *cpu)
> >  virCPUDefPtr
> >  virCPUDefParseXML(xmlNodePtr node,
> >                    xmlXPathContextPtr ctxt,
> > -                  virCPUType mode)
> > +                  virCPUType type)
> 
> s/type/cputype
> 
> I have this faint recollection that a variable of name 'type' won't be
> good for some compiler.

Brief excerpt from 'git grep "int type"':

src/conf/domain_conf.h:    int type;
src/conf/domain_conf.h:    int type;
src/conf/domain_conf.h:    int type;
src/conf/domain_conf.h:    int type;
src/conf/domain_conf.h:    int type;
src/conf/domain_conf.h:void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
src/conf/domain_conf.h:                                  int type);
src/conf/domain_conf.h:int virDomainControllerFind(const virDomainDef *def, int type, int idx);
src/conf/domain_conf.h:int virDomainControllerFindByType(virDomainDefPtr def, int type);

I think type is okay and widely used.

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