Skip to content

Commit

Permalink
Kernel: Use default constructors/destructors
Browse files Browse the repository at this point in the history
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
  • Loading branch information
ldm5180 authored and bgianfo committed Mar 17, 2022
1 parent 68f75ab commit 190cf15
Show file tree
Hide file tree
Showing 79 changed files with 102 additions and 309 deletions.
9 changes: 2 additions & 7 deletions Kernel/Arch/aarch64/ScopedCritical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@

namespace Kernel {

ScopedCritical::ScopedCritical()
{
}

ScopedCritical::~ScopedCritical()
{
}
ScopedCritical::ScopedCritical() = default;
ScopedCritical::~ScopedCritical() = default;

ScopedCritical::ScopedCritical(ScopedCritical&& /*from*/)
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Arch/aarch64/SmapDisabler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ SmapDisabler::SmapDisabler()
{
}

SmapDisabler::~SmapDisabler()
{
}
SmapDisabler::~SmapDisabler() = default;

}
4 changes: 1 addition & 3 deletions Kernel/Bus/USB/SysFSUSB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ SysFSUSBDeviceInformation::SysFSUSBDeviceInformation(NonnullOwnPtr<KString> devi
{
}

SysFSUSBDeviceInformation::~SysFSUSBDeviceInformation()
{
}
SysFSUSBDeviceInformation::~SysFSUSBDeviceInformation() = default;

ErrorOr<void> SysFSUSBDeviceInformation::try_generate(KBufferBuilder& builder)
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Bus/USB/UHCI/UHCIController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ UNMAP_AFTER_INIT UHCIController::UHCIController(PCI::DeviceIdentifier const& pci
{
}

UNMAP_AFTER_INIT UHCIController::~UHCIController()
{
}
UNMAP_AFTER_INIT UHCIController::~UHCIController() = default;

ErrorOr<void> UHCIController::reset()
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Bus/USB/USBDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ Device::Device(Device const& device, NonnullOwnPtr<Pipe> default_pipe)
{
}

Device::~Device()
{
}
Device::~Device() = default;

ErrorOr<void> Device::enumerate_device()
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Bus/USB/USBTransfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ Transfer::Transfer(Pipe& pipe, u16 len, NonnullOwnPtr<Memory::Region> data_buffe
{
}

Transfer::~Transfer()
{
}
Transfer::~Transfer() = default;

void Transfer::set_setup_packet(const USBRequestData& request)
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Bus/VirtIO/Queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ Queue::Queue(NonnullOwnPtr<Memory::Region> queue_region, u16 queue_size, u16 not
enable_interrupts();
}

Queue::~Queue()
{
}
Queue::~Queue() = default;

void Queue::enable_interrupts()
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/Audio/AC97.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ UNMAP_AFTER_INIT AC97::AC97(PCI::DeviceIdentifier const& pci_device_identifier)
{
}

UNMAP_AFTER_INIT AC97::~AC97()
{
}
UNMAP_AFTER_INIT AC97::~AC97() = default;

bool AC97::handle_irq(RegisterState const&)
{
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Devices/Audio/Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AudioChannel final

public:
static NonnullRefPtr<AudioChannel> must_create(AudioController const&, size_t channel_index);
virtual ~AudioChannel() override { }
virtual ~AudioChannel() override = default;

// ^CharacterDevice
virtual bool can_read(const OpenFileDescription&, u64) const override;
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/BlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ void AsyncBlockDeviceRequest::start()
m_block_device.start_request(*this);
}

BlockDevice::~BlockDevice()
{
}
BlockDevice::~BlockDevice() = default;

bool BlockDevice::read_block(u64 index, UserOrKernelBuffer& buffer)
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/CharacterDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

namespace Kernel {

CharacterDevice::~CharacterDevice()
{
}
CharacterDevice::~CharacterDevice() = default;

}
4 changes: 1 addition & 3 deletions Kernel/Devices/ConsoleDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ UNMAP_AFTER_INIT ConsoleDevice::ConsoleDevice()
{
}

UNMAP_AFTER_INIT ConsoleDevice::~ConsoleDevice()
{
}
UNMAP_AFTER_INIT ConsoleDevice::~ConsoleDevice() = default;

bool ConsoleDevice::can_read(const Kernel::OpenFileDescription&, u64) const
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/DeviceControlDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ UNMAP_AFTER_INIT DeviceControlDevice::DeviceControlDevice()
{
}

UNMAP_AFTER_INIT DeviceControlDevice::~DeviceControlDevice()
{
}
UNMAP_AFTER_INIT DeviceControlDevice::~DeviceControlDevice() = default;

ErrorOr<size_t> DeviceControlDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer& buffer, size_t size)
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/FullDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ UNMAP_AFTER_INIT FullDevice::FullDevice()
{
}

UNMAP_AFTER_INIT FullDevice::~FullDevice()
{
}
UNMAP_AFTER_INIT FullDevice::~FullDevice() = default;

bool FullDevice::can_read(const OpenFileDescription&, u64) const
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/HID/KeyboardDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,7 @@ UNMAP_AFTER_INIT KeyboardDevice::KeyboardDevice()

// FIXME: UNMAP_AFTER_INIT is fine for now, but for hot-pluggable devices
// like USB keyboards, we need to remove this
UNMAP_AFTER_INIT KeyboardDevice::~KeyboardDevice()
{
}
UNMAP_AFTER_INIT KeyboardDevice::~KeyboardDevice() = default;

bool KeyboardDevice::can_read(const OpenFileDescription&, u64) const
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/HID/MouseDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ MouseDevice::MouseDevice()
{
}

MouseDevice::~MouseDevice()
{
}
MouseDevice::~MouseDevice() = default;

bool MouseDevice::can_read(const OpenFileDescription&, u64) const
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/HID/PS2KeyboardDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ UNMAP_AFTER_INIT PS2KeyboardDevice::PS2KeyboardDevice(const I8042Controller& ps2

// FIXME: UNMAP_AFTER_INIT might not be correct, because in practice PS/2 devices
// are hot pluggable.
UNMAP_AFTER_INIT PS2KeyboardDevice::~PS2KeyboardDevice()
{
}
UNMAP_AFTER_INIT PS2KeyboardDevice::~PS2KeyboardDevice() = default;

}
4 changes: 1 addition & 3 deletions Kernel/Devices/HID/PS2MouseDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ UNMAP_AFTER_INIT PS2MouseDevice::PS2MouseDevice(const I8042Controller& ps2_contr
{
}

UNMAP_AFTER_INIT PS2MouseDevice::~PS2MouseDevice()
{
}
UNMAP_AFTER_INIT PS2MouseDevice::~PS2MouseDevice() = default;

bool PS2MouseDevice::handle_irq(const RegisterState&)
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/HID/VMWareMouseDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ VMWareMouseDevice::VMWareMouseDevice(const I8042Controller& ps2_controller)
: PS2MouseDevice(ps2_controller)
{
}
VMWareMouseDevice::~VMWareMouseDevice()
{
}
VMWareMouseDevice::~VMWareMouseDevice() = default;

}
4 changes: 1 addition & 3 deletions Kernel/Devices/MemoryDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ UNMAP_AFTER_INIT MemoryDevice::MemoryDevice()
{
}

UNMAP_AFTER_INIT MemoryDevice::~MemoryDevice()
{
}
UNMAP_AFTER_INIT MemoryDevice::~MemoryDevice() = default;

ErrorOr<size_t> MemoryDevice::read(OpenFileDescription&, u64 offset, UserOrKernelBuffer& buffer, size_t length)
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/NullDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ UNMAP_AFTER_INIT NullDevice::NullDevice()
{
}

UNMAP_AFTER_INIT NullDevice::~NullDevice()
{
}
UNMAP_AFTER_INIT NullDevice::~NullDevice() = default;

bool NullDevice::can_read(const OpenFileDescription&, u64) const
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/RandomDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ UNMAP_AFTER_INIT RandomDevice::RandomDevice()
{
}

UNMAP_AFTER_INIT RandomDevice::~RandomDevice()
{
}
UNMAP_AFTER_INIT RandomDevice::~RandomDevice() = default;

bool RandomDevice::can_read(const OpenFileDescription&, u64) const
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/SerialDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ UNMAP_AFTER_INIT SerialDevice::SerialDevice(IOAddress base_addr, unsigned minor)
initialize();
}

UNMAP_AFTER_INIT SerialDevice::~SerialDevice()
{
}
UNMAP_AFTER_INIT SerialDevice::~SerialDevice() = default;

bool SerialDevice::can_read(const OpenFileDescription&, u64) const
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/ZeroDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ UNMAP_AFTER_INIT ZeroDevice::ZeroDevice()
{
}

UNMAP_AFTER_INIT ZeroDevice::~ZeroDevice()
{
}
UNMAP_AFTER_INIT ZeroDevice::~ZeroDevice() = default;

bool ZeroDevice::can_read(const OpenFileDescription&, u64) const
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/FileSystem/AnonymousFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ AnonymousFile::AnonymousFile(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
{
}

AnonymousFile::~AnonymousFile()
{
}
AnonymousFile::~AnonymousFile() = default;

ErrorOr<Memory::Region*> AnonymousFile::mmap(Process& process, OpenFileDescription&, Memory::VirtualRange const& range, u64 offset, int prot, bool shared)
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/FileSystem/BlockBasedFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ BlockBasedFileSystem::BlockBasedFileSystem(OpenFileDescription& file_description
VERIFY(file_description.file().is_seekable());
}

BlockBasedFileSystem::~BlockBasedFileSystem()
{
}
BlockBasedFileSystem::~BlockBasedFileSystem() = default;

ErrorOr<void> BlockBasedFileSystem::initialize()
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/FileSystem/Custody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ Custody::Custody(Custody* parent, NonnullOwnPtr<KString> name, Inode& inode, int
{
}

Custody::~Custody()
{
}
Custody::~Custody() = default;

ErrorOr<NonnullOwnPtr<KString>> Custody::try_serialize_absolute_path() const
{
Expand Down
13 changes: 3 additions & 10 deletions Kernel/FileSystem/DevPtsFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ ErrorOr<NonnullRefPtr<DevPtsFS>> DevPtsFS::try_create()
return adopt_nonnull_ref_or_enomem(new (nothrow) DevPtsFS);
}

DevPtsFS::DevPtsFS()
{
}

DevPtsFS::~DevPtsFS()
{
}
DevPtsFS::DevPtsFS() = default;
DevPtsFS::~DevPtsFS() = default;

ErrorOr<void> DevPtsFS::initialize()
{
Expand Down Expand Up @@ -81,9 +76,7 @@ DevPtsFSInode::DevPtsFSInode(DevPtsFS& fs, InodeIndex index, SlavePTY* pty)
m_pty = *pty;
}

DevPtsFSInode::~DevPtsFSInode()
{
}
DevPtsFSInode::~DevPtsFSInode() = default;

ErrorOr<size_t> DevPtsFSInode::read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const
{
Expand Down
24 changes: 6 additions & 18 deletions Kernel/FileSystem/DevTmpFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ ErrorOr<NonnullRefPtr<DevTmpFS>> DevTmpFS::try_create()
return adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFS);
}

DevTmpFS::DevTmpFS()
{
}
DevTmpFS::DevTmpFS() = default;

size_t DevTmpFS::allocate_inode_index()
{
Expand All @@ -28,9 +26,7 @@ size_t DevTmpFS::allocate_inode_index()
return 1 + m_next_inode_index.value();
}

DevTmpFS::~DevTmpFS()
{
}
DevTmpFS::~DevTmpFS() = default;

ErrorOr<void> DevTmpFS::initialize()
{
Expand Down Expand Up @@ -167,9 +163,7 @@ StringView DevTmpFSLinkInode::name() const
return m_name->view();
}

DevTmpFSLinkInode::~DevTmpFSLinkInode()
{
}
DevTmpFSLinkInode::~DevTmpFSLinkInode() = default;

DevTmpFSLinkInode::DevTmpFSLinkInode(DevTmpFS& fs, NonnullOwnPtr<KString> name)
: DevTmpFSInode(fs)
Expand Down Expand Up @@ -206,9 +200,7 @@ DevTmpFSDirectoryInode::DevTmpFSDirectoryInode(DevTmpFS& fs, NonnullOwnPtr<KStri
, m_name(move(name))
{
}
DevTmpFSDirectoryInode::~DevTmpFSDirectoryInode()
{
}
DevTmpFSDirectoryInode::~DevTmpFSDirectoryInode() = default;

ErrorOr<void> DevTmpFSDirectoryInode::traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)> callback) const
{
Expand Down Expand Up @@ -286,9 +278,7 @@ DevTmpFSRootDirectoryInode::DevTmpFSRootDirectoryInode(DevTmpFS& fs)
{
m_mode = 0555;
}
DevTmpFSRootDirectoryInode::~DevTmpFSRootDirectoryInode()
{
}
DevTmpFSRootDirectoryInode::~DevTmpFSRootDirectoryInode() = default;
ErrorOr<void> DevTmpFSRootDirectoryInode::chmod(mode_t)
{
return EPERM;
Expand All @@ -306,9 +296,7 @@ DevTmpFSDeviceInode::DevTmpFSDeviceInode(DevTmpFS& fs, MajorNumber major_number,
{
}

DevTmpFSDeviceInode::~DevTmpFSDeviceInode()
{
}
DevTmpFSDeviceInode::~DevTmpFSDeviceInode() = default;

StringView DevTmpFSDeviceInode::name() const
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/FileSystem/Ext2FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ Ext2FS::Ext2FS(OpenFileDescription& file_description)
{
}

Ext2FS::~Ext2FS()
{
}
Ext2FS::~Ext2FS() = default;

ErrorOr<void> Ext2FS::flush_super_block()
{
Expand Down
Loading

0 comments on commit 190cf15

Please sign in to comment.