tests/struct_flock.c: fix musl libc compilation warnings
The size of off_t is not something one can rely upon. For example, musl libc unconditionally defines it as an int64_t type on x86. A cast to the target type helps to avoid these libc differences. * configure.ac: Call AC_C_TYPEOF. * tests/struct_flock.c (TYPEOF_FLOCK_OFF_T): New macro. (test_flock_einval): Use it instead of off_t.
This commit is contained in:
parent
4776e3366f
commit
2165a359fd
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Copyright (c) 1999-2001 Wichert Akkerman <wichert@deephackmode.org>
|
||||
# Copyright (c) 2002-2009 Roland McGrath <roland@redhat.com>
|
||||
# Copyright (c) 2006-2015 Dmitry V. Levin <ldv@altlinux.org>
|
||||
# Copyright (c) 2006-2016 Dmitry V. Levin <ldv@altlinux.org>
|
||||
# Copyright (c) 2008-2015 Mike Frysinger <vapier@gentoo.org>
|
||||
# Copyright (c) 2015 Elvira Khabirova <lineprinter0@gmail.com>
|
||||
# All rights reserved.
|
||||
@ -251,6 +251,7 @@ AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
AC_C_CONST
|
||||
AC_C_BIGENDIAN
|
||||
AC_C_TYPEOF
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_STDBOOL
|
||||
AC_HEADER_DIRENT
|
||||
|
@ -45,13 +45,19 @@
|
||||
|
||||
#define TEST_FLOCK_EINVAL(cmd) test_flock_einval(cmd, #cmd)
|
||||
|
||||
#ifdef HAVE_TYPEOF
|
||||
# define TYPEOF_FLOCK_OFF_T typeof(((struct_kernel_flock *) NULL)->l_len)
|
||||
#else
|
||||
# define TYPEOF_FLOCK_OFF_T off_t
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_flock_einval(const int cmd, const char *name)
|
||||
{
|
||||
struct_kernel_flock fl = {
|
||||
.l_type = F_RDLCK,
|
||||
.l_start = (off_t) 0xdefaced1facefeed,
|
||||
.l_len = (off_t) 0xdefaced2cafef00d
|
||||
.l_start = (TYPEOF_FLOCK_OFF_T) 0xdefaced1facefeed,
|
||||
.l_len = (TYPEOF_FLOCK_OFF_T) 0xdefaced2cafef00d
|
||||
};
|
||||
syscall(TEST_SYSCALL_NR, 0, cmd, &fl);
|
||||
printf("%s(0, %s, {l_type=F_RDLCK, l_whence=SEEK_SET"
|
||||
|
Loading…
x
Reference in New Issue
Block a user