pseries: Replace non-portable asprintf by g_strdup_printf
g_strdup_printf already handles OOM errors, so some error handling in QEMU code can be removed. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
b8e76b35d4
commit
4ecf8aa5a0
@ -328,14 +328,11 @@ static void *spapr_create_fdt_skel(const char *cpu_model,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&nodename, "%s@%x", modelname, index) < 0) {
|
nodename = g_strdup_printf("%s@%x", modelname, index);
|
||||||
fprintf(stderr, "Allocation failure\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
_FDT((fdt_begin_node(fdt, nodename)));
|
_FDT((fdt_begin_node(fdt, nodename)));
|
||||||
|
|
||||||
free(nodename);
|
g_free(nodename);
|
||||||
|
|
||||||
_FDT((fdt_property_cell(fdt, "reg", index)));
|
_FDT((fdt_property_cell(fdt, "reg", index)));
|
||||||
_FDT((fdt_property_string(fdt, "device_type", "cpu")));
|
_FDT((fdt_property_string(fdt, "device_type", "cpu")));
|
||||||
|
@ -80,9 +80,7 @@ static char *vio_format_dev_name(VIOsPAPRDevice *dev)
|
|||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
/* Device tree style name device@reg */
|
/* Device tree style name device@reg */
|
||||||
if (asprintf(&name, "%s@%x", pc->dt_name, dev->reg) < 0) {
|
name = g_strdup_printf("%s@%x", pc->dt_name, dev->reg);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -101,12 +99,8 @@ static int vio_make_devnode(VIOsPAPRDevice *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
dt_name = vio_format_dev_name(dev);
|
dt_name = vio_format_dev_name(dev);
|
||||||
if (!dt_name) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
node_off = fdt_add_subnode(fdt, vdevice_off, dt_name);
|
node_off = fdt_add_subnode(fdt, vdevice_off, dt_name);
|
||||||
free(dt_name);
|
g_free(dt_name);
|
||||||
if (node_off < 0) {
|
if (node_off < 0) {
|
||||||
return node_off;
|
return node_off;
|
||||||
}
|
}
|
||||||
@ -444,9 +438,6 @@ static int spapr_vio_busdev_init(DeviceState *qdev)
|
|||||||
/* Don't overwrite ids assigned on the command line */
|
/* Don't overwrite ids assigned on the command line */
|
||||||
if (!dev->qdev.id) {
|
if (!dev->qdev.id) {
|
||||||
id = vio_format_dev_name(dev);
|
id = vio_format_dev_name(dev);
|
||||||
if (!id) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
dev->qdev.id = id;
|
dev->qdev.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,20 +637,12 @@ int spapr_populate_chosen_stdout(void *fdt, VIOsPAPRBus *bus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
name = vio_format_dev_name(dev);
|
name = vio_format_dev_name(dev);
|
||||||
if (!name) {
|
path = g_strdup_printf("/vdevice/%s", name);
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (asprintf(&path, "/vdevice/%s", name) < 0) {
|
|
||||||
path = NULL;
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = fdt_setprop_string(fdt, offset, "linux,stdout-path", path);
|
ret = fdt_setprop_string(fdt, offset, "linux,stdout-path", path);
|
||||||
out:
|
|
||||||
free(name);
|
g_free(name);
|
||||||
free(path);
|
g_free(path);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user