[Mesa-dev] [PATCH 3/3] mesa: Fix tautological compare

Ian Romanick idr at freedesktop.org
Wed Feb 28 01:07:01 UTC 2018


From: Ian Romanick <ian.d.romanick at intel.com>

_BaseFormat is GLenum16, but it is compared with an integer -1.  Even if
_mesa_base_tex_format returned -1, it becomes 0xffff, and the
comparison, after type promotion, will always fail.  Fix this by
explicitly casting both to GLenum16.  This should be more future proof
that casting just the -1.

CID: 1429517
Fixes: ca721b3 ("mesa: use GLenum16 in a few more places")
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/main/teximage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 35ed875..1d7bff5 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -853,7 +853,7 @@ init_teximage_fields_ms(struct gl_context *ctx,
 
    target = img->TexObject->Target;
    img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat );
-   assert(img->_BaseFormat != -1);
+   assert((GLenum16) img->_BaseFormat != (GLenum16) -1);
    img->InternalFormat = internalFormat;
    img->Border = border;
    img->Width = width;
-- 
2.9.5



More information about the mesa-dev mailing list