mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +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
3 changed files with 5 additions and 9 deletions
|
@ -822,8 +822,7 @@ KResult Ext2FSInode::resize(u64 new_size)
|
||||||
// FIXME: There are definitely more efficient ways to achieve this.
|
// FIXME: There are definitely more efficient ways to achieve this.
|
||||||
size_t bytes_to_clear = new_size - old_size;
|
size_t bytes_to_clear = new_size - old_size;
|
||||||
size_t clear_from = old_size;
|
size_t clear_from = old_size;
|
||||||
u8 zero_buffer[PAGE_SIZE];
|
u8 zero_buffer[PAGE_SIZE] {};
|
||||||
memset(zero_buffer, 0, sizeof(zero_buffer));
|
|
||||||
while (bytes_to_clear) {
|
while (bytes_to_clear) {
|
||||||
auto nwritten = write_bytes(clear_from, min(sizeof(zero_buffer), bytes_to_clear), UserOrKernelBuffer::for_kernel_buffer(zero_buffer), nullptr);
|
auto nwritten = write_bytes(clear_from, min(sizeof(zero_buffer), bytes_to_clear), UserOrKernelBuffer::for_kernel_buffer(zero_buffer), nullptr);
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
|
@ -1429,8 +1428,7 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(Ext2FSInode& parent_inode,
|
||||||
|
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
kgettimeofday(now);
|
kgettimeofday(now);
|
||||||
ext2_inode e2inode;
|
ext2_inode e2inode {};
|
||||||
memset(&e2inode, 0, sizeof(ext2_inode));
|
|
||||||
e2inode.i_mode = mode;
|
e2inode.i_mode = mode;
|
||||||
e2inode.i_uid = uid;
|
e2inode.i_uid = uid;
|
||||||
e2inode.i_gid = gid;
|
e2inode.i_gid = gid;
|
||||||
|
|
|
@ -390,8 +390,7 @@ void kgettimeofday(timeval& tv)
|
||||||
|
|
||||||
siginfo_t Process::wait_info()
|
siginfo_t Process::wait_info()
|
||||||
{
|
{
|
||||||
siginfo_t siginfo;
|
siginfo_t siginfo {};
|
||||||
memset(&siginfo, 0, sizeof(siginfo));
|
|
||||||
siginfo.si_signo = SIGCHLD;
|
siginfo.si_signo = SIGCHLD;
|
||||||
siginfo.si_pid = pid().value();
|
siginfo.si_pid = pid().value();
|
||||||
siginfo.si_uid = uid();
|
siginfo.si_uid = uid();
|
||||||
|
|
|
@ -739,11 +739,10 @@ bool Thread::WaitBlocker::unblock(Process& process, UnblockFlags flags, u8 signa
|
||||||
// more than once!
|
// more than once!
|
||||||
do_set_result(process.wait_info());
|
do_set_result(process.wait_info());
|
||||||
} else {
|
} else {
|
||||||
siginfo_t siginfo;
|
siginfo_t siginfo {};
|
||||||
memset(&siginfo, 0, sizeof(siginfo));
|
|
||||||
{
|
{
|
||||||
ScopedSpinLock lock(g_scheduler_lock);
|
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_signo = SIGCHLD;
|
||||||
siginfo.si_pid = process.pid().value();
|
siginfo.si_pid = process.pid().value();
|
||||||
siginfo.si_uid = process.uid();
|
siginfo.si_uid = process.uid();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue