提交 33912cc0 编写于 作者: M Michal Privoznik

virCPUDefFormatBufFull: Use our general error handling pattern

Well, so far there are no variables to free, no cleanup work needed on
an error, so bare 'return -1;' after each error is just okay. But this
will change in a while.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 83c5467e
...@@ -434,6 +434,8 @@ virCPUDefFormatBufFull(virBufferPtr buf, ...@@ -434,6 +434,8 @@ virCPUDefFormatBufFull(virBufferPtr buf,
virDomainNumaPtr numa, virDomainNumaPtr numa,
bool updateCPU) bool updateCPU)
{ {
int ret = -1;
if (!def) if (!def)
return 0; return 0;
...@@ -445,7 +447,7 @@ virCPUDefFormatBufFull(virBufferPtr buf, ...@@ -445,7 +447,7 @@ virCPUDefFormatBufFull(virBufferPtr buf,
if (!(tmp = virCPUModeTypeToString(def->mode))) { if (!(tmp = virCPUModeTypeToString(def->mode))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected CPU mode %d"), def->mode); _("Unexpected CPU mode %d"), def->mode);
return -1; goto cleanup;
} }
virBufferAsprintf(buf, " mode='%s'", tmp); virBufferAsprintf(buf, " mode='%s'", tmp);
} }
...@@ -457,7 +459,7 @@ virCPUDefFormatBufFull(virBufferPtr buf, ...@@ -457,7 +459,7 @@ virCPUDefFormatBufFull(virBufferPtr buf,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected CPU match policy %d"), _("Unexpected CPU match policy %d"),
def->match); def->match);
return -1; goto cleanup;
} }
virBufferAsprintf(buf, " match='%s'", tmp); virBufferAsprintf(buf, " match='%s'", tmp);
} }
...@@ -469,15 +471,17 @@ virCPUDefFormatBufFull(virBufferPtr buf, ...@@ -469,15 +471,17 @@ virCPUDefFormatBufFull(virBufferPtr buf,
virBufferAsprintf(buf, "<arch>%s</arch>\n", virBufferAsprintf(buf, "<arch>%s</arch>\n",
virArchToString(def->arch)); virArchToString(def->arch));
if (virCPUDefFormatBuf(buf, def, updateCPU) < 0) if (virCPUDefFormatBuf(buf, def, updateCPU) < 0)
return -1; goto cleanup;
if (virDomainNumaDefCPUFormat(buf, numa) < 0) if (virDomainNumaDefCPUFormat(buf, numa) < 0)
return -1; goto cleanup;
virBufferAdjustIndent(buf, -2); virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</cpu>\n"); virBufferAddLit(buf, "</cpu>\n");
return 0; ret = 0;
cleanup:
return ret;
} }
int int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册