From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH iproute2-next v2 1/4] utils: Introduce and use inet_prefix_reset_flags() Date: Mon, 12 Feb 2018 13:08:13 -0700 Message-ID: <82f92e8f-3316-f15f-002e-81ff97857b1e@gmail.com> References: <1518379353-31995-1-git-send-email-serhe.popovych@gmail.com> <1518379353-31995-2-git-send-email-serhe.popovych@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Serhey Popovych , netdev@vger.kernel.org Return-path: Received: from mail-it0-f68.google.com ([209.85.214.68]:53975 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751202AbeBLUIQ (ORCPT ); Mon, 12 Feb 2018 15:08:16 -0500 Received: by mail-it0-f68.google.com with SMTP id i144so8216870ita.3 for ; Mon, 12 Feb 2018 12:08:16 -0800 (PST) In-Reply-To: <1518379353-31995-2-git-send-email-serhe.popovych@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: 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 > --- > 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.