[LTP] [PATCH] dup06: Convert to new API
Shiyang Ruan
ruansy.fnst@fujitsu.com
Thu Jan 11 03:10:46 CET 2024
在 2024/1/11 2:29, Petr Vorel 写道:
> Hi Shiyang,
>
>> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
>> ---
>> testcases/kernel/syscalls/dup/dup06.c | 141 ++++++++++----------------
>> 1 file changed, 52 insertions(+), 89 deletions(-)
>
>> diff --git a/testcases/kernel/syscalls/dup/dup06.c b/testcases/kernel/syscalls/dup/dup06.c
>> index e3f8070bf..84fc260a1 100644
>> --- a/testcases/kernel/syscalls/dup/dup06.c
>> +++ b/testcases/kernel/syscalls/dup/dup06.c
>> @@ -1,42 +1,22 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> /*
>> - * Copyright (c) International Business Machines Corp., 2002
>> - * ported from SPIE, section2/iosuite/dup1.c, by Airong Zhang
>> - * Copyright (c) 2013 Cyril Hrubis <chrubis@suse.cz>
> ...
>> + * Copyright (c) International Business Machines Corp., 2002
>> + * ported from SPIE, section2/iosuite/dup1.c, by Airong Zhang
>> + * Copyright (c) 2013 Cyril Hrubis <chrubis@suse.cz>
> Could you please also add your or LTP copyright for this rewrite?
> E.g.
> * Copyright (c) Linux Test Project, 2003-2015
> + your copyright, or just:
> * Copyright (c) Linux Test Project, 2003-2024
>
> $ make check-dup06
> CHECK testcases/kernel/syscalls/dup/dup06.c
> dup06.c:28: ERROR: return is not a function, parentheses are not required
> dup06.c:53: ERROR: do not use assignment in if condition
> dup06.c:56: WARNING: braces {} are not necessary for any arm of this statement
>
> Therefore I'm going to merge with following change (+ please let me know if you
> want to add your copyright).
>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
Thanks, adding LTP copyright is fine.
Let me send a new version of these two patches because the next one has
the same issue. I've fixed it.
--
Ruan.
>
> Kind regards,
> Petr
>
> diff --git testcases/kernel/syscalls/dup/dup06.c testcases/kernel/syscalls/dup/dup06.c
> index 84fc260a1..e7e27b8f9 100644
> --- testcases/kernel/syscalls/dup/dup06.c
> +++ testcases/kernel/syscalls/dup/dup06.c
> @@ -1,8 +1,9 @@
> // SPDX-License-Identifier: GPL-2.0-or-later
> /*
> * Copyright (c) International Business Machines Corp., 2002
> - * ported from SPIE, section2/iosuite/dup1.c, by Airong Zhang
> + * ported from SPIE, section2/iosuite/dup1.c, by Airong Zhang
> * Copyright (c) 2013 Cyril Hrubis <chrubis@suse.cz>
> + * Copyright (c) Linux Test Project, 2003-2024
> */
>
> /*\
> @@ -17,6 +18,7 @@
> static int *pfildes;
> static int minfd, maxfd, freefds;
> static char pfilname[40];
> +
> static int cnt_free_fds(int maxfd)
> {
> int freefds = 0;
> @@ -25,7 +27,7 @@ static int cnt_free_fds(int maxfd)
> if (fcntl(maxfd, F_GETFD) == -1 && errno == EBADF)
> freefds++;
>
> - return (freefds);
> + return freefds;
> }
>
> static void setup(void)
> @@ -50,16 +52,17 @@ static void run(void)
>
> pfildes[0] = SAFE_CREAT(pfilname, 0666);
> for (i = 1; i < maxfd; i++) {
> - if ((pfildes[i] = dup(pfildes[i - 1])) == -1)
> + pfildes[i] = dup(pfildes[i - 1]);
> + if (pfildes[i] == -1)
> break;
> }
> - if (i < freefds) {
> +
> + if (i < freefds)
> tst_res(TFAIL, "Not enough files duped");
> - } else if (i > freefds) {
> + else if (i > freefds)
> tst_res(TFAIL, "Too many files duped");
> - } else {
> - tst_res(TPASS, "Test passed.");
> - }
> + else
> + tst_res(TPASS, "Test passed");
>
> SAFE_UNLINK(pfilname);
>
More information about the ltp
mailing list