Mesa (main): panvk: cast negative value to unint8_t

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Dec 23 17:15:47 UTC 2021


Module: Mesa
Branch: main
Commit: 08f7d37fb97712e377f0b788be99bd10f899fa79
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=08f7d37fb97712e377f0b788be99bd10f899fa79

Author: Thomas H.P. Andersen <phomes at gmail.com>
Date:   Thu Dec 23 16:15:00 2021 +0100

panvk: cast negative value to unint8_t

The index is a uint8_t but can be assigned a negative 1
value in panvk_pipeline_builder_parse_color_blend()
The comparison to ~0 thus makes sense but clang will complain:

"result of comparison of constant -1 with expression of type
'const uint8_t' (aka 'const unsigned char') is always true
[-Wtautological-constant-out-of-range-compare]"

Fix this by casting to a uint8_t before comparison.

Fixes a warning with clang

Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14289>

---

 src/panfrost/vulkan/panvk_vX_cmd_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/panfrost/vulkan/panvk_vX_cmd_buffer.c b/src/panfrost/vulkan/panvk_vX_cmd_buffer.c
index a08f428a2ae..5eaf7e49cf7 100644
--- a/src/panfrost/vulkan/panvk_vX_cmd_buffer.c
+++ b/src/panfrost/vulkan/panvk_vX_cmd_buffer.c
@@ -468,7 +468,7 @@ panvk_draw_prepare_fs_rsd(struct panvk_cmd_buffer *cmdbuf,
 
       void *bd = rsd.cpu + pan_size(RENDERER_STATE);
       for (unsigned i = 0; i < pipeline->blend.state.rt_count; i++) {
-         if (pipeline->blend.constant[i].index != ~0) {
+         if (pipeline->blend.constant[i].index != (uint8_t)~0) {
             struct mali_blend_packed bd_dyn;
             struct mali_blend_packed *bd_templ =
                (struct mali_blend_packed *)&pipeline->blend.bd_template[i];



More information about the mesa-commit mailing list