Re: [PATCH] x86/kaslr: remove useless code in mem_avoid_memmap

From: Qian Cai
Date: Thu Aug 22 2019 - 09:46:27 EST


On Thu, 2019-08-22 at 21:26 +0800, Baoquan He wrote:
> On 08/22/19 at 08:32am, Qian Cai wrote:
> > MAX_MEMMAP_REGIONS is a macro that equal to 4. "i" is static local
> > variable that default to 0. The comparison "i >= MAX_MEMMAP_REGIONS"
> > will always be false.
>
> Seems not true. mem_avoid_memmap() could be invoked many times if
> multiple memmap= added. It will carry the value accumulated from
> the past.

Ah, I am still a newbie in C after all those years. Sorry for the noise.

>
> >
> > Signed-off-by: Qian Cai <cai@xxxxxx>
> > ---
> > Âarch/x86/boot/compressed/kaslr.c | 3 ---
> > Â1 file changed, 3 deletions(-)
> >
> > diff --git a/arch/x86/boot/compressed/kaslr.c
> > b/arch/x86/boot/compressed/kaslr.c
> > index 2e53c056ba20..a4a5a88edb94 100644
> > --- a/arch/x86/boot/compressed/kaslr.c
> > +++ b/arch/x86/boot/compressed/kaslr.c
> > @@ -176,9 +176,6 @@ static void mem_avoid_memmap(char *str)
> > Â{
> > Â static int i;
> > Â
> > - if (i >= MAX_MEMMAP_REGIONS)
> > - return;
> > -
> > Â while (str && (i < MAX_MEMMAP_REGIONS)) {
> > Â int rc;
> > Â unsigned long long start, size;
> > --Â
> > 1.8.3.1
> >