hw/ppc/spapr_caps.c: use g_autofree in spapr_cap_get_string()
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20220228175004.8862-5-danielhb413@gmail.com> Signed-off-by: Cédric Le Goater <clg@kaod.org>
This commit is contained in:
parent
ea8464fa27
commit
bc940c46c9
@ -95,12 +95,12 @@ static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name,
|
||||
}
|
||||
|
||||
|
||||
static void spapr_cap_get_string(Object *obj, Visitor *v, const char *name,
|
||||
void *opaque, Error **errp)
|
||||
static void spapr_cap_get_string(Object *obj, Visitor *v, const char *name,
|
||||
void *opaque, Error **errp)
|
||||
{
|
||||
SpaprCapabilityInfo *cap = opaque;
|
||||
SpaprMachineState *spapr = SPAPR_MACHINE(obj);
|
||||
char *val = NULL;
|
||||
g_autofree char *val = NULL;
|
||||
uint8_t value = spapr_get_cap(spapr, cap->index);
|
||||
|
||||
if (value >= cap->possible->num) {
|
||||
@ -111,7 +111,6 @@ static void spapr_cap_get_string(Object *obj, Visitor *v, const char *name,
|
||||
val = g_strdup(cap->possible->vals[value]);
|
||||
|
||||
visit_type_str(v, name, &val, errp);
|
||||
g_free(val);
|
||||
}
|
||||
|
||||
static void spapr_cap_set_string(Object *obj, Visitor *v, const char *name,
|
||||
|
Loading…
Reference in New Issue
Block a user