git: 3f83f32d7d07 - main - fusefs: minor refactor in the tests

From: Alan Somers <asomers_at_FreeBSD.org>
Date: Tue, 24 Dec 2024 21:56:13 UTC
The branch main has been updated by asomers:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f83f32d7d07afbb2dbff63fc6ec520f3341eec7

commit 3f83f32d7d07afbb2dbff63fc6ec520f3341eec7
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2024-12-24 21:54:42 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2024-12-24 21:55:48 +0000

    fusefs: minor refactor in the tests
    
    Do more work in MockFS's constructor's member initializer list, instead
    of the body of the constructor.  It's easier to read this way.
    
    Sponsored by:   ConnectWise
---
 tests/sys/fs/fusefs/mockfs.cc | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/tests/sys/fs/fusefs/mockfs.cc b/tests/sys/fs/fusefs/mockfs.cc
index 023cecd0276f..502f22a1e980 100644
--- a/tests/sys/fs/fusefs/mockfs.cc
+++ b/tests/sys/fs/fusefs/mockfs.cc
@@ -421,7 +421,18 @@ MockFS::MockFS(int max_readahead, bool allow_other, bool default_permissions,
 	uint32_t kernel_minor_version, uint32_t max_write, bool async,
 	bool noclusterr, unsigned time_gran, bool nointr, bool noatime,
 	const char *fsname, const char *subtype)
-	: m_uniques(new std::unordered_set<uint64_t>)
+	: m_daemon_id(NULL),
+	  m_kernel_minor_version(kernel_minor_version),
+	  m_kq(pm == KQ ? kqueue() : -1),
+	  m_maxreadahead(max_readahead),
+	  m_pid(getpid()),
+	  m_uniques(new std::unordered_set<uint64_t>),
+	  m_pm(pm),
+	  m_time_gran(time_gran),
+	  m_child_pid(-1),
+	  m_maxwrite(MIN(max_write, max_max_write)),
+	  m_nready(-1),
+	  m_quit(false)
 {
 	struct sigaction sa;
 	struct iovec *iov = NULL;
@@ -429,20 +440,6 @@ MockFS::MockFS(int max_readahead, bool allow_other, bool default_permissions,
 	char fdstr[15];
 	const bool trueval = true;
 
-	m_daemon_id = NULL;
-	m_kernel_minor_version = kernel_minor_version;
-	m_maxreadahead = max_readahead;
-	m_maxwrite = MIN(max_write, max_max_write);
-	m_nready = -1;
-	m_pm = pm;
-	m_time_gran = time_gran;
-	m_quit = false;
-
-	if (m_pm == KQ)
-		m_kq = kqueue();
-	else
-		m_kq = -1;
-
 	/*
 	 * Kyua sets pwd to a testcase-unique tempdir; no need to use
 	 * mkdtemp
@@ -467,9 +464,6 @@ MockFS::MockFS(int max_readahead, bool allow_other, bool default_permissions,
 		throw(std::system_error(errno, std::system_category(),
 			"Couldn't open /dev/fuse"));
 
-	m_pid = getpid();
-	m_child_pid = -1;
-
 	build_iovec(&iov, &iovlen, "fstype", __DECONST(void *, "fusefs"), -1);
 	build_iovec(&iov, &iovlen, "fspath",
 		    __DECONST(void *, "mountpoint"), -1);