99#define KUNIT_PROC_READ 0
1010#define KUNIT_PROC_WRITE 1
1111
12- static int i_zero ;
13- static int i_one_hundred = 100 ;
14-
1512/*
1613 * Test that proc_dointvec will not try to use a NULL .data field even when the
1714 * length is non-zero.
@@ -29,8 +26,8 @@ static void sysctl_test_api_dointvec_null_tbl_data(struct kunit *test)
2926 .maxlen = sizeof (int ),
3027 .mode = 0644 ,
3128 .proc_handler = proc_dointvec ,
32- .extra1 = & i_zero ,
33- .extra2 = & i_one_hundred ,
29+ .extra1 = SYSCTL_ZERO ,
30+ .extra2 = SYSCTL_ONE_HUNDRED ,
3431 };
3532 /*
3633 * 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(struct kunit *test)
7976 .maxlen = 0 ,
8077 .mode = 0644 ,
8178 .proc_handler = proc_dointvec ,
82- .extra1 = & i_zero ,
83- .extra2 = & i_one_hundred ,
79+ .extra1 = SYSCTL_ZERO ,
80+ .extra2 = SYSCTL_ONE_HUNDRED ,
8481 };
8582 void __user * buffer = (void __user * )kunit_kzalloc (test , sizeof (int ),
8683 GFP_USER );
@@ -122,8 +119,8 @@ static void sysctl_test_api_dointvec_table_len_is_zero(struct kunit *test)
122119 .maxlen = sizeof (int ),
123120 .mode = 0644 ,
124121 .proc_handler = proc_dointvec ,
125- .extra1 = & i_zero ,
126- .extra2 = & i_one_hundred ,
122+ .extra1 = SYSCTL_ZERO ,
123+ .extra2 = SYSCTL_ONE_HUNDRED ,
127124 };
128125 void __user * buffer = (void __user * )kunit_kzalloc (test , sizeof (int ),
129126 GFP_USER );
@@ -156,8 +153,8 @@ static void sysctl_test_api_dointvec_table_read_but_position_set(
156153 .maxlen = sizeof (int ),
157154 .mode = 0644 ,
158155 .proc_handler = proc_dointvec ,
159- .extra1 = & i_zero ,
160- .extra2 = & i_one_hundred ,
156+ .extra1 = SYSCTL_ZERO ,
157+ .extra2 = SYSCTL_ONE_HUNDRED ,
161158 };
162159 void __user * buffer = (void __user * )kunit_kzalloc (test , sizeof (int ),
163160 GFP_USER );
@@ -191,8 +188,8 @@ static void sysctl_test_dointvec_read_happy_single_positive(struct kunit *test)
191188 .maxlen = sizeof (int ),
192189 .mode = 0644 ,
193190 .proc_handler = proc_dointvec ,
194- .extra1 = & i_zero ,
195- .extra2 = & i_one_hundred ,
191+ .extra1 = SYSCTL_ZERO ,
192+ .extra2 = SYSCTL_ONE_HUNDRED ,
196193 };
197194 size_t len = 4 ;
198195 loff_t pos = 0 ;
@@ -222,8 +219,8 @@ static void sysctl_test_dointvec_read_happy_single_negative(struct kunit *test)
222219 .maxlen = sizeof (int ),
223220 .mode = 0644 ,
224221 .proc_handler = proc_dointvec ,
225- .extra1 = & i_zero ,
226- .extra2 = & i_one_hundred ,
222+ .extra1 = SYSCTL_ZERO ,
223+ .extra2 = SYSCTL_ONE_HUNDRED ,
227224 };
228225 size_t len = 5 ;
229226 loff_t pos = 0 ;
@@ -251,8 +248,8 @@ static void sysctl_test_dointvec_write_happy_single_positive(struct kunit *test)
251248 .maxlen = sizeof (int ),
252249 .mode = 0644 ,
253250 .proc_handler = proc_dointvec ,
254- .extra1 = & i_zero ,
255- .extra2 = & i_one_hundred ,
251+ .extra1 = SYSCTL_ZERO ,
252+ .extra2 = SYSCTL_ONE_HUNDRED ,
256253 };
257254 char input [] = "9" ;
258255 size_t len = sizeof (input ) - 1 ;
@@ -281,8 +278,8 @@ static void sysctl_test_dointvec_write_happy_single_negative(struct kunit *test)
281278 .maxlen = sizeof (int ),
282279 .mode = 0644 ,
283280 .proc_handler = proc_dointvec ,
284- .extra1 = & i_zero ,
285- .extra2 = & i_one_hundred ,
281+ .extra1 = SYSCTL_ZERO ,
282+ .extra2 = SYSCTL_ONE_HUNDRED ,
286283 };
287284 char input [] = "-9" ;
288285 size_t len = sizeof (input ) - 1 ;
@@ -313,8 +310,8 @@ static void sysctl_test_api_dointvec_write_single_less_int_min(
313310 .maxlen = sizeof (int ),
314311 .mode = 0644 ,
315312 .proc_handler = proc_dointvec ,
316- .extra1 = & i_zero ,
317- .extra2 = & i_one_hundred ,
313+ .extra1 = SYSCTL_ZERO ,
314+ .extra2 = SYSCTL_ONE_HUNDRED ,
318315 };
319316 size_t max_len = 32 , len = max_len ;
320317 loff_t pos = 0 ;
@@ -351,8 +348,8 @@ static void sysctl_test_api_dointvec_write_single_greater_int_max(
351348 .maxlen = sizeof (int ),
352349 .mode = 0644 ,
353350 .proc_handler = proc_dointvec ,
354- .extra1 = & i_zero ,
355- .extra2 = & i_one_hundred ,
351+ .extra1 = SYSCTL_ZERO ,
352+ .extra2 = SYSCTL_ONE_HUNDRED ,
356353 };
357354 size_t max_len = 32 , len = max_len ;
358355 loff_t pos = 0 ;
0 commit comments