[libvirt] [PATCH v2 05/15] qemu: Simplify modelName stringification

Peter Krempa pkrempa at redhat.com
Tue Feb 20 12:52:24 UTC 2018


On Mon, Feb 19, 2018 at 16:26:35 +0100, Andrea Bolognani wrote:
> On Mon, 2018-02-19 at 16:06 +0100, Peter Krempa wrote:
> > >      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)
> > > -            modelName = virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
> > > +        const virDomainPCIControllerOpts *pciopts = &def->opts.pciopts;
> > > +        const char *modelName = virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
> > 
> > This is not equivalent. virDomainControllerPCIModelName implementation
> > actually defines a string for VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT so
> > it will not return NULL and the commit message does not explain why/if
> > it is actually okay.
> 
> The result doesn't change because the PCIE_ROOT case in the switch
> statement immediately following the conversion does nothing but
> error out, which makes whether or not modelName is NULL irrelevant.

I mistakenly looked into the case for PCI_ROOT, so that mislead me. I
think it's okay in this case even without a comment. Thanks for the
explanation.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180220/3e0bfdcc/attachment-0001.sig>


More information about the libvir-list mailing list