[Mesa-dev] [PATCH 4/9] mesa: delete tautological compare

Brian Paul brianp at vmware.com
Mon Apr 2 07:41:55 PDT 2012


On 04/01/2012 04:24 PM, nobled wrote:
> Noticed by clang:
>
> main/extensions.c:934:14: warning: comparison of unsigned
> expression<  0 is always false [-Wtautological-compare]
>     if (index<  0)
>         ~~~~~ ^ ~
>
> Also don't cast away const needlessly in this function.
> ---
>   src/mesa/main/extensions.c |    5 +----
>   1 files changed, 1 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
> index b02a49d..6354ad3 100644
> --- a/src/mesa/main/extensions.c
> +++ b/src/mesa/main/extensions.c
> @@ -931,14 +931,11 @@ _mesa_get_enabled_extension(struct gl_context
> *ctx, GLuint index)
>      size_t n;
>      const struct extension *i;
>
> -   if (index<  0)
> -      return NULL;
> -

It looks like this isn't needed on Mesa/master.  See commit 
b72d5767e3092016e0c2cfacaf38bb09d570955d


>      base = (GLboolean*)&ctx->Extensions;
>      n = 0;
>      for (i = extension_table; i->name != 0; ++i) {
>         if (n == index&&  base[i->offset]) {
> -	 return (GLubyte*) i->name;
> +	 return (const GLubyte*) i->name;
>         } else if (base[i->offset]) {
>   	 ++n;
>         }

That looks OK.

Reviewed-by: Brian Paul <brianp at vmware.com>

-Brian


More information about the mesa-dev mailing list