1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:37:43 +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:
Daniel Bertalan 2023-04-24 20:14:44 +02:00 committed by Andreas Kling
parent c911fb0150
commit 6aa392f6e4
4 changed files with 10 additions and 14 deletions

View file

@ -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()