[LTP] [PATCH 1/2] pathconf01: Convert to new API

Yang Xu (Fujitsu) xuyang2018.jy@fujitsu.com
Wed Nov 29 06:57:32 CET 2023


Hi

>Hi,

>> On 2023/11/2 16:05, Yang Xu wrote:
>> > * Simplify code and description
>> > * Use TST_macros

>> > Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
>> > ---
>> >   .../kernel/syscalls/pathconf/pathconf01.c     | 251 +++---------------
>> >   1 file changed, 33 insertions(+), 218 deletions(-)

>> > diff --git a/testcases/kernel/syscalls/pathconf/pathconf01.c b/testcases/kernel/syscalls/pathconf/pathconf01.c
>> > index 362bae94f..9b8b99d48 100644
>> > --- a/testcases/kernel/syscalls/pathconf/pathconf01.c
>> > +++ b/testcases/kernel/syscalls/pathconf/pathconf01.c
>> > @@ -1,237 +1,52 @@
>> > +// SPDX-License-Identifier: GPL-2.0-or-later
>Unfortunately GPL-2.0-only

>> >   /*
>> >    * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
>> > - *
>> > - * This program is free software; you can redistribute it and/or modify it
>> > - * under the terms of version 2 of the GNU General Public License as
>> > - * published by the Free Software Foundation.
>Because there is no "at any later version".

Yes,you are right.

...
>> > -   {
>> > -   "_PC_LINK_MAX", _PC_LINK_MAX}, {
>> > -   "_PC_NAME_MAX", _PC_NAME_MAX}, {
>> > -   "_PC_PATH_MAX", _PC_PATH_MAX}, {
>> > -   "_PC_PIPE_BUF", _PC_PIPE_BUF}, {
>> > -   "_PC_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED}, {
>> > -   "_PC_NO_TRUNC", _PC_NO_TRUNC}, {
>> > -   NULL, 0}
>> > +} tcases[] = {
>> > +   {"_PC_LINK_MAX", _PC_LINK_MAX},

>Please use this:
>#define NAME_DESC(x) x, #x

>} tcases[] = {
>        { NAME_DESC(_PC_NAME_MAX) },
>        { NAME_DESC(_PC_PATH_MAX) },
>        ...

OK. I'll modify it.

>> > +   {"_PC_NAME_MAX", _PC_NAME_MAX},
>> > +   {"_PC_PATH_MAX", _PC_PATH_MAX},
>> > +   {"_PC_PIPE_BUF", _PC_PIPE_BUF},
>> > +   {"_PC_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED},
>> > +   {"_PC_NO_TRUNC", _PC_NO_TRUNC},
>> > +   {NULL, 0},
>> Hi Yang,

>> What is the purpose of the last entry? IMO, it is equal to the first entry.
>> Other than that, it looks good to me.
>Very good question, I wonder as well.

The last entry really doesn't make any sense, I'll remove it.

>BTW there are many of others:
>https://www.gnu.org/software/libc/manual/html_node/Pathconf.html

I tried to add some macros and found that I had overlooked a judgment condition:

"If name corresponds to a maximum or minimum limit, and that
limit is indeterminate, -1 is returned and errno is not
changed.  (To distinguish an indeterminate limit from an
error, set errno to zero before the call, and then check
whether errno is nonzero when -1 is returned.)"

That seems to be very important in this case.

Best Regards,
Yang Xu

>Kind regards,
>Petr


More information about the ltp mailing list