From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johannes Berg Subject: Re: [PATCH] netlink: add policy attribute range validation Date: Thu, 27 Sep 2018 10:51:37 +0200 Message-ID: <1538038297.14416.25.camel@sipsolutions.net> References: <20180926200630.23399-1-johannes@sipsolutions.net> <1537993066.28767.29.camel@sipsolutions.net> <1537994127.28767.39.camel@sipsolutions.net> <20180927071621.GF30601@unicorn.suse.cz> <1538035929.14416.21.camel@sipsolutions.net> <20180927084807.GG30601@unicorn.suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org To: Michal Kubecek Return-path: Received: from s3.sipsolutions.net ([144.76.43.62]:53052 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbeI0PJA (ORCPT ); Thu, 27 Sep 2018 11:09:00 -0400 In-Reply-To: <20180927084807.GG30601@unicorn.suse.cz> Sender: netdev-owner@vger.kernel.org List-ID: On Thu, 2018-09-27 at 10:48 +0200, Michal Kubecek wrote: > We could still use helper macros so this part could become > > DEFINE_NLA_U8_RANGE(retry_range, 1, 255); > > or > > DEFINE_NLA_RANGE(retry_range, u8, 1, 255); True. > > policy[] = { > > ... > > [NL80211_ATTR_WIPHY_RETRY_SHORT] = { > > .type = NLA_U8, > > .validation_data = &retry_range, > > }, > > ... > > }; > > And this could be also shortened using a macro. > > It would still be longer but not that much. Right. You'd still have to name it, and then we'd probably eventually want to share some common range definitions, but indeed it would work. > I didn't mean it as a serious objection, rather a note that the gain may > not be worth the additional complexity. Sure, and suggestions are very welcome. I was just trying to explain why I chose this direction, more than anything else. > But if you want to follow in the > direction you indicated later (in particular, allowing different > interpretations of validation_data for the same type), overloading does > indeed make more sense. I'm just working on the patches - give me a few more minutes. johannes