From 9effb9f15f4811a80169801b5d2938961424a7d4 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 13 Aug 2022 14:07:31 +0930 Subject: [PATCH] ubsan: undefined shift in sign_extend * libhppa.h (sign_extend): Avoid undefined behaviour. --- bfd/libhppa.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bfd/libhppa.h b/bfd/libhppa.h index 1de2d5c943b..ebaffe66abf 100644 --- a/bfd/libhppa.h +++ b/bfd/libhppa.h @@ -162,7 +162,7 @@ enum hppa_reloc_expr_type_alt static inline unsigned ATTRIBUTE_UNUSED sign_extend (unsigned x, unsigned len) { - unsigned signbit = (1 << (len - 1)); + unsigned signbit = (1u << (len - 1)); unsigned mask = (signbit << 1) - 1; return ((x & mask) ^ signbit) - signbit; } -- 2.30.2