On 01/27/15 at 09:22am, Simon Horman wrote:
> Hi Ben, Hi Thomas,
> 
> On Mon, Jan 26, 2015 at 11:19:53AM -0800, Ben Pfaff wrote:
> > On Mon, Jan 26, 2015 at 02:44:07PM +0100, Thomas Graf wrote:
> > > list_moved() not handling the list_empty() case is somewhat rude.
> > > Why not just handle that special case and call list_init() in
> > > list_moved() instead? I realize it's currently documented to fail in
> > > list_moved() but I don't see any side effect in handling this properly
> > > because any caller doing so right now would be buggy.
> > 
> > I'd prefer to handle that case in list_moved() but I don't know a safe
> > way to detect it, that is, a way that doesn't try to read from
> > possibly freed memory.
> 
> Likewise.
> 
> I had an idea to detect it using something like this, but
> it breaks list_is_short() and moreover changes the scheme
> of empty lists.

The only really clean solution I could come up with is to replace the
realloc() with an explicit alloc() + memcpy() + free() and do a
list_move() before the free. That would allow to get rid of list_moved()
completely.

Not really better than what Simon proposes though so I have no
objection to Simon's patch.

Acked-by: Thomas Graf <tg...@noironetworks.com>
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to