mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
Kernel: Store the kernel command line in a StringView
The Raspberry Pi's mailbox interface does not guarantee that the returned command line is null-terminated. This commit removes that assumption from the current code, allowing the next commit to add support for reading it on the Pi. This also lets us eliminate a few manual `strlen()` calls :^)
This commit is contained in:
parent
c911fb0150
commit
6aa392f6e4
4 changed files with 10 additions and 14 deletions
|
@ -16,15 +16,9 @@ static char s_cmd_line[1024];
|
|||
static constexpr StringView s_embedded_cmd_line = ""sv;
|
||||
static CommandLine* s_the;
|
||||
|
||||
UNMAP_AFTER_INIT void CommandLine::early_initialize(char const* cmd_line)
|
||||
UNMAP_AFTER_INIT void CommandLine::early_initialize(StringView cmd_line)
|
||||
{
|
||||
if (!cmd_line)
|
||||
return;
|
||||
size_t length = strlen(cmd_line);
|
||||
if (length >= sizeof(s_cmd_line))
|
||||
length = sizeof(s_cmd_line) - 1;
|
||||
memcpy(s_cmd_line, cmd_line, length);
|
||||
s_cmd_line[length] = '\0';
|
||||
(void)cmd_line.copy_characters_to_buffer(s_cmd_line, sizeof(s_cmd_line));
|
||||
}
|
||||
|
||||
bool CommandLine::was_initialized()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue