From 32c900890e5d6e2d4f9fc9564ef171f96ecebf46 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 28 Sep 2019 00:49:32 +0200 Subject: [PATCH] Fix two ubsan warnings --- src/regint.h | 2 +- src/regparse.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/regint.h b/src/regint.h index fe4ee9b..1b58e02 100644 --- a/src/regint.h +++ b/src/regint.h @@ -385,7 +385,7 @@ typedef Bits* BitSetRef; } while (0) #define BS_ROOM(bs,pos) (bs)[pos / BITS_IN_ROOM] -#define BS_BIT(pos) (1 << (pos % BITS_IN_ROOM)) +#define BS_BIT(pos) (1u << (pos % BITS_IN_ROOM)) #define BITSET_AT(bs, pos) (BS_ROOM(bs,pos) & BS_BIT(pos)) #define BITSET_SET_BIT(bs, pos) BS_ROOM(bs,pos) |= BS_BIT(pos) diff --git a/src/regparse.c b/src/regparse.c index 49076d5..e506f84 100644 --- a/src/regparse.c +++ b/src/regparse.c @@ -467,14 +467,14 @@ static int str_end_hash(st_str_end_key* x) { UChar *p; - int val = 0; + unsigned val = 0; p = x->s; while (p < x->end) { - val = val * 997 + (int )*p++; + val = val * 997 + (unsigned )*p++; } - return val + (val >> 5); + return (int) (val + (val >> 5)); } extern hash_table_type* -- 2.50.0