Mesa (master): panfrost: Fix OOB array access compiler warning.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 28 23:02:36 UTC 2020


Module: Mesa
Branch: master
Commit: ecab580d48f150d798ee82ff943ba3c30b9d8a65
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ecab580d48f150d798ee82ff943ba3c30b9d8a65

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Aug 25 10:20:44 2020 -0700

panfrost: Fix OOB array access compiler warning.

-1 is used to select "choose the dest type", but we were dereffing src[-1]
anyway and the compiler is not a fan.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6462>

---

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

diff --git a/src/panfrost/bifrost/bir.c b/src/panfrost/bifrost/bir.c
index 3ca57f66f0e..61a5ffc2647 100644
--- a/src/panfrost/bifrost/bir.c
+++ b/src/panfrost/bifrost/bir.c
@@ -106,7 +106,7 @@ bi_get_component_count(bi_instruction *ins, signed src)
                 return (src <= 0) ? ins->vector_channels : 1;
         } else {
                 unsigned dest_bytes = nir_alu_type_get_type_size(ins->dest_type);
-                unsigned src_bytes = nir_alu_type_get_type_size(ins->src_types[src]);
+                unsigned src_bytes = nir_alu_type_get_type_size(ins->src_types[MAX2(src, 0)]);
 
                 /* If there's either f32 on either end, it's only a single
                  * component, etc. */



More information about the mesa-commit mailing list