]> granicus.if.org Git - strace/commitdiff
tests/struct_flock.c: fix musl libc compilation warnings
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 12 Jan 2016 00:02:56 +0000 (00:02 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 12 Jan 2016 03:07:38 +0000 (03:07 +0000)
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.

configure.ac
tests/struct_flock.c

index 1524b9b6b6cfb1f810768035faf8bae9672396a4..42a6accda9e4ac5f085ea35cc4a542f089303143 100644 (file)
@@ -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
index 0acba90c65e906afb79a53e3ac89816d6fb1848c..e514c99fd37ddea7baf16a38777cefc29fdf219c 100644 (file)
 
 #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"