From 00cd00e64130694ff7b49456d4bc421a153b4e6d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 30 Sep 2018 05:34:30 -0400 Subject: [PATCH] Tweak HB_TAG and HB_UNTAG uint32_t was getting promoted to signed int, which is not what we wanted... Wow, clang has become good at generating warnings... ../../src/hb-common.h:349:29: warning: signed shift result (0xFF000000) sets the sign bit of the shift expression's type ('int') and becomes negative [-Wshift-sign-overflow] _HB_SCRIPT_MAX_VALUE = HB_TAG_MAX, /*< skip >*/ ^~~~~~~~~~ ../../src/hb-common.h:93:20: note: expanded from macro 'HB_TAG_MAX' define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff) ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/hb-common.h:89:57: note: expanded from macro 'HB_TAG' define HB_TAG(c1,c2,c3,c4) ((hb_tag_t)((((uint8_t)(c1))<<24)|(((uint8_t)(c2))<<16)|(((uint8_t)(c3))<<8)|((uint8_t)(c4)))) ~~~~~~~~~~~~~~~^ ~~ ../../src/hb-common.h:349:3: warning: ISO C restricts enumerator values to range of 'int' (4294967295 is too large) [-Wpedantic] _HB_SCRIPT_MAX_VALUE = HB_TAG_MAX, /*< skip >*/ ^ ~~~~~~~~~~ --- src/hb-common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hb-common.h b/src/hb-common.h index fdceff9dc..37bbb2b14 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -86,8 +86,8 @@ typedef union _hb_var_int_t { typedef uint32_t hb_tag_t; -#define HB_TAG(c1,c2,c3,c4) ((hb_tag_t)((((uint8_t)(c1))<<24)|(((uint8_t)(c2))<<16)|(((uint8_t)(c3))<<8)|((uint8_t)(c4)))) -#define HB_UNTAG(tag) ((uint8_t)((tag)>>24)), ((uint8_t)((tag)>>16)), ((uint8_t)((tag)>>8)), ((uint8_t)(tag)) +#define HB_TAG(c1,c2,c3,c4) ((hb_tag_t)((((uint32_t)(c1)&0xFF)<<24)|(((uint32_t)(c2)&0xFF)<<16)|(((uint32_t)(c3)&0xFF)<<8)|((uint32_t)(c4)&0xFF))) +#define HB_UNTAG(tag) (((tag)>>24)&0xFF), (((tag)>>16)&0xFF), (((tag)>>8)&0xFF), ((tag)&0xFF) #define HB_TAG_NONE HB_TAG(0,0,0,0) #define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff)