From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVmej-0002b4-4Y for qemu-devel@nongnu.org; Wed, 11 Mar 2015 15:51:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVmed-0004xy-If for qemu-devel@nongnu.org; Wed, 11 Mar 2015 15:51:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36506) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVmed-0004xo-C9 for qemu-devel@nongnu.org; Wed, 11 Mar 2015 15:50:55 -0400 Date: Wed, 11 Mar 2015 20:50:49 +0100 From: "Michael S. Tsirkin" Message-ID: <20150311205049-mutt-send-email-mst@redhat.com> References: <1426096767-30494-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1426096767-30494-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 05/25] pci/shpc: fix signed integer overflow List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell clang undefined behaviour sanitizer reports: > hw/pci/shpc.c:162:27: runtime error: left shift of 1 by 31 places > cannot be represented in type 'int' Caused by the usual lack of a 'U' qualifier on a constant 1 being shifted left. Fix it up. Reported-by: Peter Maydell Signed-off-by: Michael S. Tsirkin --- hw/pci/shpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 5fd7f4b..759910f 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -159,7 +159,7 @@ static void shpc_interrupt_update(PCIDevice *d) for (slot = 0; slot < shpc->nslots; ++slot) { uint8_t event = shpc->config[SHPC_SLOT_EVENT_LATCH(slot)]; uint8_t disable = shpc->config[SHPC_SLOT_EVENT_SERR_INT_DIS(d, slot)]; - uint32_t mask = 1 << SHPC_IDX_TO_LOGICAL(slot); + uint32_t mask = 1U << SHPC_IDX_TO_LOGICAL(slot); if (event & ~disable) { int_locator |= mask; } -- MST