Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5655795img; Wed, 27 Mar 2019 12:33:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGQg7qwtHQbm/1eB3kuTnbJugY5LsOe8m7OnYqca//U7Xm3LoeGEUwkbzkt/cSbnuDzF+h X-Received: by 2002:a17:902:b40a:: with SMTP id x10mr30595099plr.231.1553715208911; Wed, 27 Mar 2019 12:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553715208; cv=none; d=google.com; s=arc-20160816; b=vmrx2gbtDA2DHS6QVls/u/iu6FGk+8hFuIx58sLBWNmywWrxJ3YAFpLPG1244qTFy4 EW6dJHnm1gVtBdaINk67gBVxpHHifCWbzg1b/ak/+h3Ohm0V6V2XIZPbhR527iCCnQch mOOt0oBX01vxmAn5088Y/+Yq/h2W+45yAy+7ahoV2bFW8Bh6Bp/VxsT3sjkR5MtOZ0nH ZcJJwNj0fBMwV7FIDeGU78CHczJ9AENe/p3Fpm/3fIb6zjKetRjEvAJZCuiT88KUnr7b ty1iDeb2OZkLu6j5OPaSSUrYmZ1WrOLevhHgBZx8NgGsethklLRDm7ZRaBpwEs6SEVqP cJQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TM3alqmvoSPIkR9pB5ZYN15N7nACrRaT7FEetPhsNQs=; b=kmNEHnc1qSShEU7OtjzfIwcu1s0q7k1+8pBpN5jffqXiifmS/zvOuh3mDDyJs6ZYtt pI/aPQsnwH4CpvytEAwMMwAniAdc5NQikbDzv7IGt9zvYjO4owfjaAuglDfUknwStXMI vbWbNap/gmnZAxgut52dNfJXuiuRxBrA91P41tQhCLoTmFR3yASGPB5rvDXfnuwkBTnp gYZqe1cnE7gJx70DnY1rIm2vk+rQizsyjR7zQ9a9WkdtiFr/NojC6gvQ7MAyTWOHQP6M MEWG7CkzUj3winM3cVNdqf10/j9q+3nCyqIVEsygIZ13zqNipAjC966SFkiPw5IaCI3q QnMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o+e+UsKK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id p187si3527635pfp.89.2019.03.27.12.33.13; Wed, 27 Mar 2019 12:33:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o+e+UsKK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1731240AbfC0SCj (ORCPT + 99 others); Wed, 27 Mar 2019 14:02:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:42526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730973AbfC0SCh (ORCPT ); Wed, 27 Mar 2019 14:02:37 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 77B4721855; Wed, 27 Mar 2019 18:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709756; bh=mx7AU5o7JgyEMh48NL+uha0qBt9zCAhWs1GDDBiOTEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o+e+UsKKrsbRu7Wk+HIr+gqqRTbLenlU1B9clbN1gXNVeC1q336qaMnNXIXZACEQZ eLQwwm8n4Uhhq9+YigvFHGVs+az5E2Vnn4Qgt8DwhCSaUOc7NKcuHA7tACHTFTJdYk q27lGLqqv16nBnj1etq55Rw0vJTJd5zQPQLngly0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 022/262] net: stmmac: Avoid sometimes uninitialized Clang warnings Date: Wed, 27 Mar 2019 13:57:57 -0400 Message-Id: <20190327180158.10245-22-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Chancellor [ Upstream commit df103170854e87124ee7bdd2bca64b178e653f97 ] When building with -Wsometimes-uninitialized, Clang warns: drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:495:3: warning: variable 'ns' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:495:3: warning: variable 'ns' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:532:3: warning: variable 'ns' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:532:3: warning: variable 'ns' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:741:3: warning: variable 'sec_inc' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:741:3: warning: variable 'sec_inc' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] Clang is concerned with the use of stmmac_do_void_callback (which stmmac_get_timestamp and stmmac_config_sub_second_increment wrap), as it may fail to initialize these values if the if condition was ever false (meaning the callbacks don't exist). It's not wrong because the callbacks (get_timestamp and config_sub_second_increment respectively) are the ones that initialize the variables. While it's unlikely that the callbacks are ever going to disappear and make that condition false, we can easily avoid this warning by zero initialize the variables. Link: https://github.com/ClangBuiltLinux/linux/issues/384 Suggested-by: Nick Desaulniers Reviewed-by: Nick Desaulniers Signed-off-by: Nathan Chancellor Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 685d20472358..019ab99e65bb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -474,7 +474,7 @@ static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p, struct sk_buff *skb) { struct skb_shared_hwtstamps shhwtstamp; - u64 ns; + u64 ns = 0; if (!priv->hwts_tx_en) return; @@ -513,7 +513,7 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p, { struct skb_shared_hwtstamps *shhwtstamp = NULL; struct dma_desc *desc = p; - u64 ns; + u64 ns = 0; if (!priv->hwts_rx_en) return; @@ -558,8 +558,8 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) u32 snap_type_sel = 0; u32 ts_master_en = 0; u32 ts_event_en = 0; + u32 sec_inc = 0; u32 value = 0; - u32 sec_inc; bool xmac; xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac; -- 2.19.1