fix: strcmp protection with NULL args
This commit is contained in:
parent
0bcc99997a
commit
f65d5ce418
@ -4,6 +4,8 @@ int strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
if (!s1 || !s2)
|
||||
return -1;
|
||||
while (s1[i] == s2[i] && s1[i] != '\0')
|
||||
i++;
|
||||
return s1[i] - s2[i];
|
||||
|
@ -1,10 +1,9 @@
|
||||
#include "kprintf.h"
|
||||
#include "string.h"
|
||||
#include "terminal.h"
|
||||
#include "utils.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define ARRAY_SIZE(array) sizeof(array) / sizeof(array[0])
|
||||
|
||||
void color_cmd(char *arg)
|
||||
{
|
||||
uint8_t tmp_color;
|
||||
@ -21,16 +20,14 @@ void color_cmd(char *arg)
|
||||
}
|
||||
}
|
||||
tmp_color = terminal_get_default_color();
|
||||
kprintf(KERN_WARNING "Invalid argument\navailable color: ");
|
||||
kprintf(KERN_WARNING "Invalid argument\n");
|
||||
kprintf("Available colors: ");
|
||||
for (size_t i = 0; i < ARRAY_SIZE(colors); i++) {
|
||||
terminal_set_default_fg_color(i);
|
||||
// Unai the STRING MERGE argument of kprintf cause me a
|
||||
// cramptissue. I lost all my skibidi aura to fix it but it work
|
||||
// (;
|
||||
kprintf(colors[i]);
|
||||
if (i != ARRAY_SIZE(colors) - 1)
|
||||
kprintf(", ");
|
||||
}
|
||||
terminal_set_default_fg_color(tmp_color);
|
||||
kprintf("\n");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user