From: Sodagudi Prasad <psodagud@codeaurora.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>,
Michal Marek <mmarek@suse.com>,
Greg Hackmann <ghackmann@google.com>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: unused-variable warning is getting disabled with clang
Date: Thu, 07 Dec 2017 18:16:56 -0800 [thread overview]
Message-ID: <c871326fca27c1b8fd81f838a604c634@codeaurora.org> (raw)
In-Reply-To: <20171207062602.GA12561@kroah.com>
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.
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)
Please let me know if you have any concerns with this approach to
identify all unused local variables.
-Thanks, Prasad
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
Linux Foundation Collaborative Project
next prev parent reply other threads:[~2017-12-08 2:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-06 21:24 unused-variable warning is getting disabled with clang Sodagudi Prasad
2017-12-07 6:26 ` Greg Kroah-Hartman
2017-12-08 2:16 ` Sodagudi Prasad [this message]
2017-12-18 15:32 ` Masahiro Yamada
2018-01-27 0:59 ` [PATCH] kbuild: clang: Disable -Wunused-const-variable warnings Prasad Sodagudi
2018-01-28 16:22 ` Segher Boessenkool
2018-01-29 16:35 ` Sodagudi Prasad
2018-01-29 17:08 ` Prasad Sodagudi
2018-01-29 23:57 ` Segher Boessenkool
2018-02-02 16:01 ` Masahiro Yamada
2018-02-06 23:46 ` [PATCH] kbuild: clang: disable unused variable warnings only when constant Prasad Sodagudi
2018-02-07 0:22 ` Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c871326fca27c1b8fd81f838a604c634@codeaurora.org \
--to=psodagud@codeaurora.org \
--cc=ghackmann@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.com \
--cc=yamada.masahiro@socionext.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox