mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
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++.
This commit is contained in:
parent
7c950c2d01
commit
cbd8f78cce
Notes:
sideshowbarker
2024-07-18 22:03:48 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/cbd8f78cceb Pull-request: https://github.com/SerenityOS/serenity/pull/5449 Reviewed-by: https://github.com/awesomekling
|
@ -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;
|
||||
|
|
|
@ -390,8 +390,7 @@ void kgettimeofday(timeval& tv)
|
|||
|
||||
siginfo_t Process::wait_info()
|
||||
{
|
||||
siginfo_t siginfo;
|
||||
memset(&siginfo, 0, sizeof(siginfo));
|
||||
siginfo_t siginfo {};
|
||||
siginfo.si_signo = SIGCHLD;
|
||||
siginfo.si_pid = pid().value();
|
||||
siginfo.si_uid = uid();
|
||||
|
|
|
@ -739,11 +739,10 @@ bool Thread::WaitBlocker::unblock(Process& process, UnblockFlags flags, u8 signa
|
|||
// more than once!
|
||||
do_set_result(process.wait_info());
|
||||
} else {
|
||||
siginfo_t siginfo;
|
||||
memset(&siginfo, 0, sizeof(siginfo));
|
||||
siginfo_t siginfo {};
|
||||
{
|
||||
ScopedSpinLock lock(g_scheduler_lock);
|
||||
// We need to gather the information before we release the sheduler lock!
|
||||
// We need to gather the information before we release the scheduler lock!
|
||||
siginfo.si_signo = SIGCHLD;
|
||||
siginfo.si_pid = process.pid().value();
|
||||
siginfo.si_uid = process.uid();
|
||||
|
|
Loading…
Reference in a new issue