On Mon, Apr 06, 2015 at 03:24:27PM -0700, Justin Pettit wrote:
> 
> > On Apr 6, 2015, at 2:39 PM, Ben Pfaff <b...@nicira.com> wrote:
> > 
> > CC: Russell Bryant <rbry...@redhat.com>
> > Signed-off-by: Ben Pfaff <b...@nicira.com>
> > ---
> > lib/hmap.h |   12 +++++++++++-
> > 1 file changed, 11 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/hmap.h b/lib/hmap.h
> > index 85241f0..6215be6 100644
> > --- a/lib/hmap.h
> > +++ b/lib/hmap.h
> > @@ -1,5 +1,5 @@
> > /*
> > - * Copyright (c) 2008, 2009, 2010, 2012, 2013 Nicira, Inc.
> > + * Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015 Nicira, Inc.
> >  *
> >  * Licensed under the Apache License, Version 2.0 (the "License");
> >  * you may not use this file except in compliance with the License.
> > @@ -124,6 +124,16 @@ struct hmap_node *hmap_random_node(const struct hmap 
> > *);
> >  * iteration).
> >  *
> >  * HASH is only evaluated once.
> > + *
> > + *
> > + * Warning
> > + * -------
> > + *
> > + * When the loop terminates, &NODE->MEMBER will equal NULL.  Unless MEMBER 
> > is
> > + * the first member in its struct, this means that NODE itself will not be
> > + * NULL.
> > + *
> > + * (This is true for all of the HMAP_FOR_EACH_*() macros.)
> >  */
> > #define HMAP_FOR_EACH_WITH_HASH(NODE, MEMBER, HASH, HMAP)               \
> >     for (INIT_CONTAINER(NODE, hmap_first_with_hash(HMAP, HASH), MEMBER); \
> 
> Acked-by: Justin Pettit <jpet...@nicira.com>

Thanks, applied.

Another approach would be to make the macros assign NULL to their NODE
arguments before they exit.  I wonder whether making the behavior less
surprising is better than documenting the surprising behavior, in this
case.
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to