intel/tools: Fix intel_dev_info --hwconfig switch

Since a42a5bf87e, we've been closing the file descriptor immediately
after loading the devinfo struct.

intel_get_and_print_hwconfig_table() re-queries the hwconfig info from
the device to print out all the entries, so we need to leave the fd
open for this use. I moved the close() call to all paths which exit
the for loop's current iteration.

Ref: a42a5bf87e ("intel/devinfo: add an option to pick platform to print")
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29549>
This commit is contained in:
Jordan Justen
2024-06-05 02:04:50 -07:00
committed by Marge Bot
parent 2dba5d484b
commit e02c6663e9

View File

@@ -254,10 +254,11 @@ main(int argc, char *argv[])
continue;
bool success = intel_get_device_info_from_fd(fd, &devinfo, -1, -1);
close(fd);
if (!success)
if (!success) {
close(fd);
continue;
}
if (print_json) {
JSON_Value *json = intel_device_info_dump_json(&devinfo);
@@ -276,6 +277,7 @@ main(int argc, char *argv[])
printf("%s", pretty_string);
json_free_serialized_string(pretty_string);
json_value_free(json);
close(fd);
continue;
}
@@ -287,6 +289,8 @@ main(int argc, char *argv[])
intel_get_and_print_hwconfig_table(fd, &devinfo);
if (print_workarounds)
print_wa_info(&devinfo);
close(fd);
}
}