From patchwork Mon Sep 2 11:01:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 271886 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B45402C009F for ; Mon, 2 Sep 2013 21:15:17 +1000 (EST) Received: from localhost ([::1]:38746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGS6E-0006Dj-AN for incoming@patchwork.ozlabs.org; Mon, 02 Sep 2013 07:15:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGS2b-0000dO-9z for qemu-devel@nongnu.org; Mon, 02 Sep 2013 07:11:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VGS2V-00005q-BE for qemu-devel@nongnu.org; Mon, 02 Sep 2013 07:11:29 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:33220) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGS2V-0008Vh-1v; Mon, 02 Sep 2013 07:11:23 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 2C4BA40240; Mon, 2 Sep 2013 15:11:21 +0400 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.corpit.ru (Postfix) with SMTP id BAB64211; Mon, 2 Sep 2013 15:01:57 +0400 (MSK) Received: (nullmailer pid 14633 invoked by uid 1000); Mon, 02 Sep 2013 11:01:56 -0000 From: Michael Tokarev To: aliguori@us.ibm.com Date: Mon, 2 Sep 2013 15:01:25 +0400 Message-Id: <1378119695-14568-6-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1378119695-14568-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1378119695-14568-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Peter Maydell , Michael Tokarev , qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 05/15] slirp/arp_table.c: Avoid shifting into sign bit of signed integers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Maydell "0xf << 28" shifts right into the sign bit, since 0xf is a signed integer. Use the 'U' suffix to force an unsigned shift to avoid this undefined behaviour and a clang sanitizer warning. Signed-off-by: Peter Maydell Reviewed-by: Eric Blake Acked-by: Jan Kiszka Signed-off-by: Michael Tokarev --- slirp/arp_table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slirp/arp_table.c b/slirp/arp_table.c index bf698c1..ecdb0ba 100644 --- a/slirp/arp_table.c +++ b/slirp/arp_table.c @@ -38,7 +38,7 @@ void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN]) ethaddr[3], ethaddr[4], ethaddr[5])); /* Check 0.0.0.0/8 invalid source-only addresses */ - if ((ip_addr & htonl(~(0xf << 28))) == 0) { + if ((ip_addr & htonl(~(0xfU << 28))) == 0) { return; } @@ -74,7 +74,7 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr, DEBUG_ARG("ip = 0x%x", ip_addr); /* Check 0.0.0.0/8 invalid source-only addresses */ - assert((ip_addr & htonl(~(0xf << 28))) != 0); + assert((ip_addr & htonl(~(0xfU << 28))) != 0); /* If broadcast address */ if (ip_addr == 0xffffffff || ip_addr == broadcast_addr) {