linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/boot/KASLR: Fix unused variable warning
@ 2019-12-11 13:04 Zhenzhong Duan
  2019-12-14 12:58 ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Zhenzhong Duan @ 2019-12-11 13:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: tglx, mingo, bp, x86, fanc.fnst, ardb, dave.hansen, dan.j.williams

This patch fixes below warning by moving variable 'i':
arch/x86/boot/compressed/kaslr.c:698:6: warning: unused variable ‘i’
[-Wunused-variable]

Also use true/false instead of 1/0 for boolean return.

Fixes: 690eaa532057 ("x86/boot/KASLR: Limit KASLR to extract the
kernel in immovable memory only")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
---
 arch/x86/boot/compressed/kaslr.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index d7408af55738..fff24a55bfd5 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -695,7 +695,6 @@ static bool process_mem_region(struct mem_vector *region,
        unsigned long long minimum,
        unsigned long long image_size)
 {
- int i;
  /*
  * If no immovable memory found, or MEMORY_HOTREMOVE disabled,
  * use @region directly.
@@ -705,12 +704,13 @@ static bool process_mem_region(struct mem_vector *region,

  if (slot_area_index == MAX_SLOT_AREA) {
  debug_putstr("Aborted e820/efi memmap scan (slot_areas full)!\n");
- return 1;
+ return true;
  }
- return 0;
+ return false;
  }

 #if defined(CONFIG_MEMORY_HOTREMOVE) && defined(CONFIG_ACPI)
+ int i;
  /*
  * If immovable memory found, filter the intersection between
  * immovable memory and @region.
@@ -734,11 +734,11 @@ static bool process_mem_region(struct mem_vector *region,

  if (slot_area_index == MAX_SLOT_AREA) {
  debug_putstr("Aborted e820/efi memmap scan when walking immovable
regions(slot_areas full)!\n");
- return 1;
+ return true;
  }
  }
 #endif
- return 0;
+ return false;
 }

 #ifdef CONFIG_EFI
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/boot/KASLR: Fix unused variable warning
  2019-12-11 13:04 [PATCH] x86/boot/KASLR: Fix unused variable warning Zhenzhong Duan
@ 2019-12-14 12:58 ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2019-12-14 12:58 UTC (permalink / raw)
  To: Zhenzhong Duan
  Cc: linux-kernel, tglx, mingo, x86, fanc.fnst, ardb, dave.hansen,
	dan.j.williams

On Wed, Dec 11, 2019 at 09:04:17PM +0800, Zhenzhong Duan wrote:
> This patch fixes below warning by moving variable 'i':

Avoid having "This patch" or "This commit" in the commit message. It is
tautologically useless.

Also, do

$ git grep 'This patch' Documentation/process

for more details.

> arch/x86/boot/compressed/kaslr.c:698:6: warning: unused variable ‘i’
> [-Wunused-variable]

You could explain here why the warning fires...

> Also use true/false instead of 1/0 for boolean return.
> 
> Fixes: 690eaa532057 ("x86/boot/KASLR: Limit KASLR to extract the
> kernel in immovable memory only")
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
> ---
>  arch/x86/boot/compressed/kaslr.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)


WARNING: please, no spaces at the start of a line
#45: FILE: arch/x86/boot/compressed/kaslr.c:707:
+ return true;$

WARNING: please, no spaces at the start of a line
#48: FILE: arch/x86/boot/compressed/kaslr.c:709:
+ return false;$

WARNING: please, no spaces at the start of a line
#52: FILE: arch/x86/boot/compressed/kaslr.c:713:
+ int i;$

ERROR: patch seems to be corrupt (line wrapped?)
#60: FILE: arch/x86/boot/compressed/kaslr.c:736:
regions(slot_areas full)!\n");

WARNING: please, no spaces at the start of a line
#62: FILE: arch/x86/boot/compressed/kaslr.c:737:
+ return true;$

WARNING: please, no spaces at the start of a line
#67: FILE: arch/x86/boot/compressed/kaslr.c:741:
+ return false;$


$ test-apply.sh /tmp/zhenzhong.duan.01 
checking file arch/x86/boot/compressed/kaslr.c
patch: **** malformed patch at line 60: regions(slot_areas full)!\n");

I'd be very interested to know how you even managed to create such a
well, hm, "patch"?!

For the future, before you send a patch:

- use checkpatch on it
- send it to yourself and try applying it first

Thx.

-- 
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/boot/KASLR: Fix unused variable warning
  2020-01-10  9:43 Zhenzhong Duan
@ 2020-01-10  9:52 ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2020-01-10  9:52 UTC (permalink / raw)
  To: Zhenzhong Duan
  Cc: linux-kernel, x86, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	Dave Hansen, Rafael J. Wysocki

On Fri, Jan 10, 2020 at 05:43:04PM +0800, Zhenzhong Duan wrote:
> Local variable 'i' is referenced only when CONFIG_MEMORY_HOTREMOVE and
> CONFIG_ACPI are defined, but definition of variable 'i' is out of guard.
> If any of the two macros is undefined, below warning triggers during
> build with 'make EXTRA_CFLAGS=-Wall binrpm-pkg', fix it by moving 'i'
> in the guard.

Maybe I wasn't clear: save this patch for when it triggers in the normal
build, without additional build flags.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] x86/boot/KASLR: Fix unused variable warning
@ 2020-01-10  9:43 Zhenzhong Duan
  2020-01-10  9:52 ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Zhenzhong Duan @ 2020-01-10  9:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: x86, Zhenzhong Duan, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H. Peter Anvin, Dave Hansen, Rafael J. Wysocki

Local variable 'i' is referenced only when CONFIG_MEMORY_HOTREMOVE and
CONFIG_ACPI are defined, but definition of variable 'i' is out of guard.
If any of the two macros is undefined, below warning triggers during
build with 'make EXTRA_CFLAGS=-Wall binrpm-pkg', fix it by moving 'i'
in the guard.

arch/x86/boot/compressed/kaslr.c:698:6: warning: unused variable ‘i’ [-Wunused-variable]

Fixes: 690eaa532057 ("x86/boot/KASLR: Limit KASLR to extract the kernel in immovable memory only")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
---
v3: remove changes from 0/1 to false/true per Tglx
    add the command details about triggering build warning per Boris

v2: update description per Boris.

 arch/x86/boot/compressed/kaslr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index d7408af55738..62bc46684581 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -695,7 +695,6 @@ static bool process_mem_region(struct mem_vector *region,
 			       unsigned long long minimum,
 			       unsigned long long image_size)
 {
-	int i;
 	/*
 	 * If no immovable memory found, or MEMORY_HOTREMOVE disabled,
 	 * use @region directly.
@@ -711,6 +710,7 @@ static bool process_mem_region(struct mem_vector *region,
 	}
 
 #if defined(CONFIG_MEMORY_HOTREMOVE) && defined(CONFIG_ACPI)
+	int i;
 	/*
 	 * If immovable memory found, filter the intersection between
 	 * immovable memory and @region.
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-10  9:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 13:04 [PATCH] x86/boot/KASLR: Fix unused variable warning Zhenzhong Duan
2019-12-14 12:58 ` Borislav Petkov
2020-01-10  9:43 Zhenzhong Duan
2020-01-10  9:52 ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).