[Mesa-dev] [PATCH] glx/glvnd: list the strcmp arguments in correct order

Eric Engestrom eric.engestrom at imgtec.com
Thu Sep 1 11:53:18 UTC 2016


On Thu, Sep 01, 2016 at 10:36:44AM +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> Currently, due to the inverse order, strcmp will produce negative result
> when the needle is towards the start of the haystack. Thus on the next
> iteration(s) we'll end up further towards the end and eventually fail to
> locate the entry.

Good catch!
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>

> 
> Cc: "12.0" <mesa-stable at lists.freedesktop.org>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  src/glx/glxglvnd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/glx/glxglvnd.c b/src/glx/glxglvnd.c
> index 962eda8..098304d 100644
> --- a/src/glx/glxglvnd.c
> +++ b/src/glx/glxglvnd.c
> @@ -24,8 +24,8 @@ static unsigned FindGLXFunction(const GLubyte *name)
>  
>      while (first <= last) {
>          int middle = (first + last) / 2;
> -        int comp = strcmp((const char *) name,
> -                          __glXDispatchTableStrings[middle]);
> +        int comp = strcmp(__glXDispatchTableStrings[middle],
> +                          (const char *) name);
>  
>          if (comp < 0)
>              first = middle + 1;
> -- 
> 2.9.0


More information about the mesa-dev mailing list