x86: Fix unused variable 'hi'
Subsystems (3)
PATCH 1/1 x86: Fix unused variable 'hi'
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]
--- arch/x86/hyperv/hv_apic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/hyperv/hv_apic.c +2 -1
@@ -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 :
Signature · 1 line
2.17.1
Quoted 14 lines · Xu Yihang
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]Reported-by Hulk Robot <[email protected]>Signed-off-by Xu Yihang <[email protected]>--- arch/x86/hyperv/hv_apic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/hyperv/hv_apic.c +0
-0
arch/x86/hyperv/hv_apic.c static void hv_apic_icr_write(u32 low, u32 id) · line 62
Quoted 9 lines
arch/x86/hyperv/hv_apic.c +2
-1@@ -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 :
Why and under what config does this function trigger the warning?
Thanks,
Ingo
From: Ingo Molnar <[email protected]> Sent: Thursday, March 18, 2021 4:24 AM
Quoted 25 lines · Xu Yihang
Quoted 3 lines
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]
Quoted 19 lines
Reported-by Hulk Robot <[email protected]>Signed-off-by Xu Yihang <[email protected]>--- arch/x86/hyperv/hv_apic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/hyperv/hv_apic.c +2
-1@@ -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;
Quoted 8 lines
arch/x86/hyperv/hv_apic.c static void hv_apic_icr_write(u32 low, u32 id) · line 62
Quoted 2 lines
arch/x86/hyperv/hv_apic.c +0
-0switch (reg) {case APIC_EOI :Why and under what config does this function trigger the warning?
Thanks,
Ingo
The warning should trigger if CONFIG_HYPERV is "m" or "y", and W=1 is selected. The variable is indeed set but not used because only the low order 32 bits of the synthetic MSR are relevant, but rdmsr() returns both the low 32 and the high 32 bits.
Michael
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 x86: Fix unused variable 'hi'
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.
--- arch/x86/hyperv/hv_apic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/hyperv/hv_apic.c +2 -1
@@ -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 :
Signature · 1 line
2.17.1
Wei Liu
maintainerQuoted 11 lines · Xu Yihang
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_HYPERVenabled:
make allmodconfig ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu- make W=1arch/x86/hyperv/hv_apic.oARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu-
HV_X64_MSR_EOIstores on bit 31:0 andHV_X64_MSR_TPRstores in bit 7:0, which means higher 32 bits are not really used, therefore__maybe_unusedadded.Reported-by Hulk Robot <[email protected]>Signed-off-by Xu Yihang <[email protected]>
I slightly modified the commit message and queued it up for hyperv-next. Thanks.
Wei.
PATCH 1/1 x86: Fix unused variable 'hi'
In reply to Xu YihangFixes 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 potentially cast to void in order to silent this warning.
--- arch/x86/hyperv/hv_apic.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/hyperv/hv_apic.c +2 -0
@@ -60,9 +60,11 @@ static u32 hv_apic_read(u32 reg)switch (reg) {case APIC_EOI :rdmsr (HV_X64_MSR_EOI , reg_val, hi); + (void ) hi;return reg_val;case APIC_TASKPRI :rdmsr (HV_X64_MSR_TPR , reg_val, hi); + (void ) hi;return reg_val;default :
Signature · 1 line
2.17.1
Wei Liu
maintainerQuoted 21 lines · Xu Yihang
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_HYPERVenabled:
make allmodconfig ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu- make W=1arch/x86/hyperv/hv_apic.oARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu-
HV_X64_MSR_EOIstores on bit 31:0 andHV_X64_MSR_TPRstores in bit 7:0, which means higher 32 bits are not really used, therefore potentially cast to void in order to silent this warning.Reported-by Hulk Robot <[email protected]>Signed-off-by Xu Yihang <[email protected]>--- arch/x86/hyperv/hv_apic.c | 2 ++ 1 file changed, 2 insertions(+)arch/x86/hyperv/hv_apic.c +0
-0
arch/x86/hyperv/hv_apic.c static u32 hv_apic_read(u32 reg) · line 67
Quoted 8 lines
arch/x86/hyperv/hv_apic.c +2
-0@@ -60,9 +60,11 @@ static u32 hv_apic_read(u32 reg)switch (reg) {case APIC_EOI :rdmsr (HV_X64_MSR_EOI , reg_val, hi); + (void ) hi;return reg_val;case APIC_TASKPRI :rdmsr (HV_X64_MSR_TPR , reg_val, hi); + (void ) hi;
I would like to remove the space while committing this patch. There is no need for you to do anything.
Wei.
Quoted 6 lines
arch/x86/hyperv/hv_apic.c +0
-0return reg_val;default :Signature · 1 line
2.17.1
Quoted 17 lines · Wei Liu
Quoted 16 lines · Xu Yihang
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_HYPERVenabled:
make allmodconfig ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu- make W=1arch/x86/hyperv/hv_apic.oARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu-
HV_X64_MSR_EOIstores on bit 31:0 andHV_X64_MSR_TPRstores in bit 7:0, which means higher 32 bits are not really used, therefore potentially cast to void in order to silent this warning.Reported-by Hulk Robot <[email protected]>Signed-off-by Xu Yihang <[email protected]>--- arch/x86/hyperv/hv_apic.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 16 lines
arch/x86/hyperv/hv_apic.c static u32 hv_apic_read(u32 reg) · line 67
Quoted 13 lines
arch/x86/hyperv/hv_apic.c +2
-0@@ -60,9 +60,11 @@ static u32 hv_apic_read(u32 reg)switch (reg) {case APIC_EOI :rdmsr (HV_X64_MSR_EOI , reg_val, hi); + (void ) hi;return reg_val;case APIC_TASKPRI :rdmsr (HV_X64_MSR_TPR , reg_val, hi); + (void ) hi;I would like to remove the space while committing this patch. There is no need for you to do anything.
Applied to hyperv-next.