[Mesa-dev] [PATCH shader-db 1/3] run: define extension_string within the specified scope

Eric Engestrom eric.engestrom at imgtec.com
Mon Aug 21 13:27:50 UTC 2017


On Monday, 2017-08-21 11:27:19 +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> The same declaration was being used for two distinct things - a short
> list of EGL and the core GL extensions.
> 
> In the former it is a const string, while the latter is a dynamically
> managed list of extensions.
> 
> Define the variables within the specific scope.
> 
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  run.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/run.c b/run.c
> index c001447..afc5ba0 100644
> --- a/run.c
> +++ b/run.c
> @@ -446,8 +446,8 @@ main(int argc, char **argv)
>              "EGL_KHR_create_context",
>              "EGL_KHR_surfaceless_context"
>      };
> -    char *extension_string = eglQueryString(egl_dpy, EGL_EXTENSIONS);
>      for (int i = 0; i < ARRAY_SIZE(egl_extension); i++) {
> +        const char *extension_string = eglQueryString(egl_dpy, EGL_EXTENSIONS);

Not sure moving the query inside the loop is a good idea. (it's
a relatively small loop, but still, on principle)

Keeping just the second hunk below already achieves what you want, but
with variable shadowing, which I'm not a fan of.
How about renaming the two `extension_string` variables throughout the
function to `{egl,gl}_extension_string` (on top on the 2nd hunk)?

>          if (strstr(extension_string, egl_extension[i]) == NULL) {
>              fprintf(stderr, "ERROR: Missing %s\n", egl_extension[i]);
>              ret = -1;
> @@ -484,6 +484,8 @@ main(int argc, char **argv)
>      if (core_ctx != EGL_NO_CONTEXT &&
>          eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, core_ctx)) {
>          int num_extensions;
> +        char *extension_string;
> +
>          glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
>  
>          size_t extension_string_size = num_extensions * 26;
> -- 
> 2.13.3
> 


More information about the mesa-dev mailing list