From patchwork Fri Dec 8 02:16:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Sodagudi X-Patchwork-Id: 10101497 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8D81660329 for ; Fri, 8 Dec 2017 02:16:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 708AA28852 for ; Fri, 8 Dec 2017 02:16:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64EFC289DD; Fri, 8 Dec 2017 02:16:59 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF90328852 for ; Fri, 8 Dec 2017 02:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751958AbdLHCQ6 (ORCPT ); Thu, 7 Dec 2017 21:16:58 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:34452 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751904AbdLHCQ5 (ORCPT ); Thu, 7 Dec 2017 21:16:57 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id CABB7607EB; Fri, 8 Dec 2017 02:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1512699416; bh=KFAKO8Inqnilv1him09D0Zrd6QLN5Do4Aw6x2Z2F14U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aqnGT7sK6r727omlSi5tFeilgjEYSGq9jboYe0IZcgOx2/p6PPFsceHqgOEbBV1e9 pFnO+AMAV6qaIYZHyAq3/s8fvhjo/guJBaQWtX6ayfEKW33iay9jjX676ISY76CQgx BwoaxCMY/h0n0THHcPvSmCgahD1scT4snxMy42w4= Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 33D1060227; Fri, 8 Dec 2017 02:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1512699416; bh=KFAKO8Inqnilv1him09D0Zrd6QLN5Do4Aw6x2Z2F14U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aqnGT7sK6r727omlSi5tFeilgjEYSGq9jboYe0IZcgOx2/p6PPFsceHqgOEbBV1e9 pFnO+AMAV6qaIYZHyAq3/s8fvhjo/guJBaQWtX6ayfEKW33iay9jjX676ISY76CQgx BwoaxCMY/h0n0THHcPvSmCgahD1scT4snxMy42w4= MIME-Version: 1.0 Date: Thu, 07 Dec 2017 18:16:56 -0800 From: Sodagudi Prasad To: Greg Kroah-Hartman Cc: Masahiro Yamada , Michal Marek , Greg Hackmann , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: unused-variable warning is getting disabled with clang In-Reply-To: <20171207062602.GA12561@kroah.com> References: <56cef2a644acc458b9457e3147abc4c0@codeaurora.org> <20171207062602.GA12561@kroah.com> Message-ID: X-Sender: psodagud@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 2017-12-06 22:26, Greg Kroah-Hartman wrote: > On Wed, Dec 06, 2017 at 01:24:51PM -0800, Sodagudi Prasad wrote: >> >> Hi All, >> >> When kernel compiled with clang, following line is disabling the >> unused-variable warning. This is not the case with gcc. >> KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) >> >> Are there any specific reasons for disabling unused-variable with >> clang? > > Try it and see why it is disabled :) Hi Greg, When I have enabled -Wunused-variable warnings with clang, observed both -Wunused-variable and -Wunused-const-variable as expected. It looks that, -Wunused-const-variable warnings are disabled explicitly with GCC as well. commit - c9c6837d39311b0c - "kbuild: move -Wunused-const-variable to W=1 warning level" I could see following warnings along with couple of -Wunused-variables warnings with downstream code. arch/arm64/crypto/sha1-ce-glue.c:118:1: warning: unused variable 'cpu_feature_match_SHA1' [-Wunused-const-variable] include/linux/cpufeature.h:48:33: note: expanded from macro 'module_cpu_feature_match' arch/arm64/crypto/sha2-ce-glue.c:148:1: warning: unused variable 'cpu_feature_match_SHA2' [-Wunused-const-variable] arch/arm64/crypto/ghash-ce-glue.c:597:33: warning: unused variable 'ghash_cpu_feature' [-Wunused-const-variable] arch/arm64/crypto/aes-ce-cipher.c:280:1: warning: unused variable 'cpu_feature_match_AES' [-Wunused-const-variable] arch/arm64/crypto/aes-glue.c:674:1: warning: unused variable 'cpu_feature_match_AES' [-Wunused-const-variable] kernel/trace/ftrace.c:1092:27: warning: unused variable 'ftrace_swapper_pid' [-Wunused-const-variable] drivers/usb/host/ehci-platform.c:406:36: warning: unused variable 'ehci_acpi_match' [-Wunused-const-variable] drivers/usb/host/xhci-plat.c:416:36: warning: unused variable 'usb_xhci_acpi_match' [-Wunused-const-variable] So I have made following change and I will share patch for the same. Please let me know if you have any concerns with this approach to identify all unused local variables. -Thanks, Prasad diff --git a/Makefile b/Makefile index 4e6da2f..8a6c14e 100644 --- a/Makefile +++ b/Makefile @@ -711,7 +711,7 @@ endif KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) -meabi gnu KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) -KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) KBUILD_CFLAGS += $(call cc-disable-warning, gnu) KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)