summaryrefslogtreecommitdiff
path: root/Kernel/init.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-12 21:07:52 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-12 21:28:55 +0200
commitfdfda6dec20101013bb33633e657f06ef2a1ea96 (patch)
tree2157f8281cd9bc33a6984455c4831c397d2bd30c /Kernel/init.cpp
parent15f4043a7a80f52c0fa05c4e69771e758464cd20 (diff)
downloadserenity-fdfda6dec20101013bb33633e657f06ef2a1ea96.zip
AK: Make string-to-number conversion helpers return Optional
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
Diffstat (limited to 'Kernel/init.cpp')
-rw-r--r--Kernel/init.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index 0dacc83a6a..7e9006d8cd 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -251,10 +251,9 @@ void init_stage2()
root = root.substring(strlen("/dev/hda"), root.length() - strlen("/dev/hda"));
if (root.length()) {
- bool ok;
- unsigned partition_number = root.to_uint(ok);
+ auto partition_number = root.to_uint();
- if (!ok) {
+ if (!partition_number.has_value()) {
klog() << "init_stage2: couldn't parse partition number from root kernel parameter";
hang();
}
@@ -273,9 +272,9 @@ void init_stage2()
klog() << "init_stage2: couldn't read GPT from disk";
hang();
}
- auto partition = gpt.partition(partition_number);
+ auto partition = gpt.partition(partition_number.value());
if (!partition) {
- klog() << "init_stage2: couldn't get partition " << partition_number;
+ klog() << "init_stage2: couldn't get partition " << partition_number.value();
hang();
}
root_dev = *partition;
@@ -287,20 +286,20 @@ void init_stage2()
klog() << "init_stage2: couldn't read EBR from disk";
hang();
}
- auto partition = ebr.partition(partition_number);
+ auto partition = ebr.partition(partition_number.value());
if (!partition) {
- klog() << "init_stage2: couldn't get partition " << partition_number;
+ klog() << "init_stage2: couldn't get partition " << partition_number.value();
hang();
}
root_dev = *partition;
} else {
- if (partition_number < 1 || partition_number > 4) {
- klog() << "init_stage2: invalid partition number " << partition_number << "; expected 1 to 4";
+ if (partition_number.value() < 1 || partition_number.value() > 4) {
+ klog() << "init_stage2: invalid partition number " << partition_number.value() << "; expected 1 to 4";
hang();
}
- auto partition = mbr.partition(partition_number);
+ auto partition = mbr.partition(partition_number.value());
if (!partition) {
- klog() << "init_stage2: couldn't get partition " << partition_number;
+ klog() << "init_stage2: couldn't get partition " << partition_number.value();
hang();
}
root_dev = *partition;