Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp454019pxj; Thu, 3 Jun 2021 10:38:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrvfcDIUKvASD1ByacCNiUGykqez4FW2nyyQ+XMcJX/gFldgmdqwYsFiJgAdsde1qs7rv0 X-Received: by 2002:a17:906:4f10:: with SMTP id t16mr439248eju.337.1622741914183; Thu, 03 Jun 2021 10:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622741914; cv=none; d=google.com; s=arc-20160816; b=AHEkY99WFuuUN+ySNeZW9CH7cREAObJS1EclKkPct7C7p7P1EbQooz0TkqBMSLZnJl eAA08UJlqGAdPhIk3Td9JXI+CaK/o7QyuYkE1xKKzQDibBlAFWxpcjqWcUU4tHmrg4c9 7onN6ZAypIy5YgxhzJwfmoOp5AyCC0P4s+mcD6ezHo9O3xfrXTsnI/Fd+BUKodf5aXQz GqPVkKt9Ixssbs9OMxHKyD9YC9BUEjkYE5GK+e5uHWylDpIE2tuA0fPrF2T1Lukce8ZU a839FL/cvxxzIT985hwCVBEt00fihxO5LpFgB8APV6NZNhLyj0SWFT02/oWc2q/bPloL fUcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9iI2u4zLx2PrgxUifpKo5pdKQYHV1Wz5V4RXAWrbCr0=; b=aNEt6Tf8veHW/gsq2Cz0PByWnAXEbsIIWIiXLDCR3GqwvhXwMB68F0F6esH+DPZl8N nxzfI+WmNdS5e1I5JF8TBDrLlDW1PvnMF3n7SiV4gSNe8U7vu6cemsS/Cs/P56TufgnR TWGhCFQ/5FWy69r3I6S84zhweXLpS0c55m2G/Mtsa7ISB5C5mr7Qlk7+qAXhjv58t8WR xW2Cj0OBtyV41c/nHQDyij7+k4tG0fBzJdys2cs8y846GpfedjMGKIR7NRRFQqSn6h/P Cr/+jYlFZWEmsRhScMEgE1XCFR31ceni+TL1AfUGo0sUfi1EuY8lhH4h9WlkLmwgVbTF 1aOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O0zvkdiE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f29si512312ejj.667.2021.06.03.10.38.09; Thu, 03 Jun 2021 10:38:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O0zvkdiE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230405AbhFCRgT (ORCPT + 99 others); Thu, 3 Jun 2021 13:36:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:32976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230083AbhFCRgR (ORCPT ); Thu, 3 Jun 2021 13:36:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D983613D2; Thu, 3 Jun 2021 17:34:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622741672; bh=nSPjwdgpt9if/5lEOJp4BlmsJ9DjmB1lCXvcoDoVfyU=; h=From:To:Cc:Subject:Date:From; b=O0zvkdiE7NeWEVFbnpiYdMoMI2W8SfgrcvU6S8fBqgYmrree2to0ak7AlefGJwSeO iKklKl7SPlvP9X6oWBbtxM4lpdsS2ej4UwmY3PCFejZXEKmqEb74Id/8vgPlp7wF44 k8KJ17XWB5uQlfRaGQywE0b8udUMqg3bNKwPzLFFsKmMAs94tBbsQe7Duv1ciXpacN dGeu4tARlMYYNf4dy4DRpJCS9P8yAriASsQZM3dx+W8igmTzKw7yJ27mv+0kQE4LLU miruxdTIvmeVqeGtDIwLhe40FpW/fqDSY6bUIcUXAKoKSqDz/6gfDBgDAXRGBFXWf5 kX4QNOaVsAOjQ== From: Nathan Chancellor To: Subash Abhinov Kasiviswanathan , Sean Tranchetti , "David S. Miller" , Jakub Kicinski Cc: Nick Desaulniers , Sharath Chandra Vurukala , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH net-next] net: ethernet: rmnet: Restructure if checks to avoid uninitialized warning Date: Thu, 3 Jun 2021 10:34:10 -0700 Message-Id: <20210603173410.310362-1-nathan@kernel.org> X-Mailer: git-send-email 2.32.0.rc3 MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clang warns that proto in rmnet_map_v5_checksum_uplink_packet() might be used uninitialized: drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:283:14: warning: variable 'proto' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] } else if (skb->protocol == htons(ETH_P_IPV6)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:295:36: note: uninitialized use occurs here check = rmnet_map_get_csum_field(proto, trans); ^~~~~ drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:283:10: note: remove the 'if' if its condition is always true } else if (skb->protocol == htons(ETH_P_IPV6)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:270:11: note: initialize the variable 'proto' to silence this warning u8 proto; ^ = '\0' 1 warning generated. This is technically a false positive because there is an if statement above this one that checks skb->protocol for not being either ETH_P_IP{,V6}. However, it is more obvious to sink that into the if statement as an else branch, which makes the code clearer and fixes the warning. At the same time, move the "IS_ENABLED(CONFIG_IPV6)" into the else if condition so that the else branch of the preprocessor conditional can be shared, since there is no build failure with CONFIG_IPV6 disabled. Fixes: b6e5d27e32ef ("net: ethernet: rmnet: Add support for MAPv5 egress packets") Link: https://github.com/ClangBuiltLinux/linux/issues/1390 Signed-off-by: Nathan Chancellor --- .../net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 6492ec5bdec4..cecf72be5102 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -269,27 +269,20 @@ static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb, void *trans; u8 proto; - if (skb->protocol != htons(ETH_P_IP) && - skb->protocol != htons(ETH_P_IPV6)) { - priv->stats.csum_err_invalid_ip_version++; - goto sw_csum; - } - if (skb->protocol == htons(ETH_P_IP)) { u16 ip_len = ((struct iphdr *)iph)->ihl * 4; proto = ((struct iphdr *)iph)->protocol; trans = iph + ip_len; - } else if (skb->protocol == htons(ETH_P_IPV6)) { -#if IS_ENABLED(CONFIG_IPV6) + } else if (IS_ENABLED(CONFIG_IPV6) && + skb->protocol == htons(ETH_P_IPV6)) { u16 ip_len = sizeof(struct ipv6hdr); proto = ((struct ipv6hdr *)iph)->nexthdr; trans = iph + ip_len; -#else + } else { priv->stats.csum_err_invalid_ip_version++; goto sw_csum; -#endif /* CONFIG_IPV6 */ } check = rmnet_map_get_csum_field(proto, trans); base-commit: 270d47dc1fc4756a0158778084a236bc83c156d2 -- 2.32.0.rc3