提交 26bfa2a6 编写于 作者: J Jiri Denemark

cpu_x86: Remove comparisons to NULL

Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 aa9e0ef0
...@@ -248,7 +248,7 @@ x86DataCpuid(const virCPUx86Data *data, ...@@ -248,7 +248,7 @@ x86DataCpuid(const virCPUx86Data *data,
void void
virCPUx86DataFree(virCPUx86Data *data) virCPUx86DataFree(virCPUx86Data *data)
{ {
if (data == NULL) if (!data)
return; return;
VIR_FREE(data->data); VIR_FREE(data->data);
...@@ -384,7 +384,7 @@ x86DataIsEmpty(virCPUx86Data *data) ...@@ -384,7 +384,7 @@ x86DataIsEmpty(virCPUx86Data *data)
{ {
virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data); virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data);
return x86DataCpuidNext(&iter) == NULL; return !x86DataCpuidNext(&iter);
} }
...@@ -416,7 +416,7 @@ x86DataToCPUFeatures(virCPUDefPtr cpu, ...@@ -416,7 +416,7 @@ x86DataToCPUFeatures(virCPUDefPtr cpu,
{ {
virCPUx86FeaturePtr feature = map->features; virCPUx86FeaturePtr feature = map->features;
while (feature != NULL) { while (feature) {
if (x86DataIsSubset(data, feature->data)) { if (x86DataIsSubset(data, feature->data)) {
x86DataSubtract(data, feature->data); x86DataSubtract(data, feature->data);
if (virCPUDefAddFeature(cpu, feature->name, policy) < 0) if (virCPUDefAddFeature(cpu, feature->name, policy) < 0)
...@@ -603,7 +603,7 @@ x86FeatureNew(void) ...@@ -603,7 +603,7 @@ x86FeatureNew(void)
static void static void
x86FeatureFree(virCPUx86FeaturePtr feature) x86FeatureFree(virCPUx86FeaturePtr feature)
{ {
if (feature == NULL) if (!feature)
return; return;
VIR_FREE(feature->name); VIR_FREE(feature->name);
...@@ -623,7 +623,7 @@ x86FeatureCopy(virCPUx86FeaturePtr src) ...@@ -623,7 +623,7 @@ x86FeatureCopy(virCPUx86FeaturePtr src)
if (VIR_STRDUP(feature->name, src->name) < 0) if (VIR_STRDUP(feature->name, src->name) < 0)
goto error; goto error;
if ((feature->data = x86DataCopy(src->data)) == NULL) if (!(feature->data = x86DataCopy(src->data)))
goto error; goto error;
return feature; return feature;
...@@ -641,7 +641,7 @@ x86FeatureFind(virCPUx86MapPtr map, ...@@ -641,7 +641,7 @@ x86FeatureFind(virCPUx86MapPtr map,
virCPUx86FeaturePtr feature; virCPUx86FeaturePtr feature;
feature = map->features; feature = map->features;
while (feature != NULL) { while (feature) {
if (STREQ(feature->name, name)) if (STREQ(feature->name, name))
return feature; return feature;
...@@ -728,7 +728,7 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, ...@@ -728,7 +728,7 @@ x86FeatureLoad(xmlXPathContextPtr ctxt,
goto error; goto error;
feature->name = virXPathString("string(@name)", ctxt); feature->name = virXPathString("string(@name)", ctxt);
if (feature->name == NULL) { if (!feature->name) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing CPU feature name")); "%s", _("Missing CPU feature name"));
goto ignore; goto ignore;
...@@ -761,14 +761,14 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, ...@@ -761,14 +761,14 @@ x86FeatureLoad(xmlXPathContextPtr ctxt,
} }
if (!migratable) { if (!migratable) {
if ((migrate_blocker = x86FeatureCopy(feature)) == NULL) if (!(migrate_blocker = x86FeatureCopy(feature)))
goto error; goto error;
migrate_blocker->next = map->migrate_blockers; migrate_blocker->next = map->migrate_blockers;
map->migrate_blockers = migrate_blocker; map->migrate_blockers = migrate_blocker;
} }
if (map->features == NULL) { if (!map->features) {
map->features = feature; map->features = feature;
} else { } else {
feature->next = map->features; feature->next = map->features;
...@@ -842,7 +842,7 @@ x86ModelNew(void) ...@@ -842,7 +842,7 @@ x86ModelNew(void)
static void static void
x86ModelFree(virCPUx86ModelPtr model) x86ModelFree(virCPUx86ModelPtr model)
{ {
if (model == NULL) if (!model)
return; return;
VIR_FREE(model->name); VIR_FREE(model->name);
...@@ -876,7 +876,7 @@ x86ModelFind(virCPUx86MapPtr map, ...@@ -876,7 +876,7 @@ x86ModelFind(virCPUx86MapPtr map,
virCPUx86ModelPtr model; virCPUx86ModelPtr model;
model = map->models; model = map->models;
while (model != NULL) { while (model) {
if (STREQ(model->name, name)) if (STREQ(model->name, name))
return model; return model;
...@@ -896,13 +896,13 @@ x86ModelFromCPU(const virCPUDef *cpu, ...@@ -896,13 +896,13 @@ x86ModelFromCPU(const virCPUDef *cpu,
size_t i; size_t i;
if (policy == VIR_CPU_FEATURE_REQUIRE) { if (policy == VIR_CPU_FEATURE_REQUIRE) {
if ((model = x86ModelFind(map, cpu->model)) == NULL) { if (!(model = x86ModelFind(map, cpu->model))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown CPU model %s"), cpu->model); _("Unknown CPU model %s"), cpu->model);
goto error; goto error;
} }
if ((model = x86ModelCopy(model)) == NULL) if (!(model = x86ModelCopy(model)))
goto error; goto error;
} else if (!(model = x86ModelNew())) { } else if (!(model = x86ModelNew())) {
goto error; goto error;
...@@ -917,7 +917,7 @@ x86ModelFromCPU(const virCPUDef *cpu, ...@@ -917,7 +917,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
&& cpu->features[i].policy != policy) && cpu->features[i].policy != policy)
continue; continue;
if ((feature = x86FeatureFind(map, cpu->features[i].name)) == NULL) { if (!(feature = x86FeatureFind(map, cpu->features[i].name))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown CPU feature %s"), cpu->features[i].name); _("Unknown CPU feature %s"), cpu->features[i].name);
goto error; goto error;
...@@ -1030,25 +1030,25 @@ x86ModelLoad(xmlXPathContextPtr ctxt, ...@@ -1030,25 +1030,25 @@ x86ModelLoad(xmlXPathContextPtr ctxt,
goto error; goto error;
model->name = virXPathString("string(@name)", ctxt); model->name = virXPathString("string(@name)", ctxt);
if (model->name == NULL) { if (!model->name) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing CPU model name")); "%s", _("Missing CPU model name"));
goto ignore; goto ignore;
} }
if (virXPathNode("./model", ctxt) != NULL) { if (virXPathNode("./model", ctxt)) {
virCPUx86ModelPtr ancestor; virCPUx86ModelPtr ancestor;
char *name; char *name;
name = virXPathString("string(./model/@name)", ctxt); name = virXPathString("string(./model/@name)", ctxt);
if (name == NULL) { if (!name) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing ancestor's name in CPU model %s"), _("Missing ancestor's name in CPU model %s"),
model->name); model->name);
goto ignore; goto ignore;
} }
if ((ancestor = x86ModelFind(map, name)) == NULL) { if (!(ancestor = x86ModelFind(map, name))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Ancestor model %s not found for CPU model %s"), _("Ancestor model %s not found for CPU model %s"),
name, model->name); name, model->name);
...@@ -1089,13 +1089,13 @@ x86ModelLoad(xmlXPathContextPtr ctxt, ...@@ -1089,13 +1089,13 @@ x86ModelLoad(xmlXPathContextPtr ctxt,
virCPUx86FeaturePtr feature; virCPUx86FeaturePtr feature;
char *name; char *name;
if ((name = virXMLPropString(nodes[i], "name")) == NULL) { if (!(name = virXMLPropString(nodes[i], "name"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing feature name for CPU model %s"), model->name); _("Missing feature name for CPU model %s"), model->name);
goto ignore; goto ignore;
} }
if ((feature = x86FeatureFind(map, name)) == NULL) { if (!(feature = x86FeatureFind(map, name))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Feature %s required by CPU model %s not found"), _("Feature %s required by CPU model %s not found"),
name, model->name); name, model->name);
...@@ -1108,7 +1108,7 @@ x86ModelLoad(xmlXPathContextPtr ctxt, ...@@ -1108,7 +1108,7 @@ x86ModelLoad(xmlXPathContextPtr ctxt,
goto error; goto error;
} }
if (map->models == NULL) { if (!map->models) {
map->models = model; map->models = model;
} else { } else {
model->next = map->models; model->next = map->models;
...@@ -1132,28 +1132,28 @@ x86ModelLoad(xmlXPathContextPtr ctxt, ...@@ -1132,28 +1132,28 @@ x86ModelLoad(xmlXPathContextPtr ctxt,
static void static void
x86MapFree(virCPUx86MapPtr map) x86MapFree(virCPUx86MapPtr map)
{ {
if (map == NULL) if (!map)
return; return;
while (map->features != NULL) { while (map->features) {
virCPUx86FeaturePtr feature = map->features; virCPUx86FeaturePtr feature = map->features;
map->features = feature->next; map->features = feature->next;
x86FeatureFree(feature); x86FeatureFree(feature);
} }
while (map->models != NULL) { while (map->models) {
virCPUx86ModelPtr model = map->models; virCPUx86ModelPtr model = map->models;
map->models = model->next; map->models = model->next;
x86ModelFree(model); x86ModelFree(model);
} }
while (map->vendors != NULL) { while (map->vendors) {
virCPUx86VendorPtr vendor = map->vendors; virCPUx86VendorPtr vendor = map->vendors;
map->vendors = vendor->next; map->vendors = vendor->next;
x86VendorFree(vendor); x86VendorFree(vendor);
} }
while (map->migrate_blockers != NULL) { while (map->migrate_blockers) {
virCPUx86FeaturePtr migrate_blocker = map->migrate_blockers; virCPUx86FeaturePtr migrate_blocker = map->migrate_blockers;
map->migrate_blockers = migrate_blocker->next; map->migrate_blockers = migrate_blocker->next;
x86FeatureFree(migrate_blocker); x86FeatureFree(migrate_blocker);
...@@ -1209,7 +1209,7 @@ x86MapLoadInternalFeatures(virCPUx86MapPtr map) ...@@ -1209,7 +1209,7 @@ x86MapLoadInternalFeatures(virCPUx86MapPtr map)
if (virCPUx86DataAddCPUID(feature->data, &x86_kvm_features[i].cpuid)) if (virCPUx86DataAddCPUID(feature->data, &x86_kvm_features[i].cpuid))
goto error; goto error;
if (map->features == NULL) { if (!map->features) {
map->features = feature; map->features = feature;
} else { } else {
feature->next = map->features; feature->next = map->features;
...@@ -1469,7 +1469,7 @@ x86Compute(virCPUDefPtr host, ...@@ -1469,7 +1469,7 @@ x86Compute(virCPUDefPtr host,
ret = VIR_CPU_COMPARE_IDENTICAL; ret = VIR_CPU_COMPARE_IDENTICAL;
if ((diff = x86ModelCopy(host_model)) == NULL) if (!(diff = x86ModelCopy(host_model)))
goto error; goto error;
x86DataSubtract(diff->data, cpu_optional->data); x86DataSubtract(diff->data, cpu_optional->data);
...@@ -1489,10 +1489,10 @@ x86Compute(virCPUDefPtr host, ...@@ -1489,10 +1489,10 @@ x86Compute(virCPUDefPtr host,
goto cleanup; goto cleanup;
} }
if (guest != NULL) { if (guest) {
virCPUx86Data *guestData; virCPUx86Data *guestData;
if ((guest_model = x86ModelCopy(host_model)) == NULL) if (!(guest_model = x86ModelCopy(host_model)))
goto error; goto error;
if (cpu->type == VIR_CPU_TYPE_GUEST if (cpu->type == VIR_CPU_TYPE_GUEST
...@@ -1671,7 +1671,7 @@ x86Decode(virCPUDefPtr cpu, ...@@ -1671,7 +1671,7 @@ x86Decode(virCPUDefPtr cpu,
} }
} }
if (cpuModel == NULL) { if (!cpuModel) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Cannot find suitable CPU model for given data")); "%s", _("Cannot find suitable CPU model for given data"));
goto cleanup; goto cleanup;
...@@ -1780,7 +1780,7 @@ x86Encode(virArch arch, ...@@ -1780,7 +1780,7 @@ x86Encode(virArch arch,
if (vendor) if (vendor)
*vendor = NULL; *vendor = NULL;
if ((map = virCPUx86GetMap()) == NULL) if (!(map = virCPUx86GetMap()))
goto error; goto error;
if (forced) { if (forced) {
...@@ -2243,7 +2243,7 @@ x86GetModels(char ***models) ...@@ -2243,7 +2243,7 @@ x86GetModels(char ***models)
goto error; goto error;
model = map->models; model = map->models;
while (model != NULL) { while (model) {
if (models) { if (models) {
if (VIR_STRDUP(name, model->name) < 0) if (VIR_STRDUP(name, model->name) < 0)
goto error; goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册