]> xenbits.xensource.com Git - freebsd.git/commitdiff
fusefs: initialize C++ classes the Coverity way
authorasomers <asomers@FreeBSD.org>
Mon, 16 Sep 2019 15:56:21 +0000 (15:56 +0000)
committerasomers <asomers@FreeBSD.org>
Mon, 16 Sep 2019 15:56:21 +0000 (15:56 +0000)
Coverity complained that I wasn't initializing some class members until the
SetUp method.  Do it in the constructor instead.

Reported by: Coverity
Coverity CIDs: 14043521404378
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

tests/sys/fs/fusefs/io.cc
tests/sys/fs/fusefs/mknod.cc

index 135fc4c9194b05bef17b983be86738d8841a3f96..5fefdc5307d71c8ea644c06a0ef6817c19a6e014 100644 (file)
@@ -108,11 +108,11 @@ int m_backing_fd, m_control_fd, m_test_fd;
 off_t m_filesize;
 bool m_direct_io;
 
-Io(): m_backing_fd(-1), m_control_fd(-1), m_test_fd(-1), m_direct_io(false) {};
+Io(): m_backing_fd(-1), m_control_fd(-1), m_test_fd(-1), m_filesize(0),
+       m_direct_io(false) {};
 
 void SetUp()
 {
-       m_filesize = 0;
        m_backing_fd = open("backing_file", O_RDWR | O_CREAT | O_TRUNC, 0644);
        if (m_backing_fd < 0)
                FAIL() << strerror(errno);
index 53087b75d987209d885af2261b48ac2e2cac7c6a..5e16472cbe90635d95c1c59c726d39e1a55eb460 100644 (file)
@@ -55,8 +55,11 @@ const static mode_t c_umask = 022;
 
 public:
 
-virtual void SetUp() {
+Mknod() {
        m_oldmask = umask(c_umask);
+}
+
+virtual void SetUp() {
        if (geteuid() != 0) {
                GTEST_SKIP() << "Only root may use most mknod(2) variations";
        }