intel/tools: handle some failures

Addresses "Dereference null return value" issues reported by Coverity.

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7449>
This commit is contained in:
Marcin Ślusarz 2020-11-04 18:23:31 +01:00 committed by Marge Bot
parent cd9907e7d3
commit f0061277c0

View file

@ -446,7 +446,12 @@ maybe_init(int fd)
initialized = true;
config = fopen(getenv("INTEL_DUMP_GPU_CONFIG"), "r");
const char *config_path = getenv("INTEL_DUMP_GPU_CONFIG");
fail_if(config_path == NULL, "INTEL_DUMP_GPU_CONFIG is not set\n");
config = fopen(config_path, "r");
fail_if(config == NULL, "failed to open file %s\n", config_path);
while (fscanf(config, "%m[^=]=%m[^\n]\n", &key, &value) != EOF) {
if (!strcmp(key, "verbose")) {
if (!strcmp(value, "1")) {