conf: Make full use of goto label

* virDomainDefParse: There is a goto label "no_memory", which
reports OOM error, and then fallthrough label "error". This
patch changes things like following:

    virReportOOMError();
    goto error;

into:

    goto no_memory;
This commit is contained in:
Osier Yang 2011-06-21 16:20:15 +08:00
parent 9a2ac25a63
commit a22dbe0d66
1 changed files with 7 additions and 14 deletions

View File

@ -5834,8 +5834,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
char *set = tmp; char *set = tmp;
def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN; def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) { if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) {
virReportOOMError(); goto no_memory;
goto error;
} }
if (virDomainCpuSetParse((const char **)&set, if (virDomainCpuSetParse((const char **)&set,
0, def->cpumask, 0, def->cpumask,
@ -5896,8 +5895,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
int nodemasklen = VIR_DOMAIN_CPUMASK_LEN; int nodemasklen = VIR_DOMAIN_CPUMASK_LEN;
if (VIR_ALLOC_N(def->numatune.memory.nodemask, nodemasklen) < 0) { if (VIR_ALLOC_N(def->numatune.memory.nodemask, nodemasklen) < 0) {
virReportOOMError(); goto no_memory;
goto error;
} }
/* "nodeset" leads same syntax with "cpuset". */ /* "nodeset" leads same syntax with "cpuset". */
@ -6012,8 +6010,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
if (def->os.bootloader) { if (def->os.bootloader) {
def->os.type = strdup("xen"); def->os.type = strdup("xen");
if (!def->os.type) { if (!def->os.type) {
virReportOOMError(); goto no_memory;
goto error;
} }
} else { } else {
virDomainReportError(VIR_ERR_OS_TYPE, virDomainReportError(VIR_ERR_OS_TYPE,
@ -6030,8 +6027,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
def->virtType == VIR_DOMAIN_VIRT_XEN) { def->virtType == VIR_DOMAIN_VIRT_XEN) {
VIR_FREE(def->os.type); VIR_FREE(def->os.type);
if (!(def->os.type = strdup("xen"))) { if (!(def->os.type = strdup("xen"))) {
virReportOOMError(); goto no_memory;
goto error;
} }
} }
@ -6058,8 +6054,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
goto error; goto error;
} }
if (!(def->os.arch = strdup(defaultArch))) { if (!(def->os.arch = strdup(defaultArch))) {
virReportOOMError(); goto no_memory;
goto error;
} }
} }
@ -6071,8 +6066,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
virDomainVirtTypeToString(def->virtType)); virDomainVirtTypeToString(def->virtType));
if (defaultMachine != NULL) { if (defaultMachine != NULL) {
if (!(def->os.machine = strdup(defaultMachine))) { if (!(def->os.machine = strdup(defaultMachine))) {
virReportOOMError(); goto no_memory;
goto error;
} }
} }
} }
@ -6405,8 +6399,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
virDomainInputDefPtr input; virDomainInputDefPtr input;
if (VIR_ALLOC(input) < 0) { if (VIR_ALLOC(input) < 0) {
virReportOOMError(); goto no_memory;
goto error;
} }
if (STREQ(def->os.type, "hvm")) { if (STREQ(def->os.type, "hvm")) {
input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;