From patchwork Fri Mar 8 04:02:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 10844141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5C53922 for ; Fri, 8 Mar 2019 04:02:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC1E12E2B0 for ; Fri, 8 Mar 2019 04:02:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC8672E2DF; Fri, 8 Mar 2019 04:02:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4E08D2E2B0 for ; Fri, 8 Mar 2019 04:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JLehFUIYhDqAHiPt3EmzAyf1q1JFpt4DHgf9s8OXT4A=; b=p7eo/2AdZQAjSd Blnq3sxy5AWmfWHNoxh9vHp1GciqO72mUOOL5E4bFnskpnaBLpoPWSQDzYVRZVqYI6dkT4ZGeJcPI eURvCP+PKahzq1Dk9upVKhHM39GBsietnhLGulCLVtuF0pQYceWVki3CUcBFzSNAdI9EBUEZbObus YK9YvU0HOSF1FmbEHCw5VyKtHn7wXCzx6DEI6MPuytTdRk/iyi/H6+ui4HgTOL9DWeU/wssibaSLn L/oaSzI2nHw5N31zPQzVKPWjj7Va3QV6Jo9/X4chjylIMDByw54xUZc1E6KtHVPVVl3MUfTb0AYa0 OsXGx+NaTIAv14lWvKLQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h26il-0004Lc-Iw; Fri, 08 Mar 2019 04:02:55 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h26ii-0004LC-GO for linux-arm-kernel@lists.infradead.org; Fri, 08 Mar 2019 04:02:54 +0000 Received: by mail-ed1-x542.google.com with SMTP id b20so15283965edw.11 for ; Thu, 07 Mar 2019 20:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mSUWPDkLCMVP3WJ97ekDdUYsu5f2Sgo2jFY9E7ZYMaQ=; b=qc6yfexMtIIcmudMi7dXFk9Rbj7ISAqmEW2FTPhIWF9g2kMK13JK+VyYUsVoc7PsxL fTItgYtUv1YVo4uEyA/07pDfzVlghrms703ZMGU3ee7sgTugUmEN9Jk5Q3vcNw1Otwlc G0z9akZYVxgJ6y2sFrQETUImGtLE6CflvhIuS2EIffZaszGr11rviEXEXog6+uz89dzZ NOVJf0SQnMdsIeNhENPtzFnfSendWhLIElgiLJQCtVQ6UrMHUo3xO6gE/znw4y8tUnwK 5M2WJK5M8rzOIZYezSespJjDTw1O7YT6xAB4TdFbyLM82IbHbscxyqsT6TP31dkF0dfV BxTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mSUWPDkLCMVP3WJ97ekDdUYsu5f2Sgo2jFY9E7ZYMaQ=; b=gwdxgfR19D4L8cD8LRE9BNhwM2ojUOOcZEyxJ323HUP4Ds7+yejSMf/YAInINRdIcn JhiifZ2ottXUWw9tl1VlH1D8DES5JV2gCvWSa+wajQyk9SNqOfuuN0uotKsnM1EaYX29 Gr8AkX9kv2ivv3YJ68Xb+RKHQwx8zoAcOzbVh04y4Xm7356exJ3bV6bIF5YGRQzb9kEg IzK/iCDknrzc2tKgC45nCC6irf4nN6jp9+S8U8ugWgXqTNRTzCAtmG0Vddfmb/YIMKmD ffah6MIIUXLOdOaclKDamuH2AjnJrbJ17N+xadPIT0JrsdD2py8eZmsDS9+98APGHZov w0zA== X-Gm-Message-State: APjAAAVZd81jlFgMy2161kyzeXlOYuzkGnGVjoVRKDUNA8UkNsXVUepb aPXeEJmWXcNJAlT9RkzECE0= X-Google-Smtp-Source: APXvYqxirboss2GDcOk2fMGEMYjCv52n6JtNGRIrevzS0YeyOY9kIPA7Ftebb5nhGik6XLjBamrLKw== X-Received: by 2002:aa7:d444:: with SMTP id q4mr31591342edr.278.1552017769430; Thu, 07 Mar 2019 20:02:49 -0800 (PST) Received: from localhost.localdomain ([2a01:4f9:2a:1fae::2]) by smtp.gmail.com with ESMTPSA id x18sm1895395edd.4.2019.03.07.20.02.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 20:02:48 -0800 (PST) From: Nathan Chancellor To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" Subject: [PATCH] net: stmmac: Avoid one more sometimes uninitialized Clang warning Date: Thu, 7 Mar 2019 21:02:39 -0700 Message-Id: <20190308040239.9400-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190307162101.29204-1-natechancellor@gmail.com> References: <20190307162101.29204-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190307_200252_569072_41CB99DD X-CRM114-Status: GOOD ( 14.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Maxime Coquelin , Nathan Chancellor , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);