On 4/2/22 12:31, Amneesh Singh wrote: > Related: https://gitlab.com/libvirt/libvirt/-/issues/9 > Signed-off-by: Amneesh Singh <natto@xxxxxxxxxxxxx> > --- > src/util/virarch.c | 2 +- > src/util/virarch.h | 2 +- > tools/virsh-completer-host.c | 12 ++++++++++++ > tools/virsh-completer-host.h | 5 +++++ > tools/virsh-host.c | 4 ++++ > 5 files changed, 23 insertions(+), 2 deletions(-) > > diff --git a/src/util/virarch.c b/src/util/virarch.c > index 2134dd6..b1ea85e 100644 > --- a/src/util/virarch.c > +++ b/src/util/virarch.c > @@ -123,7 +123,7 @@ virArchEndian virArchGetEndian(virArch arch) > * > * Return the string name of the architecture > */ > -const char *virArchToString(virArch arch) > +const char *virArchToString(int arch) I think instead of changing this type (which should go into a separate patch anyway) ... > { > if (arch >= VIR_ARCH_LAST) > arch = VIR_ARCH_NONE; > diff --git a/src/util/virarch.h b/src/util/virarch.h > index 81b1b27..7daa0f1 100644 > --- a/src/util/virarch.h > +++ b/src/util/virarch.h > @@ -110,7 +110,7 @@ typedef enum { > > unsigned int virArchGetWordSize(virArch arch); > virArchEndian virArchGetEndian(virArch arch); > -const char *virArchToString(virArch arch); > +const char *virArchToString(int arch); > virArch virArchFromString(const char *name); > > virArch virArchFromHost(void); > diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c > index 14c68d3..67a7687 100644 > --- a/tools/virsh-completer-host.c > +++ b/tools/virsh-completer-host.c > @@ -27,6 +27,7 @@ > #include "virxml.h" > #include "virutil.h" > #include "virsh-host.h" > +#include "virarch.h" > #include "conf/domain_conf.h" > > static char * > @@ -192,3 +193,14 @@ virshVirtTypeCompleter(vshControl *ctl G_GNUC_UNUSED, > return virshEnumComplete(VIR_DOMAIN_VIRT_LAST, > virDomainVirtTypeToString); > } > + > +char ** > +virshArchCompleter(vshControl *ctl G_GNUC_UNUSED, > + const vshCmd *cmd G_GNUC_UNUSED, > + unsigned int flags) > +{ > + virCheckFlags(0, NULL); > + > + return virshEnumComplete(VIR_ARCH_LAST, > + virArchToString); .. this callback can be typecasted. The reason is that virarch.c uses virArch for type of variables instead of int. I worry that switching to plain int may tempt to use int for variables too in which case we'd lose this nice feature of compilers: switch (var) warns you if var is of an enum type, but it doesn't if it's a plain int. Michal