|
21 | 21 | #include <iostream> |
22 | 22 |
|
23 | 23 | #include <errno.h> |
24 | | -#include <stdio.h> |
25 | | -#include <stdlib.h> |
| 24 | +#include <cstdio> |
| 25 | +#include <cstdlib> |
26 | 26 | #include <sys/stat.h> |
| 27 | +#include <cassert> |
27 | 28 |
|
28 | 29 | #include "../api/boot/multiboot.h" |
29 | | -#include <gsl/gsl> |
30 | 30 | #include "elf.h" |
31 | 31 | #include "elf_binary.hpp" |
32 | 32 |
|
@@ -72,7 +72,7 @@ string get_bootloader_path(int argc, char** argv) { |
72 | 72 | int main(int argc, char** argv) { |
73 | 73 |
|
74 | 74 | // Verify proper command usage |
75 | | - if (argc < 2) { |
| 75 | + if (argc <= 2) { |
76 | 76 | cout << info << usage; |
77 | 77 | exit(EXIT_FAILURE); |
78 | 78 | } |
@@ -127,7 +127,7 @@ int main(int argc, char** argv) { |
127 | 127 |
|
128 | 128 | const decltype(binary_sectors) img_size_sect {1 + binary_sectors}; |
129 | 129 | const decltype(binary_sectors) img_size_bytes {img_size_sect * SECT_SIZE}; |
130 | | - Expects((img_size_bytes & (SECT_SIZE-1)) == 0); |
| 130 | + assert((img_size_bytes & (SECT_SIZE-1)) == 0); |
131 | 131 |
|
132 | 132 | INFO("Total disk size: \t%ld bytes, => %ld sectors", |
133 | 133 | img_size_bytes, img_size_sect); |
@@ -175,14 +175,17 @@ int main(int argc, char** argv) { |
175 | 175 |
|
176 | 176 | INFO("Verifying multiboot header:"); |
177 | 177 | INFO("Magic value: 0x%x\n" , multiboot.magic); |
178 | | - Expects(multiboot.magic == MULTIBOOT_HEADER_MAGIC); |
| 178 | + if (multiboot.magic != MULTIBOOT_HEADER_MAGIC) { |
| 179 | + printf("Multiboot magic mismatch: 0x%08x vs %#x\n", multiboot.magic, MULTIBOOT_HEADER_MAGIC); |
| 180 | + } |
| 181 | + assert(multiboot.magic == MULTIBOOT_HEADER_MAGIC); |
179 | 182 |
|
180 | 183 | INFO("Flags: 0x%x" , multiboot.flags); |
181 | 184 | INFO("Checksum: 0x%x" , multiboot.checksum); |
182 | 185 | INFO("Checksum computed: 0x%x", multiboot.checksum + multiboot.flags + multiboot.magic); |
183 | 186 |
|
184 | 187 | // Verify multiboot header checksum |
185 | | - Expects(multiboot.checksum + multiboot.flags + multiboot.magic == 0); |
| 188 | + assert(multiboot.checksum + multiboot.flags + multiboot.magic == 0); |
186 | 189 |
|
187 | 190 | INFO("Header addr: 0x%x" , multiboot.header_addr); |
188 | 191 | INFO("Load start: 0x%x" , multiboot.load_addr); |
|
0 commit comments