After virBitmapEqual is able to compare NULL bitmaps few bits of code can be cleaned up. --- Version 2 cleans up code paths that would do a duplicate check now. src/conf/domain_conf.c | 40 ++++++++++------------------------------ src/conf/numatune_conf.c | 3 --- src/util/virbitmap.c | 6 ++++++ src/util/virbitmap.h | 3 +-- 4 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9ff3819..d364d3c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15625,18 +15625,10 @@ virDomainDefCheckABIStability(virDomainDefPtr src, goto error; } - if (src_huge->nodemask && dst_huge->nodemask) { - if (!virBitmapEqual(src_huge->nodemask, dst_huge->nodemask)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Target huge page nodemask does not match source")); - goto error; - } - } else { - if (src_huge->nodemask || dst_huge->nodemask) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Target huge page nodemask does not match source")); - goto error; - } + if (!virBitmapEqual(src_huge->nodemask, dst_huge->nodemask)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target huge page nodemask does not match source")); + goto error; } } @@ -19126,20 +19118,12 @@ virDomainIsAllVcpupinInherited(virDomainDefPtr def) { size_t i; - if (!def->cpumask) { - if (def->cputune.nvcpupin) + for (i = 0; i < def->cputune.nvcpupin; i++) { + if (!virBitmapEqual(def->cputune.vcpupin[i]->cpumask, def->cpumask)) return false; - else - return true; - } else { - for (i = 0; i < def->cputune.nvcpupin; i++) { - if (!virBitmapEqual(def->cputune.vcpupin[i]->cpumask, - def->cpumask)) - return false; - } + } - return true; - } + return true; } @@ -19477,9 +19461,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, for (i = 0; i < def->cputune.nvcpupin; i++) { char *cpumask; /* Ignore the vcpupin which inherit from "cpuset of "<vcpu>." */ - if (def->cpumask && - virBitmapEqual(def->cpumask, - def->cputune.vcpupin[i]->cpumask)) + if (virBitmapEqual(def->cpumask, def->cputune.vcpupin[i]->cpumask)) continue; virBufferAsprintf(buf, "<vcpupin vcpu='%u' ", @@ -19506,9 +19488,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, for (i = 0; i < def->cputune.niothreadspin; i++) { char *cpumask; /* Ignore the iothreadpin which inherit from "cpuset of "<vcpu>." */ - if (def->cpumask && - virBitmapEqual(def->cpumask, - def->cputune.iothreadspin[i]->cpumask)) + if (virBitmapEqual(def->cpumask, def->cputune.iothreadspin[i]->cpumask)) continue; virBufferAsprintf(buf, "<iothreadpin iothread='%u' ", diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c index ad928e0..323cd59 100644 --- a/src/conf/numatune_conf.c +++ b/src/conf/numatune_conf.c @@ -542,9 +542,6 @@ virDomainNumatuneNodesEqual(virDomainNumatunePtr n1, if (!nd1->nodeset && !nd2->nodeset) continue; - if (!nd1->nodeset || !nd2->nodeset) - return false; - if (nd1->mode != nd2->mode) return false; diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 05c50e4..d5b0035 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -504,6 +504,12 @@ bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2) virBitmapPtr tmp; size_t i; + if (!b1 && !b2) + return true; + + if (!b1 || !b2) + return false; + if (b1->max_bit > b2->max_bit) { tmp = b1; b1 = b2; diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 565264c..a347f0a 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -84,8 +84,7 @@ virBitmapPtr virBitmapNewData(void *data, int len) ATTRIBUTE_NONNULL(1); int virBitmapToData(virBitmapPtr bitmap, unsigned char **data, int *dataLen) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2); size_t virBitmapSize(virBitmapPtr bitmap) ATTRIBUTE_NONNULL(1); -- 2.2.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list