From dc9f9f55cb6b38b87d8c228ae9abb4b53ebfb25c Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 15 Mar 2021 22:54:54 +0100 Subject: System hardening and errno impl --- kernel/drivers/fb.c | 2 +- kernel/drivers/keyboard.c | 7 ++++--- kernel/drivers/mouse.c | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'kernel/drivers') diff --git a/kernel/drivers/fb.c b/kernel/drivers/fb.c index 8e73f5b..af8a830 100644 --- a/kernel/drivers/fb.c +++ b/kernel/drivers/fb.c @@ -45,7 +45,7 @@ static s32 fb_ioctl(u32 request, void *arg1, void *arg2, void *arg3, struct devi } } -static u8 fb_ready(void) +static s32 fb_ready(void) { return 1; } diff --git a/kernel/drivers/keyboard.c b/kernel/drivers/keyboard.c index dbee8e1..79cd579 100644 --- a/kernel/drivers/keyboard.c +++ b/kernel/drivers/keyboard.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -62,9 +63,9 @@ static void keyboard_rate(void) static s32 keyboard_read(void *buf, u32 offset, u32 count, struct device *dev) { - (void)dev; + UNUSED(dev); if (stack_empty(queue)) - return -1; + return -EINVAL; struct event_keyboard *e = stack_pop(queue); memcpy(buf, (u8 *)e + offset, MIN(count, sizeof(*e))); @@ -72,7 +73,7 @@ static s32 keyboard_read(void *buf, u32 offset, u32 count, struct device *dev) return MIN(count, sizeof(*e)); } -static u8 keyboard_ready(void) +static s32 keyboard_ready(void) { return !stack_empty(queue); } diff --git a/kernel/drivers/mouse.c b/kernel/drivers/mouse.c index 5c481da..8545099 100644 --- a/kernel/drivers/mouse.c +++ b/kernel/drivers/mouse.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -83,7 +84,7 @@ static u8 mouse_serial_read(void) return inb(0x60); } -static u8 mouse_ready(void) +static s32 mouse_ready(void) { return !stack_empty(queue); } @@ -92,7 +93,7 @@ static s32 mouse_read(void *buf, u32 offset, u32 count, struct device *dev) { (void)dev; if (stack_empty(queue)) - return -1; + return -EINVAL; struct event_mouse *e = stack_pop(queue); memcpy(buf, (u8 *)e + offset, MIN(count, sizeof(*e))); -- cgit v1.2.3