From 1235dca15fb62be4357e9e6d78a0d8751ea173b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20L=C3=A4nd?= Date: Tue, 29 Oct 2024 03:24:23 +0000 Subject: [PATCH] Bug 1901996: apply code formatting via Lando # ignore-this-changeset --- ipc/glue/SharedMemory_posix.cpp | 11 +++++------ ipc/gtest/TestSharedMemory.cpp | 15 +++++---------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/ipc/glue/SharedMemory_posix.cpp b/ipc/glue/SharedMemory_posix.cpp index 8f98c1962d28..da279f469237 100644 --- a/ipc/glue/SharedMemory_posix.cpp +++ b/ipc/glue/SharedMemory_posix.cpp @@ -177,19 +177,18 @@ static Maybe HaveMemfd() { #ifdef USE_MEMFD_CREATE static const Maybe kHave = []() -> Maybe { unsigned flags = MFD_CLOEXEC | MFD_ALLOW_SEALING; -#ifdef MFD_NOEXEC_SEAL +# ifdef MFD_NOEXEC_SEAL flags |= MFD_NOEXEC_SEAL; -#endif +# endif - mozilla::UniqueFileHandle fd( - memfd_create("mozilla-ipc-test", flags)); + mozilla::UniqueFileHandle fd(memfd_create("mozilla-ipc-test", flags)); -#ifdef MFD_NOEXEC_SEAL +# ifdef MFD_NOEXEC_SEAL if (!fd && errno == EINVAL) { flags &= ~MFD_NOEXEC_SEAL; fd.reset(memfd_create("mozilla-ipc-test", flags)); } -#endif +# endif if (!fd) { DCHECK_EQ(errno, ENOSYS); diff --git a/ipc/gtest/TestSharedMemory.cpp b/ipc/gtest/TestSharedMemory.cpp index 07d793f4307e..2f1d9cbc1214 100644 --- a/ipc/gtest/TestSharedMemory.cpp +++ b/ipc/gtest/TestSharedMemory.cpp @@ -298,6 +298,7 @@ TEST(IPCSharedMemory, BasicIsZero) class IPCSharedMemoryLinuxTest : public ::testing::Test { int mMajor = 0; int mMinor = 0; + protected: void SetUp() override { if (mMajor != 0) { @@ -313,21 +314,16 @@ class IPCSharedMemoryLinuxTest : public ::testing::Test { return mMajor > aMajor || (mMajor == aMajor && mMinor >= aMinor); } - bool ShouldHaveMemfd() { - return HaveKernelVersion(3, 17); - } + bool ShouldHaveMemfd() { return HaveKernelVersion(3, 17); } - bool ShouldHaveMemfdNoExec() { - return HaveKernelVersion(6, 3); - } + bool ShouldHaveMemfdNoExec() { return HaveKernelVersion(6, 3); } }; // Test that memfd_create is used where expected. // // More precisely: if memfd_create support is expected, verify that // shared memory isn't subject to a filesystem size limit. -TEST_F(IPCSharedMemoryLinuxTest, IsMemfd) -{ +TEST_F(IPCSharedMemoryLinuxTest, IsMemfd) { auto shm = MakeRefPtr(); ASSERT_TRUE(shm->Create(1)); UniqueFileHandle fd = shm->TakeHandleAndUnmap(); @@ -347,8 +343,7 @@ TEST_F(IPCSharedMemoryLinuxTest, IsMemfd) } } -TEST_F(IPCSharedMemoryLinuxTest, MemfdNoExec) -{ +TEST_F(IPCSharedMemoryLinuxTest, MemfdNoExec) { const bool expectExec = ShouldHaveMemfd() && !ShouldHaveMemfdNoExec(); auto shm = MakeRefPtr();