Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109686843
D21457.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
13 KB
Referenced Files
None
Subscribers
None
D21457.diff
View Options
Index: head/tests/sys/fs/fusefs/allow_other.cc
===================================================================
--- head/tests/sys/fs/fusefs/allow_other.cc
+++ head/tests/sys/fs/fusefs/allow_other.cc
@@ -255,6 +255,8 @@
}
);
ASSERT_EQ(0, WEXITSTATUS(status));
+
+ leak(dfd);
}
/*
Index: head/tests/sys/fs/fusefs/bmap.cc
===================================================================
--- head/tests/sys/fs/fusefs/bmap.cc
+++ head/tests/sys/fs/fusefs/bmap.cc
@@ -158,4 +158,6 @@
EXPECT_EQ(arg.bn, lbn * m_maxbcachebuf / DEV_BSIZE);
EXPECT_EQ(arg.runp, 0);
EXPECT_EQ(arg.runb, m_maxphys / m_maxbcachebuf - 1);
+
+ leak(fd);
}
Index: head/tests/sys/fs/fusefs/default_permissions.cc
===================================================================
--- head/tests/sys/fs/fusefs/default_permissions.cc
+++ head/tests/sys/fs/fusefs/default_permissions.cc
@@ -503,7 +503,7 @@
EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH)
.WillOnce(Invoke(ReturnErrno(ENOENT)));
- EXPECT_EQ(-1, open(FULLPATH, O_CREAT | O_EXCL, 0644));
+ ASSERT_EQ(-1, open(FULLPATH, O_CREAT | O_EXCL, 0644));
EXPECT_EQ(EACCES, errno);
}
Index: head/tests/sys/fs/fusefs/dev_fuse_poll.cc
===================================================================
--- head/tests/sys/fs/fusefs/dev_fuse_poll.cc
+++ head/tests/sys/fs/fusefs/dev_fuse_poll.cc
@@ -107,13 +107,12 @@
struct stat sb;
name = (const char*)arg;
- stat(name, &sb);
- return 0;
+ return ((void*)(intptr_t)stat(name, &sb));
}
/*
* A kevent's data field should contain the number of operations available to
- * be immediately rea.
+ * be immediately read.
*/
TEST_F(Kqueue, data)
{
@@ -124,6 +123,7 @@
uint64_t bar_ino = 43;
uint64_t baz_ino = 44;
Sequence seq;
+ void *th_ret;
ASSERT_EQ(0, sem_init(&sem0, 0, 0)) << strerror(errno);
ASSERT_EQ(0, sem_init(&sem1, 0, 0)) << strerror(errno);
@@ -216,9 +216,12 @@
nap(); // Allow th1 and th2 to send their ops to the daemon
EXPECT_EQ(0, sem_post(&sem1)) << strerror(errno);
- pthread_join(th0, NULL);
- pthread_join(th1, NULL);
- pthread_join(th2, NULL);
+ pthread_join(th0, &th_ret);
+ ASSERT_EQ(-1, (intptr_t)th_ret);
+ pthread_join(th1, &th_ret);
+ ASSERT_EQ(-1, (intptr_t)th_ret);
+ pthread_join(th2, &th_ret);
+ ASSERT_EQ(-1, (intptr_t)th_ret);
EXPECT_EQ(1, nready0);
EXPECT_EQ(2, nready1);
Index: head/tests/sys/fs/fusefs/fifo.cc
===================================================================
--- head/tests/sys/fs/fusefs/fifo.cc
+++ head/tests/sys/fs/fusefs/fifo.cc
@@ -124,6 +124,7 @@
}
sa.sun_family = AF_UNIX;
strlcpy(sa.sun_path, FULLPATH, sizeof(sa.sun_path));
+ sa.sun_len = sizeof(FULLPATH);
err = connect(fd, (struct sockaddr*)&sa, sizeof(sa));
if (err < 0) {
perror("connect");
@@ -140,6 +141,8 @@
sent += r;
}
+
+ FuseTest::leak(fd);
return 0;
}
@@ -189,6 +192,7 @@
ASSERT_LE(0, fd) << strerror(errno);
sa.sun_family = AF_UNIX;
strlcpy(sa.sun_path, FULLPATH, sizeof(sa.sun_path));
+ sa.sun_len = sizeof(FULLPATH);
ASSERT_EQ(0, bind(fd, (struct sockaddr*)&sa, sizeof(sa)))
<< strerror(errno);
listen(fd, 5);
Index: head/tests/sys/fs/fusefs/interrupt.cc
===================================================================
--- head/tests/sys/fs/fusefs/interrupt.cc
+++ head/tests/sys/fs/fusefs/interrupt.cc
@@ -466,6 +466,8 @@
EXPECT_EQ(0, (intptr_t)thr0_value);
sem_destroy(&sem1);
sem_destroy(&sem0);
+
+ leak(fd1);
}
/*
@@ -536,6 +538,8 @@
EXPECT_EQ(0, (intptr_t)thr0_value);
sem_destroy(&sem1);
sem_destroy(&sem0);
+
+ leak(fd1);
}
/*
@@ -611,6 +615,8 @@
setup_interruptor(self);
ASSERT_EQ(-1, read(fd, buf, bufsize));
EXPECT_EQ(EINTR, errno);
+
+ leak(fd);
}
/*
Index: head/tests/sys/fs/fusefs/io.cc
===================================================================
--- head/tests/sys/fs/fusefs/io.cc
+++ head/tests/sys/fs/fusefs/io.cc
@@ -108,7 +108,7 @@
off_t m_filesize;
bool m_direct_io;
-Io(): m_backing_fd(-1), m_control_fd(-1), m_direct_io(false) {};
+Io(): m_backing_fd(-1), m_control_fd(-1), m_test_fd(-1), m_direct_io(false) {};
void SetUp()
{
Index: head/tests/sys/fs/fusefs/mknod.cc
===================================================================
--- head/tests/sys/fs/fusefs/mknod.cc
+++ head/tests/sys/fs/fusefs/mknod.cc
@@ -214,8 +214,11 @@
ASSERT_LE(0, fd) << strerror(errno);
sa.sun_family = AF_UNIX;
strlcpy(sa.sun_path, FULLPATH, sizeof(sa.sun_path));
+ sa.sun_len = sizeof(FULLPATH);
ASSERT_EQ(0, bind(fd, (struct sockaddr*)&sa, sizeof(sa)))
<< strerror(errno);
+
+ leak(fd);
}
/*
Index: head/tests/sys/fs/fusefs/mockfs.cc
===================================================================
--- head/tests/sys/fs/fusefs/mockfs.cc
+++ head/tests/sys/fs/fusefs/mockfs.cc
@@ -833,8 +833,8 @@
res = read(m_fuse_fd, &in, sizeof(in));
if (res < 0 && !m_quit) {
- FAIL() << "read: " << strerror(errno);
m_quit = true;
+ FAIL() << "read: " << strerror(errno);
}
ASSERT_TRUE(res >= static_cast<ssize_t>(sizeof(in.header)) || m_quit);
/*
Index: head/tests/sys/fs/fusefs/notify.cc
===================================================================
--- head/tests/sys/fs/fusefs/notify.cc
+++ head/tests/sys/fs/fusefs/notify.cc
@@ -465,6 +465,7 @@
/* Fill the data cache */
fd = open(FULLPATH, O_RDWR);
+ ASSERT_LE(0, fd);
ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno);
expect_write(ino, 0, bufsize, CONTENTS);
@@ -526,6 +527,7 @@
/* Fill the data cache */
fd = open(FULLPATH, O_RDWR);
+ ASSERT_LE(0, fd) << strerror(errno);
ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno);
/* Evict the attributes, but not data cache */
Index: head/tests/sys/fs/fusefs/open.cc
===================================================================
--- head/tests/sys/fs/fusefs/open.cc
+++ head/tests/sys/fs/fusefs/open.cc
@@ -114,7 +114,7 @@
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnErrno(ENOENT)));
- EXPECT_NE(0, open(FULLPATH, O_RDONLY));
+ ASSERT_EQ(-1, open(FULLPATH, O_RDONLY));
EXPECT_EQ(ENOENT, errno);
}
@@ -136,7 +136,7 @@
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnErrno(EPERM)));
- EXPECT_NE(0, open(FULLPATH, O_RDONLY));
+ ASSERT_EQ(-1, open(FULLPATH, O_RDONLY));
EXPECT_EQ(EPERM, errno);
}
Index: head/tests/sys/fs/fusefs/opendir.cc
===================================================================
--- head/tests/sys/fs/fusefs/opendir.cc
+++ head/tests/sys/fs/fusefs/opendir.cc
@@ -86,7 +86,7 @@
expect_lookup(RELPATH, ino);
expect_opendir(ino, O_RDONLY, ReturnErrno(ENOENT));
- EXPECT_NE(0, open(FULLPATH, O_DIRECTORY));
+ ASSERT_EQ(-1, open(FULLPATH, O_DIRECTORY));
EXPECT_EQ(ENOENT, errno);
}
@@ -112,6 +112,7 @@
const char FULLPATH[] = "mountpoint/some_dir";
const char RELPATH[] = "some_dir";
uint64_t ino = 42;
+ int fd;
expect_lookup(RELPATH, ino);
expect_opendir(ino, O_RDONLY,
@@ -119,7 +120,10 @@
SET_OUT_HEADER_LEN(out, open);
}));
- EXPECT_LE(0, open(FULLPATH, O_DIRECTORY)) << strerror(errno);
+ fd = open(FULLPATH, O_DIRECTORY);
+ EXPECT_LE(0, fd) << strerror(errno);
+
+ leak(fd);
}
/* Directories can be opened O_EXEC for stuff like fchdir(2) */
@@ -138,6 +142,8 @@
fd = open(FULLPATH, O_EXEC | O_DIRECTORY);
ASSERT_LE(0, fd) << strerror(errno);
+
+ leak(fd);
}
TEST_F(Opendir, opendir)
Index: head/tests/sys/fs/fusefs/read.cc
===================================================================
--- head/tests/sys/fs/fusefs/read.cc
+++ head/tests/sys/fs/fusefs/read.cc
@@ -113,7 +113,7 @@
uint64_t ino = 42;
int fd;
ssize_t bufsize = strlen(CONTENTS);
- char buf[bufsize];
+ uint8_t buf[bufsize];
struct aiocb iocb, *piocb;
expect_lookup(RELPATH, ino, bufsize);
@@ -327,7 +327,7 @@
int fd;
uint64_t offset = 100;
ssize_t bufsize = strlen(CONTENTS);
- char buf[bufsize];
+ uint8_t buf[bufsize];
expect_lookup(RELPATH, ino, offset + bufsize);
expect_open(ino, FOPEN_DIRECT_IO, 1);
@@ -361,7 +361,7 @@
uint64_t offset = 100;
ssize_t bufsize = strlen(CONTENTS);
ssize_t halfbufsize = bufsize / 2;
- char buf[bufsize];
+ uint8_t buf[bufsize];
expect_lookup(RELPATH, ino, offset + bufsize);
expect_open(ino, FOPEN_DIRECT_IO, 1);
@@ -384,7 +384,7 @@
uint64_t ino = 42;
int fd;
ssize_t bufsize = strlen(CONTENTS);
- char buf[bufsize];
+ uint8_t buf[bufsize];
expect_lookup(RELPATH, ino, bufsize);
expect_open(ino, 0, 1);
@@ -419,7 +419,7 @@
ssize_t bufsize = strlen(CONTENTS);
ssize_t partbufsize = 3 * bufsize / 4;
ssize_t r;
- char buf[bufsize];
+ uint8_t buf[bufsize];
struct stat sb;
expect_lookup(RELPATH, ino, offset + bufsize);
@@ -448,7 +448,7 @@
int fd;
ssize_t bufsize = strlen(CONTENTS);
off_t old_filesize = m_maxbcachebuf * 2 + bufsize;
- char buf[bufsize];
+ uint8_t buf[bufsize];
struct stat sb;
expect_lookup(RELPATH, ino, old_filesize);
@@ -483,7 +483,7 @@
uint64_t ino = 42;
int fd0, fd1;
ssize_t bufsize = strlen(CONTENTS);
- char buf[bufsize];
+ uint8_t buf[bufsize];
FuseTest::expect_lookup(RELPATH, ino, S_IFREG | 0644, bufsize, 2);
expect_open(ino, FOPEN_KEEP_CACHE, 2);
@@ -518,7 +518,7 @@
uint64_t ino = 42;
int fd0, fd1;
ssize_t bufsize = strlen(CONTENTS);
- char buf[bufsize];
+ uint8_t buf[bufsize];
FuseTest::expect_lookup(RELPATH, ino, S_IFREG | 0644, bufsize, 2);
expect_open(ino, 0, 2);
@@ -646,7 +646,7 @@
uint64_t ino = 42;
int fd;
ssize_t bufsize = strlen(CONTENTS);
- char buf[bufsize];
+ uint8_t buf[bufsize];
expect_lookup(RELPATH, ino, bufsize);
expect_open(ino, 0, 1);
@@ -682,7 +682,7 @@
*/
uint64_t offset = m_maxbcachebuf;
ssize_t bufsize = strlen(CONTENTS);
- char buf[bufsize];
+ uint8_t buf[bufsize];
expect_lookup(RELPATH, ino, offset + bufsize);
expect_open(ino, 0, 1);
@@ -704,7 +704,7 @@
uint64_t ino = 42;
int fd;
ssize_t bufsize = strlen(CONTENTS);
- char buf[bufsize];
+ uint8_t buf[bufsize];
expect_lookup(RELPATH, ino, bufsize);
expect_open(ino, 0, 1);
@@ -727,7 +727,7 @@
uint64_t ino = 42;
int fd;
ssize_t bufsize = strlen(CONTENTS);
- char buf[bufsize];
+ uint8_t buf[bufsize];
expect_lookup(RELPATH, ino, bufsize);
expect_open(ino, 0, 1);
@@ -789,7 +789,7 @@
uint64_t ino = 42;
int fd;
size_t bufsize = strlen(CONTENTS);
- char buf[bufsize];
+ uint8_t buf[bufsize];
int sp[2];
off_t sbytes;
Index: head/tests/sys/fs/fusefs/release.cc
===================================================================
--- head/tests/sys/fs/fusefs/release.cc
+++ head/tests/sys/fs/fusefs/release.cc
@@ -90,6 +90,7 @@
EXPECT_LE(0, fd) << strerror(errno);
fd2 = dup(fd);
+ ASSERT_LE(0, fd2) << strerror(errno);
ASSERT_EQ(0, close(fd2)) << strerror(errno);
ASSERT_EQ(0, close(fd)) << strerror(errno);
Index: head/tests/sys/fs/fusefs/setattr.cc
===================================================================
--- head/tests/sys/fs/fusefs/setattr.cc
+++ head/tests/sys/fs/fusefs/setattr.cc
@@ -548,6 +548,8 @@
free(r1buf);
free(r0buf);
free(w0buf);
+
+ leak(fd);
}
/* Change a file's timestamps */
Index: head/tests/sys/fs/fusefs/utils.hh
===================================================================
--- head/tests/sys/fs/fusefs/utils.hh
+++ head/tests/sys/fs/fusefs/utils.hh
@@ -83,7 +83,9 @@
m_async(false),
m_noclusterr(false),
m_nointr(false),
- m_time_gran(1)
+ m_time_gran(1),
+ m_maxbcachebuf(0),
+ m_maxphys(0)
{}
virtual void SetUp();
Index: head/tests/sys/fs/fusefs/utils.cc
===================================================================
--- head/tests/sys/fs/fusefs/utils.cc
+++ head/tests/sys/fs/fusefs/utils.cc
@@ -83,8 +83,9 @@
GTEST_SKIP() << strerror(errno);
}
}
- sysctlbyname(usermount_node, &usermount_val, &usermount_size,
- NULL, 0);
+ ASSERT_EQ(sysctlbyname(usermount_node, &usermount_val, &usermount_size,
+ NULL, 0),
+ 0);;
if (geteuid() != 0 && !usermount_val)
GTEST_SKIP() << "current user is not allowed to mount";
}
Index: head/tests/sys/fs/fusefs/write.cc
===================================================================
--- head/tests/sys/fs/fusefs/write.cc
+++ head/tests/sys/fs/fusefs/write.cc
@@ -183,7 +183,7 @@
public:
virtual void SetUp() {
m_async = true;
- m_maxwrite = m_maxphys;
+ m_maxwrite = 1 << 25; // Anything larger than MAXPHYS will suffice
WriteBack::SetUp();
if (m_maxphys < 2 * DFLTPHYS)
GTEST_SKIP() << "MAXPHYS must be at least twice DFLTPHYS"
@@ -563,6 +563,8 @@
free(expected);
free(zeros);
+
+ leak(fd);
}
TEST_F(Write, pwrite)
@@ -614,6 +616,8 @@
EXPECT_EQ(sb0.st_atime, sb1.st_atime);
EXPECT_NE(sb0.st_mtime, sb1.st_mtime);
EXPECT_NE(sb0.st_ctime, sb1.st_ctime);
+
+ leak(fd);
}
TEST_F(Write, write)
@@ -863,7 +867,7 @@
uint64_t ino = 42;
int fd;
ssize_t bufsize = strlen(CONTENTS);
- char readbuf[bufsize];
+ uint8_t readbuf[bufsize];
expect_lookup(RELPATH, ino, 0);
expect_open(ino, 0, 1);
@@ -895,7 +899,7 @@
uint64_t ino = 42;
int fd;
ssize_t bufsize = strlen(CONTENTS);
- char readbuf[bufsize];
+ uint8_t readbuf[bufsize];
expect_lookup(RELPATH, ino, 0);
expect_open(ino, 0, 1);
@@ -942,6 +946,7 @@
ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno);
/* Don't close the file because that would flush the cache */
+ leak(fd);
}
/*
@@ -1175,6 +1180,8 @@
EXPECT_EQ((time_t)server_time, sb.st_atime);
EXPECT_NE((time_t)server_time, sb.st_mtime);
EXPECT_NE((time_t)server_time, sb.st_ctime);
+
+ leak(fd);
}
/* Any dirty timestamp fields should be flushed during a SETATTR */
@@ -1208,6 +1215,8 @@
EXPECT_LE(0, fd) << strerror(errno);
ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno);
ASSERT_EQ(0, fchmod(fd, newmode)) << strerror(errno);
+
+ leak(fd);
}
/* fuse_init_out.time_gran controls the granularity of timestamps */
@@ -1243,6 +1252,8 @@
EXPECT_LE(0, fd) << strerror(errno);
ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno);
ASSERT_EQ(0, fchmod(fd, newmode)) << strerror(errno);
+
+ leak(fd);
}
INSTANTIATE_TEST_CASE_P(RA, TimeGran, Range(0u, 10u));
@@ -1258,7 +1269,7 @@
uint64_t ino = 42;
int fd;
ssize_t bufsize = strlen(CONTENTS);
- char readbuf[bufsize];
+ uint8_t readbuf[bufsize];
expect_lookup(RELPATH, ino, 0);
expect_open(ino, 0, 1);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 9, 8:46 AM (20 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16549423
Default Alt Text
D21457.diff (13 KB)
Attached To
Mode
D21457: fusefs: coverity cleanup in the tests
Attached
Detach File
Event Timeline
Log In to Comment