[Mesa-dev] [PATCH 3/4] mesa/main: fix gl_buffer_index enum comparison
Samuel Pitoiset
samuel.pitoiset at gmail.com
Wed May 31 08:10:53 UTC 2017
Would be nice to update read_buffer_enum_to_index() and
_ColorReadBufferIndex too.
On 05/30/2017 10:47 PM, Rob Herring wrote:
> For clang, enums are unsigned by default and gives the following warning:
>
> external/mesa3d/src/mesa/main/buffers.c:764:21: warning: comparison of constant -1 with expression of type 'gl_buffer_index' is always false [-Wtautological-constant-out-of-range-compare]
> if (srcBuffer == -1) {
> ~~~~~~~~~ ^ ~~
>
> Replace -1 with an enum value to fix this.
>
> Signed-off-by: Rob Herring <robh at kernel.org>
> ---
> src/mesa/main/buffers.c | 6 +++---
> src/mesa/main/mtypes.h | 3 ++-
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
> index 7d17ae92de23..c5846e85c21d 100644
> --- a/src/mesa/main/buffers.c
> +++ b/src/mesa/main/buffers.c
> @@ -752,16 +752,16 @@ read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
>
> if (buffer == GL_NONE) {
> /* This is legal--it means that no buffer should be bound for reading. */
> - srcBuffer = -1;
> + srcBuffer = BUFFER_NONE;
> }
> else {
> /* general case / window-system framebuffer */
> if (_mesa_is_gles3(ctx) && !is_legal_es3_readbuffer_enum(buffer))
> - srcBuffer = -1;
> + srcBuffer = BUFFER_NONE;
> else
> srcBuffer = read_buffer_enum_to_index(ctx, buffer);
>
> - if (srcBuffer == -1) {
> + if (srcBuffer == BUFFER_NONE) {
> _mesa_error(ctx, GL_INVALID_ENUM,
> "%s(invalid buffer %s)", caller,
> _mesa_enum_to_string(buffer));
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 29e4c67846a5..6b6937473054 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -144,7 +144,8 @@ typedef enum
> BUFFER_COLOR5,
> BUFFER_COLOR6,
> BUFFER_COLOR7,
> - BUFFER_COUNT
> + BUFFER_COUNT,
> + BUFFER_NONE = -1,
> } gl_buffer_index;
>
> /**
>
More information about the mesa-dev
mailing list