Mesa (master): tgsi/scan: add an assert for the size of the samplers_declared bitfield

Nicolai Hähnle nh at kemper.freedesktop.org
Thu Apr 7 18:16:58 UTC 2016


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

Author: Nicolai Hähnle <nicolai.haehnle at amd.com>
Date:   Thu Apr  7 12:19:56 2016 -0500

tgsi/scan: add an assert for the size of the samplers_declared bitfield

The literal 1 is a (signed) int, and shifting into the sign bit is undefined
in C, so change occurences of 1 to 1u.

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

---

 src/gallium/auxiliary/tgsi/tgsi_scan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index d90fb1d..c5ef168 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -464,7 +464,8 @@ scan_declaration(struct tgsi_shader_info *info,
             }
          }
       } else if (file == TGSI_FILE_SAMPLER) {
-         info->samplers_declared |= 1 << reg;
+         STATIC_ASSERT(sizeof(info->samplers_declared) * 8 >= PIPE_MAX_SAMPLERS);
+         info->samplers_declared |= 1u << reg;
       } else if (file == TGSI_FILE_SAMPLER_VIEW) {
          unsigned target = fulldecl->SamplerView.Resource;
          assert(target < TGSI_TEXTURE_UNKNOWN);




More information about the mesa-commit mailing list