On Mon, Feb 8, 2016 at 4:52 PM, Ben Pfaff <[email protected]> wrote: > Some of our data structures derived from hmap use the same member names. > This means it's possible to confuse them in iteration, e.g. to iterate a > shash with SIMAP_FOR_EACH. Of course this will crash at runtime, but it > seems even better to catch it at compile time. > > An alternative would be to use unique member names, e.g. shash_map and > simap_map instead of just map. I like short names, though. > > It's kind of nasty that we need support from the hmap code to do this. > An alternative would be to insert the build assertions as statements before > the for loop. But that would cause nasty surprises if someone forgets the > {} around a block of statements; even though the OVS coding style requires > them in all cases, I suspect that programmers doing debugging, etc. tend > to omit them sometimes. > > It's not actually necessary to have multiple variants of these macros, > e.g. one can write a C99-compliant HMAP_FOR_EACH that accepts 3 or 4 or > more arguments. But such a macro is harder to read, so I don't know > whether this is a good tradeoff. > > Signed-off-by: Ben Pfaff <[email protected]> > > I find the the comments for *_INIT macro to be very helpful. Thanks.
Acked-by: Andy Zhou <[email protected]> _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
