kernel/sysctl-test: use SYSCTL_{ZERO/ONE_HUNDRED} instead of i_{zero/one_hundred}
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 <liushixin2@huawei.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
This commit is contained in:
parent
b13bc7cbb9
commit
c06a17fe05
|
@ -9,9 +9,6 @@
|
||||||
#define KUNIT_PROC_READ 0
|
#define KUNIT_PROC_READ 0
|
||||||
#define KUNIT_PROC_WRITE 1
|
#define KUNIT_PROC_WRITE 1
|
||||||
|
|
||||||
static int i_zero;
|
|
||||||
static int i_one_hundred = 100;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test that proc_dointvec will not try to use a NULL .data field even when the
|
* Test that proc_dointvec will not try to use a NULL .data field even when the
|
||||||
* length is non-zero.
|
* length is non-zero.
|
||||||
|
@ -29,8 +26,8 @@ static void sysctl_test_api_dointvec_null_tbl_data(struct kunit *test)
|
||||||
.maxlen = sizeof(int),
|
.maxlen = sizeof(int),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec,
|
.proc_handler = proc_dointvec,
|
||||||
.extra1 = &i_zero,
|
.extra1 = SYSCTL_ZERO,
|
||||||
.extra2 = &i_one_hundred,
|
.extra2 = SYSCTL_ONE_HUNDRED,
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
* proc_dointvec expects a buffer in user space, so we allocate one. We
|
* 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)
|
||||||
.maxlen = 0,
|
.maxlen = 0,
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec,
|
.proc_handler = proc_dointvec,
|
||||||
.extra1 = &i_zero,
|
.extra1 = SYSCTL_ZERO,
|
||||||
.extra2 = &i_one_hundred,
|
.extra2 = SYSCTL_ONE_HUNDRED,
|
||||||
};
|
};
|
||||||
void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int),
|
void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int),
|
||||||
GFP_USER);
|
GFP_USER);
|
||||||
|
@ -122,8 +119,8 @@ static void sysctl_test_api_dointvec_table_len_is_zero(struct kunit *test)
|
||||||
.maxlen = sizeof(int),
|
.maxlen = sizeof(int),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec,
|
.proc_handler = proc_dointvec,
|
||||||
.extra1 = &i_zero,
|
.extra1 = SYSCTL_ZERO,
|
||||||
.extra2 = &i_one_hundred,
|
.extra2 = SYSCTL_ONE_HUNDRED,
|
||||||
};
|
};
|
||||||
void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int),
|
void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int),
|
||||||
GFP_USER);
|
GFP_USER);
|
||||||
|
@ -156,8 +153,8 @@ static void sysctl_test_api_dointvec_table_read_but_position_set(
|
||||||
.maxlen = sizeof(int),
|
.maxlen = sizeof(int),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec,
|
.proc_handler = proc_dointvec,
|
||||||
.extra1 = &i_zero,
|
.extra1 = SYSCTL_ZERO,
|
||||||
.extra2 = &i_one_hundred,
|
.extra2 = SYSCTL_ONE_HUNDRED,
|
||||||
};
|
};
|
||||||
void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int),
|
void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int),
|
||||||
GFP_USER);
|
GFP_USER);
|
||||||
|
@ -191,8 +188,8 @@ static void sysctl_test_dointvec_read_happy_single_positive(struct kunit *test)
|
||||||
.maxlen = sizeof(int),
|
.maxlen = sizeof(int),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec,
|
.proc_handler = proc_dointvec,
|
||||||
.extra1 = &i_zero,
|
.extra1 = SYSCTL_ZERO,
|
||||||
.extra2 = &i_one_hundred,
|
.extra2 = SYSCTL_ONE_HUNDRED,
|
||||||
};
|
};
|
||||||
size_t len = 4;
|
size_t len = 4;
|
||||||
loff_t pos = 0;
|
loff_t pos = 0;
|
||||||
|
@ -222,8 +219,8 @@ static void sysctl_test_dointvec_read_happy_single_negative(struct kunit *test)
|
||||||
.maxlen = sizeof(int),
|
.maxlen = sizeof(int),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec,
|
.proc_handler = proc_dointvec,
|
||||||
.extra1 = &i_zero,
|
.extra1 = SYSCTL_ZERO,
|
||||||
.extra2 = &i_one_hundred,
|
.extra2 = SYSCTL_ONE_HUNDRED,
|
||||||
};
|
};
|
||||||
size_t len = 5;
|
size_t len = 5;
|
||||||
loff_t pos = 0;
|
loff_t pos = 0;
|
||||||
|
@ -251,8 +248,8 @@ static void sysctl_test_dointvec_write_happy_single_positive(struct kunit *test)
|
||||||
.maxlen = sizeof(int),
|
.maxlen = sizeof(int),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec,
|
.proc_handler = proc_dointvec,
|
||||||
.extra1 = &i_zero,
|
.extra1 = SYSCTL_ZERO,
|
||||||
.extra2 = &i_one_hundred,
|
.extra2 = SYSCTL_ONE_HUNDRED,
|
||||||
};
|
};
|
||||||
char input[] = "9";
|
char input[] = "9";
|
||||||
size_t len = sizeof(input) - 1;
|
size_t len = sizeof(input) - 1;
|
||||||
|
@ -281,8 +278,8 @@ static void sysctl_test_dointvec_write_happy_single_negative(struct kunit *test)
|
||||||
.maxlen = sizeof(int),
|
.maxlen = sizeof(int),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec,
|
.proc_handler = proc_dointvec,
|
||||||
.extra1 = &i_zero,
|
.extra1 = SYSCTL_ZERO,
|
||||||
.extra2 = &i_one_hundred,
|
.extra2 = SYSCTL_ONE_HUNDRED,
|
||||||
};
|
};
|
||||||
char input[] = "-9";
|
char input[] = "-9";
|
||||||
size_t len = sizeof(input) - 1;
|
size_t len = sizeof(input) - 1;
|
||||||
|
@ -313,8 +310,8 @@ static void sysctl_test_api_dointvec_write_single_less_int_min(
|
||||||
.maxlen = sizeof(int),
|
.maxlen = sizeof(int),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec,
|
.proc_handler = proc_dointvec,
|
||||||
.extra1 = &i_zero,
|
.extra1 = SYSCTL_ZERO,
|
||||||
.extra2 = &i_one_hundred,
|
.extra2 = SYSCTL_ONE_HUNDRED,
|
||||||
};
|
};
|
||||||
size_t max_len = 32, len = max_len;
|
size_t max_len = 32, len = max_len;
|
||||||
loff_t pos = 0;
|
loff_t pos = 0;
|
||||||
|
@ -351,8 +348,8 @@ static void sysctl_test_api_dointvec_write_single_greater_int_max(
|
||||||
.maxlen = sizeof(int),
|
.maxlen = sizeof(int),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec,
|
.proc_handler = proc_dointvec,
|
||||||
.extra1 = &i_zero,
|
.extra1 = SYSCTL_ZERO,
|
||||||
.extra2 = &i_one_hundred,
|
.extra2 = SYSCTL_ONE_HUNDRED,
|
||||||
};
|
};
|
||||||
size_t max_len = 32, len = max_len;
|
size_t max_len = 32, len = max_len;
|
||||||
loff_t pos = 0;
|
loff_t pos = 0;
|
||||||
|
|
Loading…
Reference in New Issue