am ef607cda: Merge "Cleanup ftruncate negative test."
* commit 'ef607cdae24363c5e6b6fc72607a4cff78623851': Cleanup ftruncate negative test.
This commit is contained in:
commit
944d901cfd
@ -18,11 +18,14 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <unistd.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
|
// 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
|
// parameter, so it will not catch negative values. On the other hand
|
||||||
// ftruncate64 does check for this, so just forward the call.
|
// ftruncate64 does check for this, so just forward the call.
|
||||||
int ftruncate(int filedes, off_t length) {
|
int ftruncate(int filedes, off_t length) {
|
||||||
return ftruncate64(filedes, length);
|
return ftruncate64(filedes, length);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // !defined(__LP64__)
|
||||||
|
@ -179,10 +179,8 @@ TEST(unistd, ftruncate64) {
|
|||||||
TEST(unistd, ftruncate_negative) {
|
TEST(unistd, ftruncate_negative) {
|
||||||
TemporaryFile tf;
|
TemporaryFile tf;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
int rc = ftruncate(tf.fd, -123);
|
ASSERT_EQ(-1, ftruncate(tf.fd, -123));
|
||||||
int err = errno;
|
ASSERT_EQ(EINVAL, errno);
|
||||||
ASSERT_EQ(-1, rc);
|
|
||||||
ASSERT_EQ(EINVAL, err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool g_pause_test_flag = false;
|
static bool g_pause_test_flag = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user