On 2/11/18 1:02 PM, Serhey Popovych wrote: > Initializing @inet_prefix using C initializers or memset() seems > inefficient and unnecessary: only small part of ->data[] field will be > used to store address corresponding to ->family. > > Instead initialize ->flags with zero and assume no other fields accessed > before checking corresponding bits in ->flags. For example special > helpers (e.g. is_addrtype_*()) can be used to ensure that @inet_prefix > contains valid ip or ipv6 address. > > Signed-off-by: Serhey Popovych <serhe.popov...@gmail.com> > --- > include/utils.h | 5 +++++ > ip/iplink_geneve.c | 2 +- > ip/iplink_vxlan.c | 7 ++++--- > 3 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/include/utils.h b/include/utils.h > index 4dc514d..ccbf353 100644 > --- a/include/utils.h > +++ b/include/utils.h > @@ -65,6 +65,11 @@ enum { > ADDRTYPE_INET_MULTI = ADDRTYPE_INET | ADDRTYPE_MULTI > }; > > +static inline void inet_prefix_reset_flags(inet_prefix *p) > +{ > + p->flags = 0; > +} > +
I think inet_prefix_reset is sufficient; flags is an implementation detail.