[Crash-utility] [PATCH RFC 02/14] memory: do not compare unsigned expression with negative value

Dave Anderson anderson at redhat.com
Mon Oct 30 18:50:59 UTC 2017



----- Original Message -----
> Signed-off-by: Oleksandr Natalenko <oleksandr at redhat.com>
> ---
>  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);
>  
> --
> 2.14.3
> 
> 


> > 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.
> 
> Would you, maybe, still prefer modifying it to addr_d = addr - amount
> anyway to avoid both compiler and code reviewer confusion in the future please?

OK fine, queued for crash-7.2.1:

  https://github.com/crash-utility/crash/commit/b2d1bba766118fddf43235f0bed483dff32ac6e0

Dave




More information about the Crash-utility mailing list