summaryrefslogtreecommitdiff
path: root/Userland/disasm.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-10 15:55:54 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-10 16:49:13 +0100
commit2f3b901f7fe230cbbf489f5a0f38fbb34a07af8c (patch)
treeceff5568f544c8bc2ef10857a914c17044863339 /Userland/disasm.cpp
parent70fce5c4c7279c045e593a8a3a6f79ebc28e2972 (diff)
downloadserenity-2f3b901f7fe230cbbf489f5a0f38fbb34a07af8c.zip
AK: Make MappedFile heap-allocated and ref-counted
Let's adapt this class a bit better to how it's actually being used. Instead of having valid/invalid states and storing an error in case it's invalid, a MappedFile is now always valid, and the factory function that creates it will return an OSError if mapping fails.
Diffstat (limited to 'Userland/disasm.cpp')
-rw-r--r--Userland/disasm.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/Userland/disasm.cpp b/Userland/disasm.cpp
index 4189499000..781caf0796 100644
--- a/Userland/disasm.cpp
+++ b/Userland/disasm.cpp
@@ -48,12 +48,14 @@ int main(int argc, char** argv)
args_parser.add_positional_argument(path, "Path to i386 binary file", "path");
args_parser.parse(argc, argv);
- MappedFile file(path);
- if (!file.is_valid()) {
- // Already printed some error message.
+ auto file_or_error = MappedFile::map(path);
+ if (file_or_error.is_error()) {
+ warnln("Could not map file: {}", file_or_error.error().string());
return 1;
}
+ auto& file = *file_or_error.value();
+
struct Symbol {
size_t value;
size_t size;