From patchwork Wed Aug 9 10:50:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 133225 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2786977vqr; Wed, 9 Aug 2023 06:07:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEargub9hMzmNmZR+nBF2XFYIsSWf0J9xFYU0kTsiZOvawgFi3Sf2D201nwKxHO19XPQEP X-Received: by 2002:a17:90b:4a11:b0:268:5c3b:6f37 with SMTP id kk17-20020a17090b4a1100b002685c3b6f37mr2217570pjb.0.1691586445223; Wed, 09 Aug 2023 06:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691586445; cv=none; d=google.com; s=arc-20160816; b=B3vnpfgIj3oZbgrz43i3RC3aU5MbeSHxzIckVjvz/YH7ftBelhfCuoAXYZu9G4Mwyp BLlTCdC+v+Nis3R5tkrpafu5NdP+Ol6g8PsyoriAuv+3obHzeCt3ExVPioB+j9e21fES udXu0Fiz8fknzszFQyXdvUDW4o3juhYUkMESxBBvB7Ko1UZ5ffQTxT10QqhTMHWF6v17 XfB7Kv8TBqOFWoBdXcU9nf11B/jKOSP8QvUV19s0Ozd/FgdK1cBuJBGa6UhJJC6nXx28 eKrodrw42ahH+ktNRXoJdUhnVi8Ce73UW5ZhEEd5pkuo7S6BQdQDVq/S8Sid6s1WSHE0 r5yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5noSV5uL5R3dSrbr/R0oWH8ijMnn3jtlsPFspVagWKY=; fh=0C5K6FXquGp4XTbGptSGk2WjQCh2p2gH5XaTr5E3gqk=; b=WOZkJsQWZEM6qMzpiiCq3k/Xg92SRjzjHE6RBRIn8PmlU/9VKnWpmJZAmPeA1ZxkAF hEXqXd9M3i3Hau50c5v/m9+9L4yVUW/7wBvffTzcSuf32hVTq/xPUXAxSPMFYiMc384W 7EbQVX506g/TjMsy8FQYebA+gfBu18+VoTwFRvfZn++i1VTQpyhXaBNso7PZLE25SAUM u7qtrKn50kLupQdFhluCj5W2JxelYqg2hteeGt9AOerXZAbLpH6hwkDDTVZ313blo2db uj3HZQDnX25ecj9rhE+Y6PvCVIdqoOvIU6iQugnjp//Sh+NGhX46nMHzpij5k6GnLDId E69g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=TX8khL8g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p22-20020a17090adf9600b00263f3c1bb86si1343343pjv.158.2023.08.09.06.07.03; Wed, 09 Aug 2023 06:07:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=TX8khL8g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232381AbjHIKvh (ORCPT + 99 others); Wed, 9 Aug 2023 06:51:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232445AbjHIKui (ORCPT ); Wed, 9 Aug 2023 06:50:38 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD74D211E; Wed, 9 Aug 2023 03:50:36 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fe2048c910so56256365e9.1; Wed, 09 Aug 2023 03:50:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691578235; x=1692183035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5noSV5uL5R3dSrbr/R0oWH8ijMnn3jtlsPFspVagWKY=; b=TX8khL8g58MfSkvF/7dqspBoYmTEND8gsbbGwKCpvoBlJdYirB/frY3cUw6GS6+SHA DfP23JLSKjLvVDd6Y6bO3Tb3CU7DtRCNxdcPfv0/dLLVbTNS8nywKaCrcpghL3jSw/4i snyo098b2K+hvjhRkYb8awdmCwqLfG3x+L62mAtDznqfAw1ZGBiX+40XWVPAtoPCbf+g 5Uxrm9xdM62+Q4csDS5gX23DV8HPo+vs/icc4hZk57D3nosZ46zn9sbBNsd/FcUukcm+ j/MC/x/Wu8KlPCoks4UJfVZKxmwvH2daD4+6FjrR9xdEHKFru3ta1n2dBRsqqaqJ8IwC 5Z0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691578235; x=1692183035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5noSV5uL5R3dSrbr/R0oWH8ijMnn3jtlsPFspVagWKY=; b=VdbXJNsPh0qWGG6IrNtiQF4gKxOc4K/9/sMLGIir3e/YRnBB2eDHQbNtmJUikRV0jW oIxo88TnXQ5phXMm4l7HGhxGaLjMwjTPMk6qIJ5qOwuaS7fxGctg1QRt5nfDb2PZlJja a7nCTPdqwq/5Wo4UkXHTiXxR9NqBdbyIE1bvpjs+a0yx3+egYyZj1lCQkmZVddmwHY0K GTh8X7GYrjjUxZ9v3otXdQF63362tub0NbKErtIbhY0hIPFqh+tA55wmsNGEDtDw08FD xuIHgdlMU8TBL93+6eI/ga6VTfsA0HrRlYKqeNiHEZgBLhrg5XcY3h0YP9c2bOZbpVvw 1wcw== X-Gm-Message-State: AOJu0YxJ6gLp60J4Mc8Vd7GyWGZPA8V2E9Nf999QaJGMV8yCBVqugiYq OqyzJJCZMCDwrevYiV3qGY8= X-Received: by 2002:adf:d4c3:0:b0:314:2e95:1ec9 with SMTP id w3-20020adfd4c3000000b003142e951ec9mr1694402wrk.10.1691578235072; Wed, 09 Aug 2023 03:50:35 -0700 (PDT) Received: from localhost ([165.225.194.193]) by smtp.gmail.com with ESMTPSA id y15-20020adff14f000000b0031766e99429sm16450128wro.115.2023.08.09.03.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 03:50:34 -0700 (PDT) From: Joel Granados X-Google-Original-From: Joel Granados To: mcgrof@kernel.org Cc: rds-devel@oss.oracle.com, "David S. Miller" , Florian Westphal , willy@infradead.org, Jan Karcher , Wen Gu , Simon Horman , Tony Lu , linux-wpan@vger.kernel.org, Matthieu Baerts , Christian Borntraeger , mptcp@lists.linux.dev, Heiko Carstens , Stefan Schmidt , Will Deacon , Julian Anastasov , netfilter-devel@vger.kernel.org, Joerg Reuter , linux-kernel@vger.kernel.org, Alexander Gordeev , linux-sctp@vger.kernel.org, Xin Long , Herbert Xu , linux-hams@vger.kernel.org, Vasily Gorbik , coreteam@netfilter.org, Ralf Baechle , Steffen Klassert , Pablo Neira Ayuso , keescook@chromium.org, Roopa Prabhu , David Ahern , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Jozsef Kadlecsik , Wenjia Zhang , josh@joshtriplett.org, linux-fsdevel@vger.kernel.org, Alexander Aring , Nikolay Aleksandrov , netdev@vger.kernel.org, Santosh Shilimkar , linux-s390@vger.kernel.org, Sven Schnelle , "D. Wythe" , Eric Dumazet , lvs-devel@vger.kernel.org, linux-rdma@vger.kernel.org, Paolo Abeni , Iurii Zaikin , Marcelo Ricardo Leitner , bridge@lists.linux-foundation.org, Karsten Graul , Mat Martineau , Miquel Raynal , Jakub Kicinski , Joel Granados , Jani Nikula Subject: [PATCH v3 13/14] sysctl: SIZE_MAX->ARRAY_SIZE in register_net_sysctl Date: Wed, 9 Aug 2023 12:50:05 +0200 Message-Id: <20230809105006.1198165-14-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230809105006.1198165-1-j.granados@samsung.com> References: <20230809105006.1198165-1-j.granados@samsung.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773756948219044731 X-GMAIL-MSGID: 1773756948219044731 Replace SIZE_MAX with ARRAY_SIZE in the register_net_sysctl macro. Now that all the callers to register_net_sysctl are actual arrays, we can call ARRAY_SIZE() without any compilation warnings. By calculating the actual array size, this commit is making sure that register_net_sysctl and all its callers forward the table_size into sysctl backend for when the sentinel elements in the ctl_table arrays (last empty markers) are removed. Without it the removal would fail lacking a stopping criteria for traversing the ctl_table arrays. Stopping condition continues to be based on both table size and the procname null test. This is needed in order to allow for the systematic removal al the sentinel element in subsequent commits: Before removing sentinel the stopping criteria will be the last null element. When the sentinel is removed then the (correct) size will take over. Signed-off-by: Joel Granados Suggested-by: Jani Nikula --- include/net/net_namespace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index e4e5fe75a281..75dba309e043 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -470,7 +470,7 @@ void unregister_pernet_device(struct pernet_operations *); struct ctl_table; #define register_net_sysctl(net, path, table) \ - register_net_sysctl_sz(net, path, table, SIZE_MAX) + register_net_sysctl_sz(net, path, table, ARRAY_SIZE(table)) #ifdef CONFIG_SYSCTL int net_sysctl_init(void); struct ctl_table_header *register_net_sysctl_sz(struct net *net, const char *path,