[PATCH -next] x86: Fix unused variable 'hi'

Subsystems: the rest, x86 architecture (32-bit and 64-bit)

STALE1995d

2 messages, 2 authors, 2021-03-22 · open the first message on its own page

[PATCH -next] x86: Fix unused variable 'hi'

From: Xu Yihang <hidden>
Date: 2021-03-22 03:55:46

Fixes the following W=1 kernel build warning(s):
arch/x86/hyperv/hv_apic.c:58:15: warning: variable ‘hi’ set but not used [-Wunused-but-set-variable]

Compiled with CONFIG_HYPERV enabled:
make allmodconfig ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu-
make W=1 arch/x86/hyperv/hv_apic.o ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu-

HV_X64_MSR_EOI stores on bit 31:0 and HV_X64_MSR_TPR stores in bit 7:0, which means higher 32 bits are not really used, therefore __maybe_unused added.

Reported-by: Hulk Robot <redacted>
Signed-off-by: Xu Yihang <redacted>
---
 arch/x86/hyperv/hv_apic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
index 284e73661a18..c0b0a5774f31 100644
--- a/arch/x86/hyperv/hv_apic.c
+++ b/arch/x86/hyperv/hv_apic.c
@@ -55,7 +55,8 @@ static void hv_apic_icr_write(u32 low, u32 id)
 
 static u32 hv_apic_read(u32 reg)
 {
-	u32 reg_val, hi;
+	u32 hi __maybe_unused;
+	u32 reg_val;
 
 	switch (reg) {
 	case APIC_EOI:
-- 
2.17.1

Re: [PATCH -next] x86: Fix unused variable 'hi'

From: Wei Liu <wei.liu@kernel.org>
Date: 2021-03-22 11:03:25

On Mon, Mar 22, 2021 at 11:54:26AM +0800, Xu Yihang wrote:
Fixes the following W=1 kernel build warning(s):
arch/x86/hyperv/hv_apic.c:58:15: warning: variable ‘hi’ set but not used [-Wunused-but-set-variable]

Compiled with CONFIG_HYPERV enabled:
make allmodconfig ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu-
make W=1 arch/x86/hyperv/hv_apic.o ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu-

HV_X64_MSR_EOI stores on bit 31:0 and HV_X64_MSR_TPR stores in bit 7:0, which means higher 32 bits are not really used, therefore __maybe_unused added.

Reported-by: Hulk Robot <redacted>
Signed-off-by: Xu Yihang <redacted>
I slightly modified the commit message and queued it up for hyperv-next.
Thanks.

Wei.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help