intel/tools: Fix compilation with UBSan
authorDanylo Piliaiev <danylo.piliaiev@globallogic.com>
Tue, 10 Mar 2020 14:24:59 +0000 (16:24 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 10 Mar 2020 15:20:26 +0000 (15:20 +0000)
Compilation failed with several similar errors:

../src/intel/tools/aub_read.c:322:4: error: case label does not reduce to an integer constant
  322 |    case MAKE_HEADER(TYPE_AUB, OPCODE_AUB, SUBOPCODE_HEADER):

Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4132>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4132>

src/intel/tools/aub_read.c

index a98e2c381800aafd80586b6bcbcc3a64fdb5efe7..6196817e9ea7f631e79c4d2b00ddfe0ec5a34608 100644 (file)
@@ -39,7 +39,7 @@
 #define SUBOPCODE(dw)  (((dw) >> 16) & 0x7f)
 
 #define MAKE_HEADER(type, opcode, subopcode) \
-                   (((type) << 29) | ((opcode) << 23) | ((subopcode) << 16))
+                   ((((unsigned) (type)) << 29) | ((opcode) << 23) | ((subopcode) << 16))
 
 #define TYPE_AUB            0x7