Kernel: Add some implied auto qualifiers

This commit is contained in:
Hendiadyoin1 2021-12-29 01:01:27 +01:00 committed by Andreas Kling
parent 9346b9589f
commit 04d75f4ff9
Notes: sideshowbarker 2024-07-17 21:54:49 +09:00
11 changed files with 30 additions and 30 deletions

View file

@ -190,7 +190,7 @@ ErrorOr<void> Coredump::write_regions()
region->remap();
for (size_t i = 0; i < region->page_count(); i++) {
auto* page = region->physical_page(i);
auto const* page = region->physical_page(i);
auto src_buffer = [&]() -> ErrorOr<UserOrKernelBuffer> {
if (page)
return UserOrKernelBuffer::for_user_buffer(reinterpret_cast<uint8_t*>((region->vaddr().as_ptr() + (i * PAGE_SIZE))), PAGE_SIZE);
@ -223,13 +223,13 @@ ErrorOr<void> Coredump::create_notes_process_data(auto& builder) const
{
auto arguments_array = process_obj.add_array("arguments"sv);
for (auto& argument : m_process->arguments())
for (auto const& argument : m_process->arguments())
arguments_array.add(argument.view());
}
{
auto environment_array = process_obj.add_array("environment"sv);
for (auto& variable : m_process->environment())
for (auto const& variable : m_process->environment())
environment_array.add(variable.view());
}
}
@ -240,7 +240,7 @@ ErrorOr<void> Coredump::create_notes_process_data(auto& builder) const
ErrorOr<void> Coredump::create_notes_threads_data(auto& builder) const
{
for (auto& thread : m_process->threads_for_coredump({})) {
for (auto const& thread : m_process->threads_for_coredump({})) {
ELF::Core::ThreadInfo info {};
info.header.type = ELF::Core::NotesEntryHeader::Type::ThreadInfo;
info.tid = thread.tid().value();
@ -256,7 +256,7 @@ ErrorOr<void> Coredump::create_notes_threads_data(auto& builder) const
ErrorOr<void> Coredump::create_notes_regions_data(auto& builder) const
{
size_t region_index = 0;
for (auto& region : m_process->address_space().regions()) {
for (auto const& region : m_process->address_space().regions()) {
#if !INCLUDE_USERSPACE_HEAP_MEMORY_IN_COREDUMPS
if (looks_like_userspace_heap_region(*region))

View file

@ -937,7 +937,7 @@ ErrorOr<void> ProcFSRootDirectory::traverse_as_directory(FileSystemID fsid, Func
TRY(callback({ ".", { fsid, component_index() }, 0 }));
TRY(callback({ "..", { fsid, 0 }, 0 }));
for (auto& component : m_components) {
for (auto const& component : m_components) {
InodeIdentifier identifier = { fsid, component.component_index() };
TRY(callback({ component.name(), identifier, 0 }));
}

View file

@ -27,7 +27,7 @@ namespace Kernel {
void __panic(const char* file, unsigned int line, const char* function)
{
// Avoid lock ranking checks on crashing paths, just try to get some debugging messages out.
auto thread = Thread::current();
auto* thread = Thread::current();
if (thread)
thread->set_crashing();

View file

@ -86,7 +86,7 @@ ErrorOr<void> PerformanceEventBuffer::append_with_ip_and_bp(ProcessID pid, Threa
if ((g_profiling_event_mask & type) == 0)
return EINVAL;
auto current_thread = Thread::current();
auto* current_thread = Thread::current();
u32 enter_count = 0;
if (current_thread)
enter_count = current_thread->enter_profiler();
@ -191,7 +191,7 @@ ErrorOr<void> PerformanceEventBuffer::to_json_impl(Serializer& object) const
{
{
auto strings = object.add_array("strings");
for (auto& it : m_strings) {
for (auto const& it : m_strings) {
strings.add(it->view());
}
}
@ -332,7 +332,7 @@ void PerformanceEventBuffer::add_process(const Process& process, ProcessEventTyp
0, 0, PERF_EVENT_THREAD_CREATE, 0, 0, 0, nullptr);
});
for (auto& region : process.address_space().regions()) {
for (auto const& region : process.address_space().regions()) {
[[maybe_unused]] auto rc = append_with_ip_and_bp(process.pid(), 0,
0, 0, PERF_EVENT_MMAP, 0, region->range().base().get(), region->range().size(), region->name());
}

View file

@ -241,7 +241,7 @@ ErrorOr<void> ProcFSExposedDirectory::traverse_as_directory(FileSystemID fsid, F
TRY(callback({ ".", { fsid, component_index() }, DT_DIR }));
TRY(callback({ "..", { fsid, parent_directory->component_index() }, DT_DIR }));
for (auto& component : m_components) {
for (auto const& component : m_components) {
InodeIdentifier identifier = { fsid, component.component_index() };
TRY(callback({ component.name(), identifier, 0 }));
}

View file

@ -143,7 +143,7 @@ ErrorOr<void> Process::procfs_get_pledge_stats(KBufferBuilder& builder) const
ErrorOr<void> Process::procfs_get_unveil_stats(KBufferBuilder& builder) const
{
JsonArraySerializer array { builder };
for (auto& unveiled_path : unveiled_paths()) {
for (auto const& unveiled_path : unveiled_paths()) {
if (!unveiled_path.was_explicitly_unveiled())
continue;
auto obj = array.add_object();
@ -222,7 +222,7 @@ ErrorOr<void> Process::procfs_get_virtual_memory_stats(KBufferBuilder& builder)
JsonArraySerializer array { builder };
{
SpinlockLocker lock(address_space().get_lock());
for (auto& region : address_space().regions()) {
for (auto const& region : address_space().regions()) {
if (!region->is_user() && !Process::current().is_superuser())
continue;
auto region_object = array.add_object();
@ -247,7 +247,7 @@ ErrorOr<void> Process::procfs_get_virtual_memory_stats(KBufferBuilder& builder)
StringBuilder pagemap_builder;
for (size_t i = 0; i < region->page_count(); ++i) {
auto* page = region->physical_page(i);
auto const* page = region->physical_page(i);
if (!page)
pagemap_builder.append('N');
else if (page->is_shared_zero_page() || page->is_lazy_committed_page())
@ -276,7 +276,7 @@ mode_t Process::binary_link_required_mode() const
ErrorOr<void> Process::procfs_get_binary_link(KBufferBuilder& builder) const
{
auto* custody = executable();
auto const* custody = executable();
if (!custody)
return Error::from_errno(ENOEXEC);
return builder.append(custody->absolute_path().bytes());

View file

@ -22,14 +22,14 @@ void __sanitizer_cov_trace_pc(void)
return;
}
auto thread = Thread::current();
auto const* thread = Thread::current();
auto tid = thread->tid();
auto maybe_kcov_instance = KCOVDevice::thread_instance->get(tid);
if (!maybe_kcov_instance.has_value()) [[likely]] {
// not traced
return;
}
auto kcov_instance = maybe_kcov_instance.value();
auto* kcov_instance = maybe_kcov_instance.value();
if (kcov_instance->state() < KCOVInstance::TRACING) [[likely]]
return;
kcov_instance->buffer_add_pc((u64)__builtin_return_address(0));

View file

@ -247,7 +247,7 @@ bool Scheduler::yield()
{
InterruptDisabler disabler;
auto current_thread = Thread::current();
auto const* current_thread = Thread::current();
dbgln_if(SCHEDULER_DEBUG, "Scheduler[{}]: yielding thread {} in_irq={}", Processor::current_id(), *current_thread, Processor::current_in_irq());
VERIFY(current_thread != nullptr);
if (Processor::current_in_irq() || Processor::in_critical()) {
@ -274,7 +274,7 @@ bool Scheduler::context_switch(Thread* thread)
thread->did_schedule();
auto from_thread = Thread::current();
auto* from_thread = Thread::current();
if (from_thread == thread)
return false;
@ -457,7 +457,7 @@ void Scheduler::timer_tick(const RegisterState& regs)
VERIFY_INTERRUPTS_DISABLED();
VERIFY(Processor::current_in_irq());
auto current_thread = Processor::current_thread();
auto* current_thread = Processor::current_thread();
if (!current_thread)
return;

View file

@ -244,8 +244,8 @@ int strcmp(const char* s1, const char* s2)
int memcmp(const void* v1, const void* v2, size_t n)
{
auto* s1 = (const u8*)v1;
auto* s2 = (const u8*)v2;
auto const* s1 = (const u8*)v1;
auto const* s2 = (const u8*)v2;
while (n-- > 0) {
if (*s1++ != *s2++)
return s1[-1] < s2[-1] ? -1 : 1;

View file

@ -105,7 +105,7 @@ static const HandlerMetadata s_syscall_table[] = {
ErrorOr<FlatPtr> handle(RegisterState& regs, FlatPtr function, FlatPtr arg1, FlatPtr arg2, FlatPtr arg3, FlatPtr arg4)
{
VERIFY_INTERRUPTS_ENABLED();
auto current_thread = Thread::current();
auto* current_thread = Thread::current();
auto& process = current_thread->process();
current_thread->did_syscall();
@ -168,7 +168,7 @@ NEVER_INLINE void syscall_handler(TrapFrame* trap)
clac();
auto& regs = *trap->regs;
auto current_thread = Thread::current();
auto* current_thread = Thread::current();
VERIFY(current_thread->previous_mode() == Thread::PreviousMode::UserMode);
auto& process = current_thread->process();
if (process.is_dying()) {
@ -178,7 +178,7 @@ NEVER_INLINE void syscall_handler(TrapFrame* trap)
return;
}
if (auto tracer = process.tracer(); tracer && tracer->is_tracing_syscalls()) {
if (auto* tracer = process.tracer(); tracer && tracer->is_tracing_syscalls()) {
tracer->set_trace_syscalls(false);
process.tracer_trap(*current_thread, regs); // this triggers SIGTRAP and stops the thread!
}
@ -219,7 +219,7 @@ NEVER_INLINE void syscall_handler(TrapFrame* trap)
regs.set_return_reg(result.value());
}
if (auto tracer = process.tracer(); tracer && tracer->is_tracing_syscalls()) {
if (auto* tracer = process.tracer(); tracer && tracer->is_tracing_syscalls()) {
tracer->set_trace_syscalls(false);
process.tracer_trap(*current_thread, regs); // this triggers SIGTRAP and stops the thread!
}

View file

@ -270,9 +270,9 @@ Thread::WriteBlocker::WriteBlocker(OpenFileDescription& description, BlockFlags&
auto Thread::WriteBlocker::override_timeout(const BlockTimeout& timeout) -> const BlockTimeout&
{
auto& description = blocked_description();
auto const& description = blocked_description();
if (description.is_socket()) {
auto& socket = *description.socket();
auto const& socket = *description.socket();
if (socket.has_send_timeout()) {
Time send_timeout = socket.send_timeout();
m_timeout = BlockTimeout(false, &send_timeout, timeout.start_time(), timeout.clock_id());
@ -290,9 +290,9 @@ Thread::ReadBlocker::ReadBlocker(OpenFileDescription& description, BlockFlags& u
auto Thread::ReadBlocker::override_timeout(const BlockTimeout& timeout) -> const BlockTimeout&
{
auto& description = blocked_description();
auto const& description = blocked_description();
if (description.is_socket()) {
auto& socket = *description.socket();
auto const& socket = *description.socket();
if (socket.has_receive_timeout()) {
Time receive_timeout = socket.receive_timeout();
m_timeout = BlockTimeout(false, &receive_timeout, timeout.start_time(), timeout.clock_id());