----- Original Message -----
> Signed-off-by: Oleksandr Natalenko <[email protected]>
> ---
>  memory.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/memory.c b/memory.c
> index 9926199..abf3982 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -14467,7 +14467,7 @@ display_with_pre_and_post(void *bufptr, ulonglong
> addr, struct searchinfo *si)
>       }
>  
>       amount = ctx * t;
> -     addr_d = addr - amount < 0 ? 0 : addr - amount;
> +     addr_d = (long)addr - amount < 0 ? 0 : addr - amount;
>  
>       display_memory(addr_d, ctx, flag, memtype, NULL);
>  
> --

I didn't write this code, but I do take the responsibility for accepting the 
patch.

The code above is used by the "search" command, where if it finds an instance 
of the
specified searched-for value, it will not only display the memory location 
where it exists,
but also the context around it.  The context is a "-x <count>" argument value 
passed to
the "search" command, which is multiplied by the word size specified.  I'm not 
sure
what the originator of this code meant by the "addr - amount < 0" 
qualification, 
because any kernel virtual address (other than s390x) would be perceived as a 
negative
number when preceded by "(long)".  So if your patch is applied, it would always 
be < 0,
set addr_d to 0, which gets ignored by display_memory(), and therefore it would 
never
show the context preceding the found entity as intended.
 
So again, you have found a coding irregularity, but your patch breaks what 
works just fine.

Probably it should just set addr_d = addr - amount, but that's what the code 
effectively
does now (by mistake), so I'm just going to leave this alone.

Dave

--
Crash-utility mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/crash-utility

Reply via email to