From patchwork Thu Mar 7 16:21:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 10843313 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 6E84714DE for ; Thu, 7 Mar 2019 16:21:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5615F2F632 for ; Thu, 7 Mar 2019 16:21:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A1DA2F60E; Thu, 7 Mar 2019 16:21:48 +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 D2AC32F60E for ; Thu, 7 Mar 2019 16:21:47 +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: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:In-Reply-To:References: List-Owner; bh=kIqOXX+OZWnFKTzdzEL16vXQws4pF4UmwnVFaGGzUQw=; b=j/KJyxTTFoNy4T FXx7cSdIunhF4yIL8NDbGCm9dZDLmTJc7c9MfZjH0fmTV+ATThkWiicXcXwMnlKsBBuPJIfadiWTN cNEHxEO0GE/XXGv361Nh569nXnsIz6BUOGKLN1SP8/eKC3D0A/8oiZISNkwRwc339/1gofidRs+dz 9GXg88xLv8EQT1SfAcE6iHUNf0REwWnUPddLtD9Kp4agSRRbxxWjyaLMRsBmmZz3FKvn6aRXXbR1a XwGHTeZhqPdbBKrR3+YVHlPccyMtELbz7pPIJGMcaeNMPZ2tzZIuY3wR1jOAthsEGzLM84f+HlQEy 5vgHayqrtX2iNhos381Q==; 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 1h1vmD-0008U1-Qf; Thu, 07 Mar 2019 16:21:45 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1vmA-0008Tc-UM for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2019 16:21:44 +0000 Received: by mail-ed1-x544.google.com with SMTP id f2so13946378edy.13 for ; Thu, 07 Mar 2019 08:21:42 -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:mime-version :content-transfer-encoding; bh=rlDTcfv3csepodlYrre4dFCFdorwXLXQR8bO/MmR6JY=; b=mMbYaryNXSzofJDG81JYpz85I0NQuIrYrxgUH1crYQSlJVTmcUEE/qX2jw5Evftlh2 s1DQVHvW601DjHoCTHEWa9r190MP6VMOcaN9OlgH/7W+wyIgkGvQa6yAHWI5v6R+xtb4 Fi5I1pWTOzIZ4j2UfHz7Vnhtl58Kq9xQGBCJvb6hHhwdZuPHYHztuULAVfVEkS2j6Po1 axjlMDw77Aq0n7bX7HMK3uMBhtAyUaAcseVUQwUkJiU6Lwq2Swy6fAu/tVQQbqTiuMzS 4GTmrdh68HiX+/VgWRITh+imLyqTkPDXu50OyVZz8t9uYQbWPDHa6yU0hSkKWSUIZ6NT LKFQ== 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:mime-version :content-transfer-encoding; bh=rlDTcfv3csepodlYrre4dFCFdorwXLXQR8bO/MmR6JY=; b=uLC/mDQc9EhiqQXOFVjSXjaBm0KiE5N99TJkRHQbhXDCxE5DnJV9BYjTuy//axa//1 sfkLwFlGzgKaiOKqQnDs3D8IJ3FdiTaPp34GQg3VVWDFFxaC795Tl6C3bH4XiDPvNTFw MOBoYomwc31a/OUiym3aNyNOtO/KrMthWtp/AApO5wAmbwcrkgmvj8/6S8b3hSaVssiZ 5q9dXAkPqST44Gy9KEejtbqzBUbQ96PtxMuBdRfkLLSnUTA8tswrdpG0BX563S08Dy/x kSIX/Xa/vHSOPfb4TW6JT5qggmGkVsF18GSZo73oOiT8nv4GaLD0JBQ9Ttg+knDGNKo6 fMSA== X-Gm-Message-State: APjAAAXfJ1y1EZSpJ8JaWjWAgP6DV8Cbi5iMYxJL9aoiEK2YpSTZVrNx gCmy8y22Y+Y9Sy0CljU9d64= X-Google-Smtp-Source: APXvYqx9nR8crH7gc55TOWqoBJNQmtLoywosInHY6XwbDFcXrkmNbcJ/e2Kx7vllre3vCBGX9HPYsQ== X-Received: by 2002:a17:906:7f88:: with SMTP id f8mr8539919ejr.108.1551975700631; Thu, 07 Mar 2019 08:21:40 -0800 (PST) Received: from localhost.localdomain ([2a01:4f9:2a:1fae::2]) by smtp.gmail.com with ESMTPSA id y45sm1413360edd.33.2019.03.07.08.21.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 08:21:39 -0800 (PST) From: Nathan Chancellor To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" Subject: [PATCH] net: stmmac: Avoid sometimes uninitialized Clang warnings Date: Thu, 7 Mar 2019 09:21:01 -0700 Message-Id: <20190307162101.29204-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.21.0 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_082142_979109_91E334F6 X-CRM114-Status: GOOD ( 13.54 ) 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_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 Signed-off-by: Nathan Chancellor --- 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 e2a13ec2e30b..001a45aed273 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -480,7 +480,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; @@ -519,7 +519,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; @@ -565,7 +565,7 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) u32 ts_master_en = 0; u32 ts_event_en = 0; u32 value = 0; - u32 sec_inc; + u32 sec_inc = 0; bool xmac; xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;