Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5639947img; Wed, 27 Mar 2019 12:14:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCXDg27nlo2Cn/iabZtXARKAd8umtLmoMjlw6jM6W3vvtCU0fFqdbXzvP+GovDBgagF4r0 X-Received: by 2002:a17:902:b484:: with SMTP id y4mr31323778plr.88.1553714072805; Wed, 27 Mar 2019 12:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714072; cv=none; d=google.com; s=arc-20160816; b=Gnk8JvgiIf/TLqk1joFuc4HQYtdC7E9IQUva+4WFoY08iUEMV1pPk4dEmmP0rT5Vz8 CitUEpshxqaCRi+a9FI+Dc54wwi7b2bdpCkFkzSC/hIpJN0jYKhSio8LqyAr+s53Isxf LshNDW5yNI+XgyUl8p6Tpn2F0Ric4ogqO3+B/J0BHrptFtvdH4nLohYGJwCCwYy9/yKA rsIUnt2aZi0/44WsSJniQIR8VUvrM7B+fvJKYBclnGGKGsQ6IhmHgdYPQy0170FLIiS5 DXzxzXtpjr72bOZ+gq1qB1y7EWVTjEeIjfF2MY2d/SSrpZ0cKGwiyLfwqN88Z7amD7b8 W6nQ== 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=kF/KVFgaAP2MBVpVYm/wGd00rH/p8OSlV3SFVx+2Wlo=; b=ta6Te4MU/52dXXT0RpdapNOalWbOSN/YyyWS1hkFJWaiQ61vo3ImTVNjbwWxdcdWSe VNDAkzAUbB/TDm3fDDWrKCSB4t9lyoSE0UVi8Xq0CtHfM6OQCX3+rrzvBgic0/nfgNN2 5UI3PyMgxKIWbI9suUVUvqoZKU2NmxjiVoapCFwnIJiEdi+BGDaKIqkmhMmNGzur1Pg1 9t5qotYik/Vf3m1TSaCMcgz34DgHNLHRPgJAuE2ZZAFYhk6ZI4GRk8Y1iM2/q30RIW7V +KaUOjC2zvifAy1FiJmU071x4LNnwdN8bvmPJxSPxwEG6I6GnQ+bJ+SN2Xz8G14TLthu kqFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YqzsOHD9; 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 j34si3431656pgb.64.2019.03.27.12.14.17; Wed, 27 Mar 2019 12:14:32 -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=YqzsOHD9; 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 S2388803AbfC0SKZ (ORCPT + 99 others); Wed, 27 Mar 2019 14:10:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:52278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388779AbfC0SKR (ORCPT ); Wed, 27 Mar 2019 14:10:17 -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 9586721741; Wed, 27 Mar 2019 18:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710217; bh=7EH4dVlSDuD7rrHSEaMh/smm3ISlrRpdbt8Mqn3fxRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YqzsOHD9U93GumLvrCyMXv83DHV3EXf3FwtK73Mn91i9d+B4i17ddkrgbyG+IaOXx vFb6AsdKTqHSF5Ex2jHiDKqm3ok3wrCnbkVHBIrpP1fmT/tXYjYr7yTcid3rKNCrqS Dn8JK6qPTsbrSjcq+NDdwjYD9xZFaRF6BIAaL08g= 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 258/262] net: stmmac: Avoid one more sometimes uninitialized Clang warning Date: Wed, 27 Mar 2019 14:01:53 -0400 Message-Id: <20190327180158.10245-258-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 1f5d861f7fefa971b2c6e766f77932c86419a319 ] When building with -Wsometimes-uninitialized, Clang warns: drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c:111:2: error: variable 'ns' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c:111:2: error: variable 'ns' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized] Clang is concerned with the use of stmmac_do_void_callback (which stmmac_get_systime wraps), as it may fail to initialize these values if the if condition was ever false (meaning the callback doesn't exist). It's not wrong because the callback is what initializes ns. While it's unlikely that the callback is going to disappear at some point and make that condition false, we can easily avoid this warning by zero initializing the variable. Link: https://github.com/ClangBuiltLinux/linux/issues/384 Fixes: df103170854e ("net: stmmac: Avoid sometimes uninitialized Clang warnings") Suggested-by: Nick Desaulniers Signed-off-by: Nathan Chancellor Reviewed-by: Nick Desaulniers Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c index 2293e21f789f..cc60b3fb0892 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -105,7 +105,7 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts) struct stmmac_priv *priv = container_of(ptp, struct stmmac_priv, ptp_clock_ops); unsigned long flags; - u64 ns; + u64 ns = 0; spin_lock_irqsave(&priv->ptp_lock, flags); stmmac_get_systime(priv, priv->ptpaddr, &ns); -- 2.19.1