[PATCH v3] tests/fcntl-common.c: extend coverage for other fcntl flags

Zhibin Li 08826794brmt at gmail.com
Wed Jul 11 17:26:34 UTC 2018


I should've taken that into consideration. I didn't because I get used to
check all those headers in /usr/include in my native env (fc27.x86_64). I
am aware now and will be careful from now on (check all those macros and
values directly from linux.git).


On Thu, Jul 12, 2018 at 1:17 AM Zhibin Li <08826794brmt at gmail.com> wrote:

> Oh, my bad. I didn't realize that. I should really use those macros
> directly.
>
> On Thu, Jul 12, 2018 at 12:13 AM Dmitry V. Levin <ldv at altlinux.org> wrote:
>
>> On Wed, Jul 11, 2018 at 05:51:10PM +0800, Zhibin Li wrote:
>> > * tests/fcntl-common.c: Include <assert.h>.
>> > (fcntl_cmd_check): New structure.
>> > (print_retval_flags, test_other_set_cmd, test_other_get_cmd,
>> > print_flags_getfd, print_flags_getsig, print_flags_getlease,
>> > test_fcntl_others): New functions.
>> > (main): Use test_fcntl_others.
>> [...]
>> > +static void
>> > +print_flags_getlease(long rc)
>> > +{
>> > +     assert(rc >= 0);
>> > +     const char *text;
>> > +
>> > +     switch (rc) {
>> > +     case 0:
>> > +             text = "F_RDLCK";
>> > +             break;
>> > +     case 1:
>> > +             text = "F_WRLCK";
>> > +             break;
>> > +     case 2:
>> > +             text = "F_UNLCK";
>> > +             break;
>>
>> Why do you want to use numbers here?
>> This approach wouldn't work well across architectures:
>>
>> $ git grep -Fw F_UNLCK include/uapi/ arch/*/include/uapi/
>> arch/alpha/include/uapi/asm/fcntl.h:#define F_UNLCK             8
>> arch/parisc/include/uapi/asm/fcntl.h:#define F_UNLCK            03
>> arch/sparc/include/uapi/asm/fcntl.h:#define F_UNLCK             3
>> include/uapi/asm-generic/fcntl.h:#define F_UNLCK                2
>>
>>
>> --
>> ldv
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180712/1274b00f/attachment.html>


More information about the Strace-devel mailing list