Message ID | 20220310082251.13173-1-liwang@redhat.com |
---|---|
State | Accepted |
Headers | show |
Series | [COMMITTED] save_restore: remove the duplicate 'const' declaration | expand |
Hi Li > --- a/lib/newlib_tests/test19.c > +++ b/lib/newlib_tests/test19.c > @@ -23,7 +23,7 @@ static struct tst_test test = { > .needs_root = 1, > .test_all = run, > .setup = setup, > - .save_restore = (const struct tst_path_val const[]) { > + .save_restore = (const struct tst_path_val[]) { > {"?/proc/nonexistent", NULL}, > {"!/proc/sys/kernel/numa_balancing", NULL}, > {"/proc/sys/kernel/core_pattern", NULL}, Since tst_path_val is a struct array, we should use {NULL, NULL} or {} terminated instead of NULL terminated , otherwise it will report missing braces warning. Best Regards Yang Xu
On Thu, Mar 10, 2022 at 4:38 PM xuyang2018.jy@fujitsu.com < xuyang2018.jy@fujitsu.com> wrote: > Hi Li > > --- a/lib/newlib_tests/test19.c > > +++ b/lib/newlib_tests/test19.c > > @@ -23,7 +23,7 @@ static struct tst_test test = { > > .needs_root = 1, > > .test_all = run, > > .setup = setup, > > - .save_restore = (const struct tst_path_val const[]) { > > + .save_restore = (const struct tst_path_val[]) { > > {"?/proc/nonexistent", NULL}, > > {"!/proc/sys/kernel/numa_balancing", NULL}, > > {"/proc/sys/kernel/core_pattern", NULL}, > > Since tst_path_val is a struct array, we should use {NULL, NULL} or {} > terminated instead of NULL terminated , otherwise it will report missing > braces warning. > Ah, right. Sorry!!! Seems I was in so hurry to fix the const issue but overlook this.
Hi Li > > > On Thu, Mar 10, 2022 at 4:38 PM xuyang2018.jy@fujitsu.com > <mailto:xuyang2018.jy@fujitsu.com> <xuyang2018.jy@fujitsu.com > <mailto:xuyang2018.jy@fujitsu.com>> wrote: > > Hi Li > > --- a/lib/newlib_tests/test19.c > > +++ b/lib/newlib_tests/test19.c > > @@ -23,7 +23,7 @@ static struct tst_test test = { > > .needs_root = 1, > > .test_all = run, > > .setup = setup, > > - .save_restore = (const struct tst_path_val const[]) { > > + .save_restore = (const struct tst_path_val[]) { > > {"?/proc/nonexistent", NULL}, > > {"!/proc/sys/kernel/numa_balancing", NULL}, > > {"/proc/sys/kernel/core_pattern", NULL}, > > Since tst_path_val is a struct array, we should use {NULL, NULL} or {} > terminated instead of NULL terminated , otherwise it will report > missing > braces warning. > > Ah, right. Sorry!!! Never mind. > > Seems I was in so hurry to fix the const issue but overlook this. I also think you can add a separate patch to fix this comment in doc or in tst_test.h for other struct pointers. /* * NULL-terminated array to be allocated buffers. */ struct tst_buffers *bufs; /* * NULL-terminated array of capability settings */ struct tst_cap *caps; Best Regards Yang Xu > > -- > Regards, > Li Wang
On Thu, Mar 10, 2022 at 4:53 PM xuyang2018.jy@fujitsu.com < xuyang2018.jy@fujitsu.com> wrote: > Hi Li > > > > > > On Thu, Mar 10, 2022 at 4:38 PM xuyang2018.jy@fujitsu.com > > <mailto:xuyang2018.jy@fujitsu.com> <xuyang2018.jy@fujitsu.com > > <mailto:xuyang2018.jy@fujitsu.com>> wrote: > > > > Hi Li > > > --- a/lib/newlib_tests/test19.c > > > +++ b/lib/newlib_tests/test19.c > > > @@ -23,7 +23,7 @@ static struct tst_test test = { > > > .needs_root = 1, > > > .test_all = run, > > > .setup = setup, > > > - .save_restore = (const struct tst_path_val const[]) { > > > + .save_restore = (const struct tst_path_val[]) { > > > {"?/proc/nonexistent", NULL}, > > > {"!/proc/sys/kernel/numa_balancing", NULL}, > > > {"/proc/sys/kernel/core_pattern", NULL}, > > > > Since tst_path_val is a struct array, we should use {NULL, NULL} or > {} > > terminated instead of NULL terminated , otherwise it will report > > missing > > braces warning. > > > > Ah, right. Sorry!!! > Never mind. > > > > Seems I was in so hurry to fix the const issue but overlook this. > I also think you can add a separate patch to fix this comment in doc or > in tst_test.h for other struct pointers. > You are right. I will go through the whole part to see if other places need updates. Thanks for finding this :). > > /* > * NULL-terminated array to be allocated buffers. > */ > struct tst_buffers *bufs; > > /* > * NULL-terminated array of capability settings > */ > struct tst_cap *caps; > > Best Regards > Yang Xu > > > > -- > > Regards, > > Li Wang >
Hi Richard > Hi Li >> --- a/lib/newlib_tests/test19.c >> +++ b/lib/newlib_tests/test19.c >> @@ -23,7 +23,7 @@ static struct tst_test test = { >> .needs_root = 1, >> .test_all = run, >> .setup = setup, >> - .save_restore = (const struct tst_path_val const[]) { >> + .save_restore = (const struct tst_path_val[]) { >> {"?/proc/nonexistent", NULL}, >> {"!/proc/sys/kernel/numa_balancing", NULL}, >> {"/proc/sys/kernel/core_pattern", NULL}, > > Since tst_path_val is a struct array, we should use {NULL, NULL} or {} > terminated instead of NULL terminated , otherwise it will report missing > braces warning. Since we have the following rule LTP-005 Array must terminate with a sentinel value (i.e. NULL or '{}') Can we check struct array whether use {} terminated instead of NULL? Best Regards Yang Xu > > Best Regards > Yang Xu >
Hello, "xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com> writes: > Hi Richard >> Hi Li >>> --- a/lib/newlib_tests/test19.c >>> +++ b/lib/newlib_tests/test19.c >>> @@ -23,7 +23,7 @@ static struct tst_test test = { >>> .needs_root = 1, >>> .test_all = run, >>> .setup = setup, >>> - .save_restore = (const struct tst_path_val const[]) { >>> + .save_restore = (const struct tst_path_val[]) { >>> {"?/proc/nonexistent", NULL}, >>> {"!/proc/sys/kernel/numa_balancing", NULL}, >>> {"/proc/sys/kernel/core_pattern", NULL}, >> >> Since tst_path_val is a struct array, we should use {NULL, NULL} or {} >> terminated instead of NULL terminated , otherwise it will report missing >> braces warning. > Since we have the following rule > LTP-005 Array must terminate with a sentinel value (i.e. NULL or '{}') > > Can we check struct array whether use {} terminated instead of NULL? I think so, however naively enabling the check causes a segfault in ptr_list_empty. Probably because there is no list, it's just NULL. It already reports the missing braces, but I suppose this is not very helpful. > > Best Regards > Yang Xu >> >> Best Regards >> Yang Xu >>
Hi Richard > Hello, > > "xuyang2018.jy@fujitsu.com"<xuyang2018.jy@fujitsu.com> writes: > >> Hi Richard >>> Hi Li >>>> --- a/lib/newlib_tests/test19.c >>>> +++ b/lib/newlib_tests/test19.c >>>> @@ -23,7 +23,7 @@ static struct tst_test test = { >>>> .needs_root = 1, >>>> .test_all = run, >>>> .setup = setup, >>>> - .save_restore = (const struct tst_path_val const[]) { >>>> + .save_restore = (const struct tst_path_val[]) { >>>> {"?/proc/nonexistent", NULL}, >>>> {"!/proc/sys/kernel/numa_balancing", NULL}, >>>> {"/proc/sys/kernel/core_pattern", NULL}, >>> >>> Since tst_path_val is a struct array, we should use {NULL, NULL} or {} >>> terminated instead of NULL terminated , otherwise it will report missing >>> braces warning. >> Since we have the following rule >> LTP-005 Array must terminate with a sentinel value (i.e. NULL or '{}') >> >> Can we check struct array whether use {} terminated instead of NULL? > > I think so, however naively enabling the check causes a segfault in > ptr_list_empty. Probably because there is no list, it's just NULL. > > It already reports the missing braces, but I suppose this is not very > helpful. Sound reasonable. Best Regards Yang Xu > >> >> Best Regards >> Yang Xu >>> >>> Best Regards >>> Yang Xu >>> > >
diff --git a/include/tst_test.h b/include/tst_test.h index e514efa76..3bedcc707 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -259,7 +259,7 @@ struct tst_test { * NULL terminated array of (/proc, /sys) files to save * before setup and restore after cleanup */ - const struct tst_path_val const *save_restore; + const struct tst_path_val *save_restore; /* * NULL terminated array of kernel config options required for the diff --git a/lib/newlib_tests/test19.c b/lib/newlib_tests/test19.c index 402a2ad30..4359a58ea 100644 --- a/lib/newlib_tests/test19.c +++ b/lib/newlib_tests/test19.c @@ -23,7 +23,7 @@ static struct tst_test test = { .needs_root = 1, .test_all = run, .setup = setup, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/nonexistent", NULL}, {"!/proc/sys/kernel/numa_balancing", NULL}, {"/proc/sys/kernel/core_pattern", NULL}, diff --git a/lib/newlib_tests/test20.c b/lib/newlib_tests/test20.c index 5feb7c144..aaa424c83 100644 --- a/lib/newlib_tests/test20.c +++ b/lib/newlib_tests/test20.c @@ -36,7 +36,7 @@ static void do_test(void) { static struct tst_test test = { .test_all = do_test, .request_hugepages = 2, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"!/proc/sys/kernel/numa_balancing", "0"}, NULL, }, diff --git a/lib/tst_test.c b/lib/tst_test.c index fe2e2bb6c..384c73e16 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -1105,7 +1105,7 @@ static void do_setup(int argc, char *argv[]) tst_tmpdir(); if (tst_test->save_restore) { - const struct tst_path_val const *pvl = tst_test->save_restore; + const struct tst_path_val *pvl = tst_test->save_restore; while (pvl->path) { if (!tst_sys_conf_save(pvl->path)) diff --git a/testcases/cve/icmp_rate_limit01.c b/testcases/cve/icmp_rate_limit01.c index 81735ce18..b8f159514 100644 --- a/testcases/cve/icmp_rate_limit01.c +++ b/testcases/cve/icmp_rate_limit01.c @@ -268,7 +268,7 @@ static struct tst_test test = { "CONFIG_NET_NS=y", NULL }, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/sys/user/max_user_namespaces", NULL}, NULL, }, diff --git a/testcases/kernel/containers/userns/userns08.c b/testcases/kernel/containers/userns/userns08.c index 33d0a9997..822b5c93f 100644 --- a/testcases/kernel/containers/userns/userns08.c +++ b/testcases/kernel/containers/userns/userns08.c @@ -134,7 +134,7 @@ static struct tst_test test = { "CONFIG_USER_NS", NULL }, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/sys/user/max_user_namespaces", NULL}, NULL, }, diff --git a/testcases/kernel/mem/ksm/ksm01.c b/testcases/kernel/mem/ksm/ksm01.c index 305bf30ea..4265f7486 100644 --- a/testcases/kernel/mem/ksm/ksm01.c +++ b/testcases/kernel/mem/ksm/ksm01.c @@ -79,7 +79,7 @@ static struct tst_test test = { {} }, .setup = setup, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"!/sys/kernel/mm/ksm/run", NULL}, {"!/sys/kernel/mm/ksm/sleep_millisecs", NULL}, {"?/sys/kernel/mm/ksm/max_page_sharing", NULL}, diff --git a/testcases/kernel/mem/ksm/ksm02.c b/testcases/kernel/mem/ksm/ksm02.c index 6ad7bcadb..daa8eb076 100644 --- a/testcases/kernel/mem/ksm/ksm02.c +++ b/testcases/kernel/mem/ksm/ksm02.c @@ -97,7 +97,7 @@ static struct tst_test test = { {} }, .setup = setup, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"!/sys/kernel/mm/ksm/run", NULL}, {"!/sys/kernel/mm/ksm/sleep_millisecs", NULL}, {"?/sys/kernel/mm/ksm/max_page_sharing", NULL}, diff --git a/testcases/kernel/mem/ksm/ksm03.c b/testcases/kernel/mem/ksm/ksm03.c index 94223e332..f0115eb18 100644 --- a/testcases/kernel/mem/ksm/ksm03.c +++ b/testcases/kernel/mem/ksm/ksm03.c @@ -82,7 +82,7 @@ static struct tst_test test = { {} }, .setup = setup, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"!/sys/kernel/mm/ksm/run", NULL}, {"!/sys/kernel/mm/ksm/sleep_millisecs", NULL}, {"?/sys/kernel/mm/ksm/max_page_sharing", NULL}, diff --git a/testcases/kernel/mem/ksm/ksm04.c b/testcases/kernel/mem/ksm/ksm04.c index 3e8a77bec..ec058aa01 100644 --- a/testcases/kernel/mem/ksm/ksm04.c +++ b/testcases/kernel/mem/ksm/ksm04.c @@ -99,7 +99,7 @@ static struct tst_test test = { {} }, .setup = setup, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"!/sys/kernel/mm/ksm/run", NULL}, {"!/sys/kernel/mm/ksm/sleep_millisecs", NULL}, {"?/sys/kernel/mm/ksm/max_page_sharing", NULL}, diff --git a/testcases/kernel/mem/ksm/ksm05.c b/testcases/kernel/mem/ksm/ksm05.c index 33721d388..0c1ced5d7 100644 --- a/testcases/kernel/mem/ksm/ksm05.c +++ b/testcases/kernel/mem/ksm/ksm05.c @@ -88,7 +88,7 @@ static struct tst_test test = { .forks_child = 1, .test_all = test_ksm, .min_kver = "2.6.32", - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"!/sys/kernel/mm/ksm/run", "1"}, NULL, }, diff --git a/testcases/kernel/mem/ksm/ksm06.c b/testcases/kernel/mem/ksm/ksm06.c index f28383cc0..4f39be0b2 100644 --- a/testcases/kernel/mem/ksm/ksm06.c +++ b/testcases/kernel/mem/ksm/ksm06.c @@ -136,7 +136,7 @@ static struct tst_test test = { {} }, .setup = setup, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/sys/kernel/mm/ksm/max_page_sharing", NULL}, {"!/sys/kernel/mm/ksm/run", NULL}, {"!/sys/kernel/mm/ksm/sleep_millisecs", NULL}, diff --git a/testcases/kernel/syscalls/add_key/add_key05.c b/testcases/kernel/syscalls/add_key/add_key05.c index bbe44e043..7a9cc6453 100644 --- a/testcases/kernel/syscalls/add_key/add_key05.c +++ b/testcases/kernel/syscalls/add_key/add_key05.c @@ -214,7 +214,7 @@ static struct tst_test test = { .needs_root = 1, .forks_child = 1, .cleanup = cleanup, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/sys/kernel/keys/gc_delay", "1"}, {"?/proc/sys/kernel/keys/maxkeys", "200"}, {"?/proc/sys/kernel/keys/maxbytes", "20000"}, diff --git a/testcases/kernel/syscalls/bind/bind06.c b/testcases/kernel/syscalls/bind/bind06.c index 7a84b19cd..d0157d426 100644 --- a/testcases/kernel/syscalls/bind/bind06.c +++ b/testcases/kernel/syscalls/bind/bind06.c @@ -109,7 +109,7 @@ static struct tst_test test = { "CONFIG_NET_NS=y", NULL }, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/sys/user/max_user_namespaces", NULL}, NULL, }, diff --git a/testcases/kernel/syscalls/madvise/madvise08.c b/testcases/kernel/syscalls/madvise/madvise08.c index e513d558a..b774bcd1c 100644 --- a/testcases/kernel/syscalls/madvise/madvise08.c +++ b/testcases/kernel/syscalls/madvise/madvise08.c @@ -213,7 +213,7 @@ static struct tst_test test = { .needs_tmpdir = 1, .needs_root = 1, .forks_child = 1, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {CORE_PATTERN, NULL}, NULL, }, diff --git a/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c b/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c index 162ff09a9..7552464b8 100644 --- a/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c +++ b/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c @@ -326,7 +326,7 @@ static struct tst_test test = { .forks_child = 1, .test_all = run, .setup = setup, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/sys/kernel/numa_balancing", "0"}, NULL, }, diff --git a/testcases/kernel/syscalls/sendto/sendto03.c b/testcases/kernel/syscalls/sendto/sendto03.c index 4459f8849..aa4dc3040 100644 --- a/testcases/kernel/syscalls/sendto/sendto03.c +++ b/testcases/kernel/syscalls/sendto/sendto03.c @@ -217,7 +217,7 @@ static struct tst_test test = { "CONFIG_NET_NS=y", NULL }, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/sys/user/max_user_namespaces", NULL}, NULL, }, diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt05.c b/testcases/kernel/syscalls/setsockopt/setsockopt05.c index abc76627a..d7855cfab 100644 --- a/testcases/kernel/syscalls/setsockopt/setsockopt05.c +++ b/testcases/kernel/syscalls/setsockopt/setsockopt05.c @@ -101,7 +101,7 @@ static struct tst_test test = { "CONFIG_NET_NS=y", NULL }, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/sys/user/max_user_namespaces", NULL}, NULL, }, diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt06.c b/testcases/kernel/syscalls/setsockopt/setsockopt06.c index 25dd04a15..e4c2671c0 100644 --- a/testcases/kernel/syscalls/setsockopt/setsockopt06.c +++ b/testcases/kernel/syscalls/setsockopt/setsockopt06.c @@ -129,7 +129,7 @@ static struct tst_test test = { "CONFIG_NET_NS=y", NULL }, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/sys/user/max_user_namespaces", NULL}, NULL, }, diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt07.c b/testcases/kernel/syscalls/setsockopt/setsockopt07.c index b405c8ece..49c8fb6b4 100644 --- a/testcases/kernel/syscalls/setsockopt/setsockopt07.c +++ b/testcases/kernel/syscalls/setsockopt/setsockopt07.c @@ -141,7 +141,7 @@ static struct tst_test test = { "CONFIG_NET_NS=y", NULL }, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/sys/user/max_user_namespaces", NULL}, NULL, }, diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt08.c b/testcases/kernel/syscalls/setsockopt/setsockopt08.c index 49eb17b13..864958b3e 100644 --- a/testcases/kernel/syscalls/setsockopt/setsockopt08.c +++ b/testcases/kernel/syscalls/setsockopt/setsockopt08.c @@ -158,7 +158,7 @@ static struct tst_test test = { "CONFIG_NET_NS=y", NULL }, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/sys/user/max_user_namespaces", NULL}, NULL, }, diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt09.c b/testcases/kernel/syscalls/setsockopt/setsockopt09.c index 53944247f..4f03975ca 100644 --- a/testcases/kernel/syscalls/setsockopt/setsockopt09.c +++ b/testcases/kernel/syscalls/setsockopt/setsockopt09.c @@ -105,7 +105,7 @@ static struct tst_test test = { "CONFIG_NET_NS=y", NULL }, - .save_restore = (const struct tst_path_val const[]) { + .save_restore = (const struct tst_path_val[]) { {"?/proc/sys/user/max_user_namespaces", NULL}, NULL, },
Signed-off-by: Li Wang <liwang@redhat.com> Reported-by: Yang Xu <xuyang2018.jy@fujitsu.com> --- include/tst_test.h | 2 +- lib/newlib_tests/test19.c | 2 +- lib/newlib_tests/test20.c | 2 +- lib/tst_test.c | 2 +- testcases/cve/icmp_rate_limit01.c | 2 +- testcases/kernel/containers/userns/userns08.c | 2 +- testcases/kernel/mem/ksm/ksm01.c | 2 +- testcases/kernel/mem/ksm/ksm02.c | 2 +- testcases/kernel/mem/ksm/ksm03.c | 2 +- testcases/kernel/mem/ksm/ksm04.c | 2 +- testcases/kernel/mem/ksm/ksm05.c | 2 +- testcases/kernel/mem/ksm/ksm06.c | 2 +- testcases/kernel/syscalls/add_key/add_key05.c | 2 +- testcases/kernel/syscalls/bind/bind06.c | 2 +- testcases/kernel/syscalls/madvise/madvise08.c | 2 +- testcases/kernel/syscalls/migrate_pages/migrate_pages02.c | 2 +- testcases/kernel/syscalls/sendto/sendto03.c | 2 +- testcases/kernel/syscalls/setsockopt/setsockopt05.c | 2 +- testcases/kernel/syscalls/setsockopt/setsockopt06.c | 2 +- testcases/kernel/syscalls/setsockopt/setsockopt07.c | 2 +- testcases/kernel/syscalls/setsockopt/setsockopt08.c | 2 +- testcases/kernel/syscalls/setsockopt/setsockopt09.c | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-)