hw/arm: use g_autofree for filename in arm_load_dtb
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/4 hw/arm: use g_autofree for filename in arm_load_dtb
The function has quite a number of exit cases so lets try and clean things up with g_autofree. As the fdt hasn't be allocated yet we can return directly from the fail point.
Reviewed-by Richard Henderson <[email protected]>
Reviewed-by Manos Pitsidianakis <[email protected]>
Signed-off-by Alex Bennée <[email protected]>
--- hw/arm/boot.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
hw/arm/boot.c +3 -5
@@ -553,20 +553,18 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,Error *err =NULL ;if (binfo->dtb_filename) { -char *filename; - filename =qemu_find_file (QEMU_FILE_TYPE_DTB , binfo->dtb_filename); + g_autofree char *filename = qemu_find_file(QEMU_FILE_TYPE_DTB, + binfo->dtb_filename);if (!filename) {fprintf (stderr,"Couldn't open dtb file %s\n" , binfo->dtb_filename); - goto fail; +return -1 ; } fdt =load_device_tree (filename, &size);if (!fdt) {fprintf (stderr,"Couldn't open dtb file %s\n" , filename); -g_free (filename); goto fail; } -g_free (filename); }else { fdt = binfo->get_dtb (binfo, &size);if (!fdt) {
Signature · 1 line
2.47.2