qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [Patch] linux-user/syscall.c - don't add GUEST_BASE to


From: Riku Voipio
Subject: Re: [Qemu-devel] [Patch] linux-user/syscall.c - don't add GUEST_BASE to NULL pointer
Date: Wed, 26 Aug 2009 16:40:43 +0300
User-agent: Mutt/1.5.18 (2008-05-17)

On Wed, Aug 26, 2009 at 01:37:48AM +0200, Jan-Simon Möller wrote:
> Thinking a bit more about this, I wonder if g2h(x) shouldn't itself always 
> return NULL on x = NULL ? 

I agree this seems like a a better idea than modifying the users of g2h.

> Something like:
> 
> Signed-off-by:  Jan-Simon Möller  <address@hidden>
> 
> diff --git a/cpu-all.h b/cpu-all.h
> index 1a6a812..631f678 100644
> --- a/cpu-all.h
> +++ b/cpu-all.h
> @@ -633,7 +633,7 @@ extern int have_guest_base;
>  #endif
> 
>  /* All direct uses of g2h and h2g need to go away for usermode softmmu.  */
> -#define g2h(x) ((void *)((unsigned long)(x) + GUEST_BASE))
> +#define g2h(x) ( !x ? NULL:((void *)((unsigned long)(x) + GUEST_BASE)))
>  #define h2g(x) ({ \
>      unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \
>      /* Check if given address fits target address space */ \
> 
> 
> I read the comment above, but before replacing it in user-mode (if possible), 
> we should fix it ;) .
> 
> 
> Best,
> Jan-Simon
> 
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]