[libvirt] [PATCH 2/2] hostdev: Remove temporary variable when checking for VF
Andrea Bolognani
abologna at redhat.com
Thu Feb 25 16:27:00 UTC 2016
On Thu, 2016-02-25 at 15:51 +0100, Michal Privoznik wrote:
> On 25.02.2016 14:02, Andrea Bolognani wrote:
> >
> > The virHostdevIsVirtualFunction() was called exactly twice, and in
> > both cases the return value was saved to a temporary variable before
> > being checked. This would be okay if it improved readability, but in
> > this case is pretty pointless.
> >
> > Get rid of the temporary variable and check the return value
> > directly; while at it, change the check from '<= 0' to '!= 1' to
> > align it with the way other similar *IsVirtualFunction() functions
> > are used thorough the code.
> > ---
> > src/util/virhostdev.c | 8 ++------
> > 1 file changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
> > index 9ae217d..2db0da0 100644
> > --- a/src/util/virhostdev.c
> > +++ b/src/util/virhostdev.c
> > @@ -416,10 +416,8 @@ virHostdevNetConfigReplace(virDomainHostdevDefPtr hostdev,
> > int vf = -1;
> > int vlanid = -1;
> > bool port_profile_associate = true;
> > - int isvf;
> >
> > - isvf = virHostdevIsVirtualFunction(hostdev);
> > - if (isvf <= 0) {
> > + if (virHostdevIsVirtualFunction(hostdev) != 1) {
> > virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> > _("Interface type hostdev is currently supported on"
> > " SR-IOV Virtual Functions only"));
> > @@ -489,7 +487,6 @@ virHostdevNetConfigRestore(virDomainHostdevDefPtr hostdev,
> > int ret = -1;
> > int vf = -1;
> > bool port_profile_associate = false;
> > - int isvf;
> >
> > /* This is only needed for PCI devices that have been defined
> > * using <interface type='hostdev'>. For all others, it is a NOP.
> > @@ -497,8 +494,7 @@ virHostdevNetConfigRestore(virDomainHostdevDefPtr hostdev,
> > if (!virHostdevIsPCINetDevice(hostdev))
> > return 0;
> >
> > - isvf = virHostdevIsVirtualFunction(hostdev);
> > - if (isvf <= 0) {
> > + if (virHostdevIsVirtualFunction(hostdev) != 1) {
> > virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> > _("Interface type hostdev is currently supported on"
> > " SR-IOV Virtual Functions only"));
> >
> ACK and safe for the freeze.
Pushed, thanks :)
--
Andrea Bolognani
Software Engineer - Virtualization Team
More information about the libvir-list
mailing list