From 2165a359fd1ba85294f99e7f8799c11b2a1540a3 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 12 Jan 2016 00:02:56 +0000 Subject: [PATCH] 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. --- configure.ac | 3 ++- tests/struct_flock.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 1524b9b6..42a6accd 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # # Copyright (c) 1999-2001 Wichert Akkerman # Copyright (c) 2002-2009 Roland McGrath -# Copyright (c) 2006-2015 Dmitry V. Levin +# Copyright (c) 2006-2016 Dmitry V. Levin # Copyright (c) 2008-2015 Mike Frysinger # Copyright (c) 2015 Elvira Khabirova # 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 diff --git a/tests/struct_flock.c b/tests/struct_flock.c index 0acba90c..e514c99f 100644 --- a/tests/struct_flock.c +++ b/tests/struct_flock.c @@ -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" -- 2.40.0