From nobody Mon Apr 6 17:07:40 2026 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 745E5C6FA83 for ; Mon, 5 Sep 2022 12:15:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236650AbiIEMPA (ORCPT ); Mon, 5 Sep 2022 08:15:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237084AbiIEMOu (ORCPT ); Mon, 5 Sep 2022 08:14:50 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3EEC12D10; Mon, 5 Sep 2022 05:14:48 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MLnTd5PnRzrSBk; Mon, 5 Sep 2022 20:12:53 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 5 Sep 2022 20:14:46 +0800 Received: from huawei.com (10.175.113.32) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 5 Sep 2022 20:14:45 +0800 From: Liu Shixin To: Luis Chamberlain , Kees Cook , Iurii Zaikin CC: , , "Liu Shixin" , Kefeng Wang Subject: [PATCH] kernel/sysctl-test: use SYSCTL_{ZERO/ONE_HUNDRED} instead of i_{zero/one_hundred} Date: Mon, 5 Sep 2022 20:48:56 +0800 Message-ID: <20220905124856.2233973-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It is better to use SYSCTL_ZERO and SYSCTL_ONE_HUNDRED instead of &i_zero and &i_one_hundred, and then we can remove these two local variable. No functional change. Signed-off-by: Liu Shixin Reported-by: kernel test robot --- kernel/sysctl-test.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/kernel/sysctl-test.c b/kernel/sysctl-test.c index 664ded05dd7a..6ef887c19c48 100644 --- a/kernel/sysctl-test.c +++ b/kernel/sysctl-test.c @@ -9,9 +9,6 @@ #define KUNIT_PROC_READ 0 #define KUNIT_PROC_WRITE 1 =20 -static int i_zero; -static int i_one_hundred =3D 100; - /* * Test that proc_dointvec will not try to use a NULL .data field even whe= n the * length is non-zero. @@ -29,8 +26,8 @@ static void sysctl_test_api_dointvec_null_tbl_data(struct= kunit *test) .maxlen =3D sizeof(int), .mode =3D 0644, .proc_handler =3D proc_dointvec, - .extra1 =3D &i_zero, - .extra2 =3D &i_one_hundred, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D SYSCTL_ONE_HUNDRED, }; /* * proc_dointvec expects a buffer in user space, so we allocate one. We @@ -79,8 +76,8 @@ static void sysctl_test_api_dointvec_table_maxlen_unset(s= truct kunit *test) .maxlen =3D 0, .mode =3D 0644, .proc_handler =3D proc_dointvec, - .extra1 =3D &i_zero, - .extra2 =3D &i_one_hundred, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D SYSCTL_ONE_HUNDRED, }; void __user *buffer =3D (void __user *)kunit_kzalloc(test, sizeof(int), GFP_USER); @@ -122,8 +119,8 @@ static void sysctl_test_api_dointvec_table_len_is_zero(= struct kunit *test) .maxlen =3D sizeof(int), .mode =3D 0644, .proc_handler =3D proc_dointvec, - .extra1 =3D &i_zero, - .extra2 =3D &i_one_hundred, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D SYSCTL_ONE_HUNDRED, }; void __user *buffer =3D (void __user *)kunit_kzalloc(test, sizeof(int), GFP_USER); @@ -156,8 +153,8 @@ static void sysctl_test_api_dointvec_table_read_but_pos= ition_set( .maxlen =3D sizeof(int), .mode =3D 0644, .proc_handler =3D proc_dointvec, - .extra1 =3D &i_zero, - .extra2 =3D &i_one_hundred, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D SYSCTL_ONE_HUNDRED, }; void __user *buffer =3D (void __user *)kunit_kzalloc(test, sizeof(int), GFP_USER); @@ -191,8 +188,8 @@ static void sysctl_test_dointvec_read_happy_single_posi= tive(struct kunit *test) .maxlen =3D sizeof(int), .mode =3D 0644, .proc_handler =3D proc_dointvec, - .extra1 =3D &i_zero, - .extra2 =3D &i_one_hundred, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D SYSCTL_ONE_HUNDRED, }; size_t len =3D 4; loff_t pos =3D 0; @@ -222,8 +219,8 @@ static void sysctl_test_dointvec_read_happy_single_nega= tive(struct kunit *test) .maxlen =3D sizeof(int), .mode =3D 0644, .proc_handler =3D proc_dointvec, - .extra1 =3D &i_zero, - .extra2 =3D &i_one_hundred, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D SYSCTL_ONE_HUNDRED, }; size_t len =3D 5; loff_t pos =3D 0; @@ -251,8 +248,8 @@ static void sysctl_test_dointvec_write_happy_single_pos= itive(struct kunit *test) .maxlen =3D sizeof(int), .mode =3D 0644, .proc_handler =3D proc_dointvec, - .extra1 =3D &i_zero, - .extra2 =3D &i_one_hundred, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D SYSCTL_ONE_HUNDRED, }; char input[] =3D "9"; size_t len =3D sizeof(input) - 1; @@ -281,8 +278,8 @@ static void sysctl_test_dointvec_write_happy_single_neg= ative(struct kunit *test) .maxlen =3D sizeof(int), .mode =3D 0644, .proc_handler =3D proc_dointvec, - .extra1 =3D &i_zero, - .extra2 =3D &i_one_hundred, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D SYSCTL_ONE_HUNDRED, }; char input[] =3D "-9"; size_t len =3D sizeof(input) - 1; @@ -313,8 +310,8 @@ static void sysctl_test_api_dointvec_write_single_less_= int_min( .maxlen =3D sizeof(int), .mode =3D 0644, .proc_handler =3D proc_dointvec, - .extra1 =3D &i_zero, - .extra2 =3D &i_one_hundred, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D SYSCTL_ONE_HUNDRED, }; size_t max_len =3D 32, len =3D max_len; loff_t pos =3D 0; @@ -351,8 +348,8 @@ static void sysctl_test_api_dointvec_write_single_great= er_int_max( .maxlen =3D sizeof(int), .mode =3D 0644, .proc_handler =3D proc_dointvec, - .extra1 =3D &i_zero, - .extra2 =3D &i_one_hundred, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D SYSCTL_ONE_HUNDRED, }; size_t max_len =3D 32, len =3D max_len; loff_t pos =3D 0; --=20 2.25.1