[PATCH v3] tests/fcntl-common.c: extend coverage for other fcntl flags
Dmitry V. Levin
ldv at altlinux.org
Wed Jul 11 16:13:43 UTC 2018
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 --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180711/0d64adea/attachment.bin>
More information about the Strace-devel
mailing list