virSysinfoDefPtr
virSysinfoReadPPC(void)
{
- virSysinfoDefPtr ret = NULL;
- char *outbuf = NULL;
+ g_auto(virSysinfoDefPtr) ret = NULL;
+ g_autofree char *outbuf = NULL;
if (VIR_ALLOC(ret) < 0)
- goto no_memory;
+ return NULL;
if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), CPUINFO);
- goto no_memory;
+ return NULL;
}
ret->nprocessor = 0;
ret->processor = NULL;
if (virSysinfoParsePPCProcessor(outbuf, ret) < 0)
- goto no_memory;
+ return NULL;
if (virSysinfoParsePPCSystem(outbuf, &ret->system) < 0)
- goto no_memory;
-
- VIR_FREE(outbuf);
- return ret;
+ return NULL;
- no_memory:
- VIR_FREE(outbuf);
- virSysinfoDefFree(ret);
- return NULL;
+ return g_steal_pointer(&ret);
}
virSysinfoDefPtr
virSysinfoReadARM(void)
{
- virSysinfoDefPtr ret = NULL;
- char *outbuf = NULL;
+ g_auto(virSysinfoDefPtr) ret = NULL;
+ g_autofree char *outbuf = NULL;
/* Some ARM systems have DMI tables available. */
if ((ret = virSysinfoReadDMI())) {
if (!virSysinfoDefIsEmpty(ret))
- return ret;
+ return g_steal_pointer(&ret);
virSysinfoDefFree(ret);
}
virResetLastError();
if (VIR_ALLOC(ret) < 0)
- goto no_memory;
+ return NULL;
if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), CPUINFO);
- goto no_memory;
+ return NULL;
}
ret->nprocessor = 0;
ret->processor = NULL;
if (virSysinfoParseARMProcessor(outbuf, ret) < 0)
- goto no_memory;
+ return NULL;
if (virSysinfoParseARMSystem(outbuf, &ret->system) < 0)
- goto no_memory;
-
- VIR_FREE(outbuf);
- return ret;
+ return NULL;
- no_memory:
- VIR_FREE(outbuf);
- virSysinfoDefFree(ret);
- return NULL;
+ return g_steal_pointer(&ret);
}
static char *
virSysinfoDefPtr
virSysinfoReadS390(void)
{
- virSysinfoDefPtr ret = NULL;
- char *outbuf = NULL;
+ g_auto(virSysinfoDefPtr) ret = NULL;
+ g_autofree char *outbuf = NULL;
if (VIR_ALLOC(ret) < 0)
- goto no_memory;
+ return NULL;
/* Gather info from /proc/cpuinfo */
if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), CPUINFO);
- goto no_memory;
+ return NULL;
}
if (virSysinfoParseS390Processor(outbuf, ret) < 0)
- goto no_memory;
+ return NULL;
/* Free buffer before reading next file */
VIR_FREE(outbuf);
if (virFileReadAll(SYSINFO, 8192, &outbuf) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), SYSINFO);
- goto no_memory;
+ return NULL;
}
if (virSysinfoParseS390System(outbuf, &ret->system) < 0)
- goto no_memory;
-
- VIR_FREE(outbuf);
- return ret;
+ return NULL;
- no_memory:
- virSysinfoDefFree(ret);
- VIR_FREE(outbuf);
- return NULL;
+ return g_steal_pointer(&ret);
}
return 0;
while (*query) {
- char *name = NULL, *value = NULL;
+ g_autofree char *name = NULL;
+ g_autofree char *value = NULL;
/* Find the next separator, or end of the string. */
end = strchr(query, '&');
* and consistent with CGI.pm we assume value is "".
*/
name = xmlURIUnescapeString(query, end - query, NULL);
- if (!name) goto no_memory;
+ if (!name)
+ return -1;
} else if (eq+1 == end) {
/* Or if we have "name=" here (works around annoying
* problem when calling xmlURIUnescapeString with len = 0).
*/
name = xmlURIUnescapeString(query, eq - query, NULL);
- if (!name) goto no_memory;
+ if (!name)
+ return -1;
} else if (query == eq) {
/* If the '=' character is at the beginning then we have
* "=value" and consistent with CGI.pm we _ignore_ this.
/* Otherwise it's "name=value". */
name = xmlURIUnescapeString(query, eq - query, NULL);
if (!name)
- goto no_memory;
+ return -1;
value = xmlURIUnescapeString(eq+1, end - (eq+1), NULL);
- if (!value) {
- VIR_FREE(name);
- goto no_memory;
- }
+ if (!value)
+ return -1;
}
/* Append to the parameter set. */
- if (virURIParamAppend(uri, name, NULLSTR_EMPTY(value)) < 0) {
- VIR_FREE(name);
- VIR_FREE(value);
+ if (virURIParamAppend(uri, name, NULLSTR_EMPTY(value)) < 0)
return -1;
- }
- VIR_FREE(name);
- VIR_FREE(value);
next:
query = end;
}
return 0;
-
- no_memory:
- virReportOOMError();
- return -1;
}
/**