Bug 1901996: apply code formatting via Lando

# ignore-this-changeset
This commit is contained in:
Otto Länd 2024-10-29 03:24:23 +00:00
parent c8f1c7016f
commit 1235dca15f
2 changed files with 10 additions and 16 deletions

View File

@ -177,19 +177,18 @@ static Maybe<unsigned> HaveMemfd() {
#ifdef USE_MEMFD_CREATE
static const Maybe<unsigned> kHave = []() -> Maybe<unsigned> {
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);

View File

@ -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<ipc::SharedMemory>();
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<ipc::SharedMemory>();