From patchwork Mon Dec 16 02:48:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerry Chu X-Patchwork-Id: 301443 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 485172C0084 for ; Mon, 16 Dec 2013 13:48:18 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752215Ab3LPCsO (ORCPT ); Sun, 15 Dec 2013 21:48:14 -0500 Received: from mail-oa0-f74.google.com ([209.85.219.74]:41655 "EHLO mail-oa0-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752210Ab3LPCsM (ORCPT ); Sun, 15 Dec 2013 21:48:12 -0500 Received: by mail-oa0-f74.google.com with SMTP id o6so843638oag.3 for ; Sun, 15 Dec 2013 18:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=SCBx3edG8QbZeMkpTNDk9BoB1AgkyUtCSMiDu3yDS5c=; b=B56DowQtYH8AAYuzAIST0mvA8uEPseZ/O2p9D/PSt2RUTszXc8IsUdKz7LBJMa8KD+ nNs5v+5Ly6g0oig0ednu7iMX0qs31Ut0GsCLGYkrlrfrVu3qixUnBciq9tyla6lGhZcD yYZArLbAu2WI5AlVUORTEXY/CiJGggyywX8Hc9mA6HO3qemvfvg9qDsuY168Tnke9yHX 2D925d0QAmtJ5r4p7UEiullWgDd8X759lz1YTsrAgBDnvE6N5D6cA05qosAmhhqhS3WN Xu9r+z3cAkHxsUf353+R7fy4AFR0M02grUwMabYnYSDyyc1EUFO26k/5BenzISvkFwFm 6ahg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=SCBx3edG8QbZeMkpTNDk9BoB1AgkyUtCSMiDu3yDS5c=; b=HjCYiK9LBu7BqcObF6MGQxH0S+T4awTYxIse8jjEWDY562Lw9d1MB6ojm2Wkw45rQX knSg3d5TFBVb3+FOw20m2ooCz5Vt17Rz6mQqfneqHWhxrjsUV/xF7YxQpKksdo2QbNvO KXrpBM5caoquwY51KbfsVz/AS4D3KS7yda4ms/CMxwzkN4h2b4lPE2z7evu/i38NTEbQ xrgPdALSMEWknBgHIFcHWal9EA/hg+xhAdwgUkoGkjvnbxmT7/GIlgKhrNSpdkHcB76O QzfcV19DRJqY1iW2WsTMRse8H8Cc5u0V6xdRfUBsWPZkskLQYGNvQTRMkfdMYLG8SFD0 saHQ== X-Gm-Message-State: ALoCoQklIDBcd1ShCBsEpJNh+qgw1vI5pubwxDmuxPM0HfuK8yRpnCOqvNv5zvDFMIIkyFGsZYpHh4qAuUOq+qxPKQ/iEAa5CRXjUH+l0BCVpFHymtzEvuZpygsS6IZKLkSc5PjImhAnxKLIKgweZhIDnHnFsrNPOPMSlrWEu5DK3Gn0Dm7izggoTYHMAb2M5tNVq7zwkEkNYdeA2z/KGdTmc4428KiTnQ== X-Received: by 10.50.79.201 with SMTP id l9mr5520065igx.4.1387162091946; Sun, 15 Dec 2013 18:48:11 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id o30si3118019yhn.1.2013.12.15.18.48.11 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 Dec 2013 18:48:11 -0800 (PST) Received: from taipei.mtv.corp.google.com (taipei.mtv.corp.google.com [172.17.130.75]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id B81365A40E5; Sun, 15 Dec 2013 18:48:11 -0800 (PST) Received: by taipei.mtv.corp.google.com (Postfix, from userid 19823) id 5E316A0DD2; Sun, 15 Dec 2013 18:48:11 -0800 (PST) From: "H.K. Jerry Chu" To: hannes@stressinduktion.org Cc: davem@davemloft.net, netdev@vger.kernel.org, Jerry Chu Subject: [PATCH net-next] net-ipv6: Fix alleged compiler warning in ipv6_exthdrs_len() Date: Sun, 15 Dec 2013 18:48:07 -0800 Message-Id: <1387162087-5072-1-git-send-email-hkchu@google.com> X-Mailer: git-send-email 1.8.5.1 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jerry Chu It was reported that Commit 299603e8370a93dd5d8e8d800f0dff1ce2c53d36 ("net-gro: Prepare GRO stack for the upcoming tunneling support") triggered a compiler warning in ipv6_exthdrs_len(): net/ipv6/ip6_offload.c: In function ‘ipv6_gro_complete’: net/ipv6/ip6_offload.c:178:24: warning: ‘optlen’ may be used uninitialized in this function [-Wmaybe-u opth = (void *)opth + optlen; ^ net/ipv6/ip6_offload.c:164:22: note: ‘optlen’ was declared here int len = 0, proto, optlen; ^ Note that there was no real bug here - optlen was never uninitialized before use. (Was the version of gcc I used smarter to not complain?) Reported-by: Hannes Frederic Sowa Signed-off-by: H.K. Jerry Chu --- net/ipv6/ip6_offload.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c index 08861f1..6fb4162 100644 --- a/net/ipv6/ip6_offload.c +++ b/net/ipv6/ip6_offload.c @@ -160,8 +160,8 @@ out: static int ipv6_exthdrs_len(struct ipv6hdr *iph, const struct net_offload **opps) { - struct ipv6_opt_hdr *opth = NULL; - int len = 0, optlen = 0, proto; + struct ipv6_opt_hdr *opth = (void *)iph; + int len = 0, proto, optlen = sizeof(*iph); proto = iph->nexthdr; for (;;) { @@ -172,12 +172,8 @@ static int ipv6_exthdrs_len(struct ipv6hdr *iph, if (!((*opps)->flags & INET6_PROTO_GSO_EXTHDR)) break; } - if (opth == NULL) { - opth = (void *)(iph+1); - } else { - optlen = ipv6_optlen(opth); - opth = (void *)opth + optlen; - } + opth = (void *)opth + optlen; + optlen = ipv6_optlen(opth); len += optlen; proto = opth->nexthdr; }