qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 3/7] integratorcp: convert control to memory API


From: Avi Kivity
Subject: Re: [Qemu-devel] [PATCH 3/7] integratorcp: convert control to memory API
Date: Tue, 18 Oct 2011 16:06:43 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20110927 Thunderbird/7.0

On 10/18/2011 01:44 PM, Peter Maydell wrote:
> 2011/10/17 Benoît Canet <address@hidden>:
> > -static void icp_control_init(uint32_t base)
> > +static void icp_control_init(target_phys_addr_t base)
> >  {
> > -    int iomemtype;
> > +    MemoryRegion *io;
> >
> > -    iomemtype = cpu_register_io_memory(icp_control_readfn,
> > -                                       icp_control_writefn, NULL,
> > -                                       DEVICE_NATIVE_ENDIAN);
> > -    cpu_register_physical_memory(base, 0x00800000, iomemtype);
> > +    io = (MemoryRegion *)g_malloc0(sizeof(MemoryRegion));
> > +    memory_region_init_io(io, &icp_control_ops, NULL,
> > +                          "control", 0x00800000);
> > +    memory_region_add_subregion(get_system_memory(), base, io);
> >     /* ??? Save/restore.  */
> >  }
>
> I didn't spot this the first time round, but this is wrong.
> We shouldn't be g_malloc0()ing the MemoryRegion -- it should
> be an element in some suitable device struct.
>
> I think the right thing to do here is probably first to do the
> (fairly trivial) conversion of the icp_control code to be a
> sysbus device, then do the memory region conversion on top of that.

It's not any less wrong than the original code, which also leaked
memory.  I'll merge it and let any further conversion take place on top.

(though g_malloc0() is better replaced by g_new()).

-- 
error compiling committee.c: too many arguments to function




reply via email to

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