mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-31 00:45:18 +00:00
qemu: firmware: use g_new0
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
7195877348
commit
73f7b6a0ef
@ -301,8 +301,7 @@ qemuFirmwareInterfaceParse(const char *path,
|
|||||||
|
|
||||||
ninterfaces = virJSONValueArraySize(interfacesJSON);
|
ninterfaces = virJSONValueArraySize(interfacesJSON);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(interfaces, ninterfaces) < 0)
|
interfaces = g_new0(qemuFirmwareOSInterface, ninterfaces);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < ninterfaces; i++) {
|
for (i = 0; i < ninterfaces; i++) {
|
||||||
virJSONValuePtr item = virJSONValueArrayGet(interfacesJSON, i);
|
virJSONValuePtr item = virJSONValueArrayGet(interfacesJSON, i);
|
||||||
@ -504,8 +503,7 @@ qemuFirmwareTargetParse(const char *path,
|
|||||||
|
|
||||||
ntargets = virJSONValueArraySize(targetsJSON);
|
ntargets = virJSONValueArraySize(targetsJSON);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(targets, ntargets) < 0)
|
targets = g_new0(qemuFirmwareTargetPtr, ntargets);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < ntargets; i++) {
|
for (i = 0; i < ntargets; i++) {
|
||||||
virJSONValuePtr item = virJSONValueArrayGet(targetsJSON, i);
|
virJSONValuePtr item = virJSONValueArrayGet(targetsJSON, i);
|
||||||
@ -515,8 +513,7 @@ qemuFirmwareTargetParse(const char *path,
|
|||||||
size_t nmachines;
|
size_t nmachines;
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
if (VIR_ALLOC(t) < 0)
|
t = g_new0(qemuFirmwareTarget, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (!(architectureStr = virJSONValueObjectGetString(item, "architecture"))) {
|
if (!(architectureStr = virJSONValueObjectGetString(item, "architecture"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -541,8 +538,7 @@ qemuFirmwareTargetParse(const char *path,
|
|||||||
|
|
||||||
nmachines = virJSONValueArraySize(machines);
|
nmachines = virJSONValueArraySize(machines);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(t->machines, nmachines) < 0)
|
t->machines = g_new0(char *, nmachines);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
for (j = 0; j < nmachines; j++) {
|
for (j = 0; j < nmachines; j++) {
|
||||||
virJSONValuePtr machine = virJSONValueArrayGet(machines, j);
|
virJSONValuePtr machine = virJSONValueArrayGet(machines, j);
|
||||||
@ -588,8 +584,7 @@ qemuFirmwareFeatureParse(const char *path,
|
|||||||
|
|
||||||
nfeatures = virJSONValueArraySize(featuresJSON);
|
nfeatures = virJSONValueArraySize(featuresJSON);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(features, nfeatures) < 0)
|
features = g_new0(qemuFirmwareFeature, nfeatures);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < nfeatures; i++) {
|
for (i = 0; i < nfeatures; i++) {
|
||||||
virJSONValuePtr item = virJSONValueArrayGet(featuresJSON, i);
|
virJSONValuePtr item = virJSONValueArrayGet(featuresJSON, i);
|
||||||
@ -632,8 +627,7 @@ qemuFirmwareParse(const char *path)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(fw) < 0)
|
fw = g_new0(qemuFirmware, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (qemuFirmwareInterfaceParse(path, doc, fw) < 0)
|
if (qemuFirmwareInterfaceParse(path, doc, fw) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1050,9 +1044,8 @@ qemuFirmwareEnableFeatures(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
switch (fw->mapping.device) {
|
switch (fw->mapping.device) {
|
||||||
case QEMU_FIRMWARE_DEVICE_FLASH:
|
case QEMU_FIRMWARE_DEVICE_FLASH:
|
||||||
if (!def->os.loader &&
|
if (!def->os.loader)
|
||||||
VIR_ALLOC(def->os.loader) < 0)
|
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
|
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
|
||||||
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
|
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
|
||||||
@ -1093,9 +1086,8 @@ qemuFirmwareEnableFeatures(virQEMUDriverPtr driver,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case QEMU_FIRMWARE_DEVICE_MEMORY:
|
case QEMU_FIRMWARE_DEVICE_MEMORY:
|
||||||
if (!def->os.loader &&
|
if (!def->os.loader)
|
||||||
VIR_ALLOC(def->os.loader) < 0)
|
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_ROM;
|
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_ROM;
|
||||||
def->os.loader->path = g_strdup(memory->filename);
|
def->os.loader->path = g_strdup(memory->filename);
|
||||||
@ -1201,8 +1193,7 @@ qemuFirmwareFetchParsedConfigs(bool privileged,
|
|||||||
|
|
||||||
npaths = virStringListLength((const char **)paths);
|
npaths = virStringListLength((const char **)paths);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(firmwares, npaths) < 0)
|
firmwares = g_new0(qemuFirmwarePtr, npaths);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < npaths; i++) {
|
for (i = 0; i < npaths; i++) {
|
||||||
if (!(firmwares[i] = qemuFirmwareParse(paths[i])))
|
if (!(firmwares[i] = qemuFirmwareParse(paths[i])))
|
||||||
@ -1431,8 +1422,7 @@ qemuFirmwareGetSupported(const char *machine,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (j == *nfws) {
|
if (j == *nfws) {
|
||||||
if (VIR_ALLOC(tmp) < 0)
|
tmp = g_new0(virFirmware, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
tmp->name = g_strdup(fwpath);
|
tmp->name = g_strdup(fwpath);
|
||||||
tmp->nvram = g_strdup(nvrampath);
|
tmp->nvram = g_strdup(nvrampath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user