1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:18:12 +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:
Nicholas Baron 2021-05-16 02:36:52 -07:00 committed by GitHub
parent bbaa463032
commit aa4d41fe2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 311 additions and 127 deletions

View file

@ -93,7 +93,6 @@ const DynamicObject& DynamicLoader::dynamic_object() const
if (program_header.type() == PT_DYNAMIC) {
dynamic_section_address = VirtualAddress(program_header.raw_data());
}
return IterationDecision::Continue;
});
VERIFY(!dynamic_section_address.is_null());
@ -109,7 +108,6 @@ size_t DynamicLoader::calculate_tls_size() const
if (program_header.type() == PT_TLS) {
tls_size = program_header.size_in_memory();
}
return IterationDecision::Continue;
});
return tls_size;
}
@ -194,7 +192,6 @@ void DynamicLoader::do_main_relocations()
case RelocationResult::Success:
break;
}
return IterationDecision::Continue;
};
m_dynamic_object->relocation_section().for_each_relocation(do_single_relocation);
m_dynamic_object->plt_relocation_section().for_each_relocation(do_single_relocation);
@ -273,7 +270,6 @@ void DynamicLoader::load_program_headers()
VERIFY(!relro_region.has_value());
relro_region = region;
}
return IterationDecision::Continue;
});
VERIFY(!text_regions.is_empty() || !data_regions.is_empty());