tgsi/scan: add an assert for the size of the samplers_declared bitfield
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 7 Apr 2016 17:19:56 +0000 (12:19 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 7 Apr 2016 18:15:05 +0000 (13:15 -0500)
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@vmware.com>
src/gallium/auxiliary/tgsi/tgsi_scan.c

index d90fb1d68df831066474fefccfd79c0c642312f4..c5ef16810a22f2637624190d261bf6736107eae4 100644 (file)
@@ -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);