From patchwork Fri Feb 24 12:45:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 13151234 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01B45C678DB for ; Fri, 24 Feb 2023 12:46:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbjBXMqB (ORCPT ); Fri, 24 Feb 2023 07:46:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjBXMqA (ORCPT ); Fri, 24 Feb 2023 07:46:00 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7415B42BED; Fri, 24 Feb 2023 04:45:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=Z1svfh4p8q2jZu1lBbyg+kHr3WJV+oeeQaEoeKU2KdU=; t=1677242759; x=1678452359; b=LIm1Aojy7V3UsMlXc3xTCJOZ7Ge0a2/0r2zjKofKsIfy4dV a8zqXBfdossww6j2WJivVn2JiTpxOfhN4+CtaR9RBF60BPj8uVAbWAx2FcrKUE/a48H4U5fAkCrjh czdhM8vs53vjBcJ3CA6vDg5wh6uALMrY+Ft9QR1+DpOKXM1dWmkB6GAn38JE2y813MVddG0mQ03YZ tPXet1CDe9H5XXIARGaX9gaTsK5jYz+UGJ+oC2P/v0YBSGPM6KvpQbkLFPA272jX9OdIuZQi7oFwm JVajjkOUdNup0fQitt8wV433iKXE5b8zLOvDT2WQfH98ItyJ1vlB2pOJy1EVCIYQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1pVXSX-004CAe-16; Fri, 24 Feb 2023 13:45:57 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: Johannes Berg Subject: [RFC PATCH 1/2] net: netlink: make full range policy macros nicer Date: Fri, 24 Feb 2023 13:45:52 +0100 Message-Id: <20230224134441.791ae90f2939.Ic85e4e5fac77de8dedfa97ee1ad749b8ff8eb7a3@changeid> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230224124553.94730-1-johannes@sipsolutions.net> References: <20230224124553.94730-1-johannes@sipsolutions.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg Since these macros are used for variable initializers there's really no way to have a non-constant pointer, so move the required & into the macros. Signed-off-by: Johannes Berg --- include/net/netlink.h | 4 ++-- net/ipv6/ioam6_iptunnel.c | 4 ++-- net/wireless/nl80211.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/netlink.h b/include/net/netlink.h index b12cd957abb4..52dedc8bfedd 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -415,13 +415,13 @@ struct nla_policy { #define NLA_POLICY_FULL_RANGE(tp, _range) { \ .type = NLA_ENSURE_UINT_OR_BINARY_TYPE(tp), \ .validation_type = NLA_VALIDATE_RANGE_PTR, \ - .range = _range, \ + .range = &(_range), \ } #define NLA_POLICY_FULL_RANGE_SIGNED(tp, _range) { \ .type = NLA_ENSURE_SINT_TYPE(tp), \ .validation_type = NLA_VALIDATE_RANGE_PTR, \ - .range_signed = _range, \ + .range_signed = &(_range), \ } #define NLA_POLICY_MIN(tp, _min) { \ diff --git a/net/ipv6/ioam6_iptunnel.c b/net/ipv6/ioam6_iptunnel.c index f6f5b83dd954..790a40e2497d 100644 --- a/net/ipv6/ioam6_iptunnel.c +++ b/net/ipv6/ioam6_iptunnel.c @@ -67,8 +67,8 @@ static struct ioam6_trace_hdr *ioam6_lwt_trace(struct lwtunnel_state *lwt) } static const struct nla_policy ioam6_iptunnel_policy[IOAM6_IPTUNNEL_MAX + 1] = { - [IOAM6_IPTUNNEL_FREQ_K] = NLA_POLICY_FULL_RANGE(NLA_U32, &freq_range), - [IOAM6_IPTUNNEL_FREQ_N] = NLA_POLICY_FULL_RANGE(NLA_U32, &freq_range), + [IOAM6_IPTUNNEL_FREQ_K] = NLA_POLICY_FULL_RANGE(NLA_U32, freq_range), + [IOAM6_IPTUNNEL_FREQ_N] = NLA_POLICY_FULL_RANGE(NLA_U32, freq_range), [IOAM6_IPTUNNEL_MODE] = NLA_POLICY_RANGE(NLA_U8, IOAM6_IPTUNNEL_MODE_MIN, IOAM6_IPTUNNEL_MODE_MAX), diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 1c3b9a305f42..fbea0e786b21 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -811,7 +811,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG }, [NL80211_ATTR_MAX_NUM_AKM_SUITES] = { .type = NLA_REJECT }, [NL80211_ATTR_PUNCT_BITMAP] = - NLA_POLICY_FULL_RANGE(NLA_U32, &nl80211_punct_bitmap_range), + NLA_POLICY_FULL_RANGE(NLA_U32, nl80211_punct_bitmap_range), }; /* policy for the key attributes */ From patchwork Fri Feb 24 12:45:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 13151233 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5062C6FA9E for ; Fri, 24 Feb 2023 12:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229876AbjBXMqC (ORCPT ); Fri, 24 Feb 2023 07:46:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjBXMqA (ORCPT ); Fri, 24 Feb 2023 07:46:00 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3DAD51920; Fri, 24 Feb 2023 04:45:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=SvGY+xsurTZFQAmamVEuOGjTjEUZA1Dfz6HddeW/2JI=; t=1677242759; x=1678452359; b=n+3Z7kHJ6qfVbWu//Ibqqs2CfR/AMdn5PG6cPkdLIjNFzhP YTUXXsY20kuCiXsu9EdRh+kgSCHnHV4W5Q8l2oFE0SU7MU3cBzk4/CnvOIRH69XvRViE/rDCv/4d4 vV7R6cO8vvKWV07UDiOmDX0dIVGxxl5k+Q+zFK0reqfbiZU7vkf5sDZXW+LHcxLgQwXG9yeZfGbTH 0BE7Xsgx3zLw5/qjB8Vz+r4lvp9OwDMr8uBgWzR6QL+a0rQky09ufDlgSb7jBZtV16bV43EwpLQYS IHoFhVp0FsEpMkS5kCIHscGQpG4IkXIN7p1sc2TQnCXMalFc8oScD0tfJmQd0EZA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1pVXSX-004CAe-2k; Fri, 24 Feb 2023 13:45:57 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: Johannes Berg Subject: [RFC PATCH 2/2] net: netlink: constify full range pointers Date: Fri, 24 Feb 2023 13:45:53 +0100 Message-Id: <20230224134441.10dbceb0bdf1.Iaac3edac4a32e0c69b6c5de0e8e986f61a619cab@changeid> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230224124553.94730-1-johannes@sipsolutions.net> References: <20230224124553.94730-1-johannes@sipsolutions.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg These pointers (and with them variables they point to) really can be const, do that. Signed-off-by: Johannes Berg --- include/net/netlink.h | 4 ++-- net/ipv6/ioam6_iptunnel.c | 2 +- net/wireless/nl80211.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/net/netlink.h b/include/net/netlink.h index 52dedc8bfedd..6a4d6aae76bd 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -351,8 +351,8 @@ struct nla_policy { const u32 mask; const char *reject_message; const struct nla_policy *nested_policy; - struct netlink_range_validation *range; - struct netlink_range_validation_signed *range_signed; + const struct netlink_range_validation *range; + const struct netlink_range_validation_signed *range_signed; struct { s16 min, max; }; diff --git a/net/ipv6/ioam6_iptunnel.c b/net/ipv6/ioam6_iptunnel.c index 790a40e2497d..dd464d915ab8 100644 --- a/net/ipv6/ioam6_iptunnel.c +++ b/net/ipv6/ioam6_iptunnel.c @@ -46,7 +46,7 @@ struct ioam6_lwt { struct ioam6_lwt_encap tuninfo; }; -static struct netlink_range_validation freq_range = { +static const struct netlink_range_validation freq_range = { .min = IOAM6_IPTUNNEL_FREQ_MIN, .max = IOAM6_IPTUNNEL_FREQ_MAX, }; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index fbea0e786b21..ae35b23fac73 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -462,7 +462,7 @@ nl80211_sta_wme_policy[NL80211_STA_WME_MAX + 1] = { [NL80211_STA_WME_MAX_SP] = { .type = NLA_U8 }, }; -static struct netlink_range_validation nl80211_punct_bitmap_range = { +static const struct netlink_range_validation nl80211_punct_bitmap_range = { .min = 0, .max = 0xffff, };