From patchwork Mon Jul 31 10:21:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 795682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xLbKD1q1gz9s2s for ; Mon, 31 Jul 2017 20:29:04 +1000 (AEST) Received: from localhost ([::1]:58595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc7wc-0000RF-3l for incoming@patchwork.ozlabs.org; Mon, 31 Jul 2017 06:29:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc7ur-0007q8-2d for qemu-devel@nongnu.org; Mon, 31 Jul 2017 06:27:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dc7uo-0001zW-Dt for qemu-devel@nongnu.org; Mon, 31 Jul 2017 06:27:13 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:38213) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc7uo-0001ye-5V; Mon, 31 Jul 2017 06:27:10 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 6EC0242ABC; Mon, 31 Jul 2017 13:27:09 +0300 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.corpit.ru (Postfix) with SMTP id 535A3B81; Mon, 31 Jul 2017 13:21:45 +0300 (MSK) Received: (nullmailer pid 5563 invoked by uid 1000); Mon, 31 Jul 2017 10:21:45 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Mon, 31 Jul 2017 13:21:31 +0300 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 86.62.121.231 Subject: [Qemu-devel] [PULL 12/25] net/eth: fix incorrect check of iov_to_buf() return value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé So we have sizeof(struct in6_address) != sizeof(uintptr_t) and Clang > Coverity on this, see 4555ca6816c :) net/eth.c:426:30: warning: The code calls sizeof() on a pointer type. This can produce an unexpected result return bytes_read == sizeof(dst_addr); ^ ~~~~~~~~~~ net/eth.c:475:34: warning: The code calls sizeof() on a pointer type. This can produce an unexpected result return bytes_read == sizeof(src_addr); ^ ~~~~~~~~~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Dmitry Fleytman Signed-off-by: Michael Tokarev --- net/eth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/eth.c b/net/eth.c index 5b9ba26a56..ae5d881aae 100644 --- a/net/eth.c +++ b/net/eth.c @@ -423,7 +423,7 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags, rthdr_offset + sizeof(*ext_hdr), dst_addr, sizeof(*dst_addr)); - return bytes_read == sizeof(dst_addr); + return bytes_read == sizeof(*dst_addr); } return false; @@ -472,7 +472,7 @@ _eth_get_rss_ex_src_addr(const struct iovec *pkt, int pkt_frags, opt_offset + sizeof(opthdr), src_addr, sizeof(*src_addr)); - return bytes_read == sizeof(src_addr); + return bytes_read == sizeof(*src_addr); } opt_offset += optlen;