qemu-ppc
[Top][All Lists]
Advanced

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

Re: [Qemu-ppc] [PATCH v1 08/11] pc-dimm: get_memory_region() will never


From: David Gibson
Subject: Re: [Qemu-ppc] [PATCH v1 08/11] pc-dimm: get_memory_region() will never return a NULL pointer
Date: Tue, 12 Jun 2018 11:12:34 +1000
User-agent: Mutt/1.10.0 (2018-05-17)

On Mon, Jun 11, 2018 at 02:16:52PM +0200, David Hildenbrand wrote:
> This is guaranteed by passing into host_memory_backend_get_memory() a
> value that is not NULL - which is what we always do.
> 
> Signed-off-by: David Hildenbrand <address@hidden>

Reviewed-by: David Gibson <address@hidden>

> ---
>  hw/mem/pc-dimm.c | 15 ++-------------
>  1 file changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index 7bb6ce509c..9a0da5d441 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -157,7 +157,6 @@ static void pc_dimm_get_size(Object *obj, Visitor *v, 
> const char *name,
>                               void *opaque, Error **errp)
>  {
>      uint64_t value;
> -    MemoryRegion *mr;
>      PCDIMMDevice *dimm = PC_DIMM(obj);
>      PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(obj);
>  
> @@ -167,11 +166,7 @@ static void pc_dimm_get_size(Object *obj, Visitor *v, 
> const char *name,
>          return;
>      }
>  
> -    mr = ddc->get_memory_region(dimm);
> -    if (!mr) {
> -        return;
> -    }
> -    value = memory_region_size(mr);
> +    value = memory_region_size(ddc->get_memory_region(dimm));
>  
>      visit_type_uint64(v, name, &value, errp);
>  }
> @@ -241,14 +236,8 @@ static uint64_t pc_dimm_md_get_region_size(const 
> MemoryDeviceState *md)
>      /* dropping const here is fine as we don't touch the memory region */
>      PCDIMMDevice *dimm = PC_DIMM(md);
>      const PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(md);
> -    MemoryRegion *mr;
> -
> -    mr = ddc->get_memory_region(dimm);
> -    if (!mr) {
> -        return 0;
> -    }
>  
> -    return memory_region_size(mr);
> +    return memory_region_size(ddc->get_memory_region(dimm));
>  }
>  
>  static void pc_dimm_md_fill_device_info(const MemoryDeviceState *md,

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

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