summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/Ext2FileSystem.cpp
diff options
context:
space:
mode:
authorBrian Gianforcaro <b.gianfo@gmail.com>2021-02-21 02:16:16 -0800
committerAndreas Kling <kling@serenityos.org>2021-02-21 11:52:47 +0100
commitcbd8f78cceb55464534bd729a9290682af004eac (patch)
treee68098205f64ab7bb6f3ddd7a7b57955aa075108 /Kernel/FileSystem/Ext2FileSystem.cpp
parent7c950c2d0147b93adcca0c1cc10e9a0be09de1af (diff)
downloadserenity-cbd8f78cceb55464534bd729a9290682af004eac.zip
Kernel: Use uniform initialization instead of memset for a few stack buffer.
Raw memset is relatively easy to mess up, avoid it when there are better alternatives provided by the compiler in modern C++.
Diffstat (limited to 'Kernel/FileSystem/Ext2FileSystem.cpp')
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index 483f4ddc1f..0b6fb423e2 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -822,8 +822,7 @@ KResult Ext2FSInode::resize(u64 new_size)
// FIXME: There are definitely more efficient ways to achieve this.
size_t bytes_to_clear = new_size - old_size;
size_t clear_from = old_size;
- u8 zero_buffer[PAGE_SIZE];
- memset(zero_buffer, 0, sizeof(zero_buffer));
+ u8 zero_buffer[PAGE_SIZE] {};
while (bytes_to_clear) {
auto nwritten = write_bytes(clear_from, min(sizeof(zero_buffer), bytes_to_clear), UserOrKernelBuffer::for_kernel_buffer(zero_buffer), nullptr);
if (nwritten < 0)
@@ -1429,8 +1428,7 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(Ext2FSInode& parent_inode,
struct timeval now;
kgettimeofday(now);
- ext2_inode e2inode;
- memset(&e2inode, 0, sizeof(ext2_inode));
+ ext2_inode e2inode {};
e2inode.i_mode = mode;
e2inode.i_uid = uid;
e2inode.i_gid = gid;