From 107eff5176710f05a00f14a6058f54197bd59a10 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 23 Dec 2019 20:18:05 +0000 Subject: [PATCH] Fix undefined behavior: left-shifting into the sign bit. Reviewed by: dim, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D22898 --- sys/sys/_sigset.h | 2 +- sys/sys/bitset.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/sys/_sigset.h b/sys/sys/_sigset.h index 1b72c14f61ce..662fcc1e216c 100644 --- a/sys/sys/_sigset.h +++ b/sys/sys/_sigset.h @@ -47,7 +47,7 @@ #define _SIG_MAXSIG 128 #define _SIG_IDX(sig) ((sig) - 1) #define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5) -#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31)) +#define _SIG_BIT(sig) (1U << (_SIG_IDX(sig) & 31)) #define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0) typedef struct __sigset { diff --git a/sys/sys/bitset.h b/sys/sys/bitset.h index f45a1827a61d..9f9ec9ea791e 100644 --- a/sys/sys/bitset.h +++ b/sys/sys/bitset.h @@ -41,7 +41,7 @@ #define __constexpr_cond(expr) (__builtin_constant_p((expr)) && (expr)) #define __bitset_mask(_s, n) \ - (1L << (__constexpr_cond(__bitset_words((_s)) == 1) ? \ + (1UL << (__constexpr_cond(__bitset_words((_s)) == 1) ? \ (__size_t)(n) : ((n) % _BITSET_BITS))) #define __bitset_word(_s, n) \