diff --git a/libc/bionic/ftruncate.cpp b/libc/bionic/ftruncate.cpp index c073f2d43c86695fc33558b3d8b0c57b0d9a3658..9936df0426418b96a9e47c3b87a4e0301e28167b 100644 --- a/libc/bionic/ftruncate.cpp +++ b/libc/bionic/ftruncate.cpp @@ -18,11 +18,14 @@ #include <sys/cdefs.h> #include <unistd.h> -#if !defined(__USE_FILE_OFFSET64) && !defined(__LP64__) +#if !defined(__LP64__) +static_assert(sizeof(off_t) == 4, + "libc can't be built with _FILE_OFFSET_BITS=64."); + // The kernel's implementation of ftruncate uses an unsigned long for the length // parameter, so it will not catch negative values. On the other hand // ftruncate64 does check for this, so just forward the call. int ftruncate(int filedes, off_t length) { return ftruncate64(filedes, length); } -#endif +#endif // !defined(__LP64__) diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp index a21578a899750b5f1938093a7d54127cb44da6ff..79c16d7eb882552667169f6ed2b86249d5b0c3c2 100644 --- a/tests/unistd_test.cpp +++ b/tests/unistd_test.cpp @@ -179,10 +179,8 @@ TEST(unistd, ftruncate64) { TEST(unistd, ftruncate_negative) { TemporaryFile tf; errno = 0; - int rc = ftruncate(tf.fd, -123); - int err = errno; - ASSERT_EQ(-1, rc); - ASSERT_EQ(EINVAL, err); + ASSERT_EQ(-1, ftruncate(tf.fd, -123)); + ASSERT_EQ(EINVAL, errno); } static bool g_pause_test_flag = false;