mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:27:35 +00:00
AK+Kernel+LibELF: Remove the need for IteratorDecision::Continue
By constraining two implementations, the compiler will select the best fitting one. All this will require is duplicating the implementation and simplifying for the `void` case. This constraining also informs both the caller and compiler by passing the callback parameter types as part of the constraint (e.g.: `IterationFunction<int>`). Some `for_each` functions in LibELF only take functions which return `void`. This is a minimal correctness check, as it removes one way for a function to incompletely do something. There seems to be a possible idiom where inside a lambda, a `return;` is the same as `continue;` in a for-loop.
This commit is contained in:
parent
bbaa463032
commit
aa4d41fe2c
25 changed files with 311 additions and 127 deletions
|
@ -172,7 +172,7 @@ static KResultOr<RequiredLoadRange> get_required_load_range(FileDescription& pro
|
|||
RequiredLoadRange range {};
|
||||
elf_image.for_each_program_header([&range](const auto& pheader) {
|
||||
if (pheader.type() != PT_LOAD)
|
||||
return IterationDecision::Continue;
|
||||
return;
|
||||
|
||||
auto region_start = (FlatPtr)pheader.vaddr().as_ptr();
|
||||
auto region_end = region_start + pheader.size_in_memory();
|
||||
|
@ -180,7 +180,6 @@ static KResultOr<RequiredLoadRange> get_required_load_range(FileDescription& pro
|
|||
range.start = region_start;
|
||||
if (range.end == 0 || region_end > range.end)
|
||||
range.end = region_end;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
VERIFY(range.end > range.start);
|
||||
|
|
|
@ -47,8 +47,6 @@ KResult Process::do_killpg(ProcessGroupID pgrp, int signal)
|
|||
any_succeeded = true;
|
||||
else
|
||||
error = res;
|
||||
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
if (group_was_empty)
|
||||
|
|
|
@ -51,18 +51,18 @@ KResultOr<int> Process::sys$module_load(Userspace<const char*> user_path, size_t
|
|||
|
||||
elf_image->for_each_section_of_type(SHT_PROGBITS, [&](const ELF::Image::Section& section) {
|
||||
if (!section.size())
|
||||
return IterationDecision::Continue;
|
||||
return;
|
||||
auto section_storage = KBuffer::copy(section.raw_data(), section.size(), Region::Access::Read | Region::Access::Write | Region::Access::Execute);
|
||||
section_storage_by_name.set(section.name(), section_storage.data());
|
||||
module->sections.append(move(section_storage));
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
bool missing_symbols = false;
|
||||
|
||||
elf_image->for_each_section_of_type(SHT_PROGBITS, [&](const ELF::Image::Section& section) {
|
||||
if (!section.size())
|
||||
return IterationDecision::Continue;
|
||||
return;
|
||||
|
||||
auto* section_storage = section_storage_by_name.get(section.name()).value_or(nullptr);
|
||||
VERIFY(section_storage);
|
||||
auto relocations = section.relocations();
|
||||
|
@ -103,10 +103,7 @@ KResultOr<int> Process::sys$module_load(Userspace<const char*> user_path, size_t
|
|||
}
|
||||
break;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
if (missing_symbols)
|
||||
|
@ -129,7 +126,6 @@ KResultOr<int> Process::sys$module_load(Userspace<const char*> user_path, size_t
|
|||
if (storage)
|
||||
module->name = String((const char*)(storage + symbol.value()));
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
if (!module->module_init)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue