From: Emma Anholt Date: Tue, 29 Nov 2022 00:28:21 +0000 (-0800) Subject: loader: Simplify the extension matching logic. X-Git-Tag: upstream/23.3.3~15966 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e864047f971d17aa11db406083dbc9eaf2cc5956;p=platform%2Fupstream%2Fmesa.git loader: Simplify the extension matching logic. Also, add debug logging for missing optional extensions. Reviewed-by: Adam Jackson Acked-by: Eric Engestrom Part-of: --- diff --git a/src/loader/loader.c b/src/loader/loader.c index e4c607e..5e27f84 100644 --- a/src/loader/loader.c +++ b/src/loader/loader.c @@ -609,24 +609,23 @@ loader_bind_extensions(void *data, const __DRIextension **extensions) { bool ret = true; - void *field; - - for (size_t i = 0; extensions[i]; i++) { - for (size_t j = 0; j < num_matches; j++) { - if (strcmp(extensions[i]->name, matches[j].name) == 0 && - extensions[i]->version >= matches[j].version) { - field = ((char *) data + matches[j].offset); - *(const __DRIextension **) field = extensions[i]; + + for (size_t j = 0; j < num_matches; j++) { + const struct dri_extension_match *match = &matches[j]; + const __DRIextension **field = (const __DRIextension **)((char *)data + matches[j].offset); + for (size_t i = 0; extensions[i]; i++) { + if (strcmp(extensions[i]->name, match->name) == 0 && + extensions[i]->version >= match->version) { + *field = extensions[i]; + break; } } - } - for (size_t j = 0; j < num_matches; j++) { - field = ((char *) data + matches[j].offset); - if ((*(const __DRIextension **) field == NULL) && !matches[j].optional) { - log_(_LOADER_FATAL, "did not find extension %s version %d\n", - matches[j].name, matches[j].version); - ret = false; + if (!*field) { + log_(match->optional ? _LOADER_DEBUG : _LOADER_FATAL, "did not find extension %s version %d\n", + match->name, match->version); + if (!match->optional) + ret = false; } }