diff options
author | Liav A <liavalb@gmail.com> | 2023-02-26 18:33:59 +0200 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2023-03-01 19:36:53 -0700 |
commit | 77486a0d08b6f4956b18d5898e108cc7a9c8a5d6 (patch) | |
tree | 06cfdffae5550ec7e95198eff97a0801f9ab7242 /Kernel | |
parent | 5416a37fdea815b2fc18c35a60d173f8cfa67709 (diff) | |
download | serenity-77486a0d08b6f4956b18d5898e108cc7a9c8a5d6.zip |
Kernel: Remove includes to LibC stdarg definitions
We don't actually need the va_list and other stdarg definitions in the
kernel, because we actually don't use the "pure" printf interface in any
kernel code at all, but we retain the snprintf declaration because the
libstdc++ library still need it to be declared and extern'ed.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/KBufferBuilder.h | 1 | ||||
-rw-r--r-- | Kernel/kprintf.cpp | 42 | ||||
-rw-r--r-- | Kernel/kstdio.h | 1 |
3 files changed, 2 insertions, 42 deletions
diff --git a/Kernel/KBufferBuilder.h b/Kernel/KBufferBuilder.h index f5e6d10f48..4a8e79607d 100644 --- a/Kernel/KBufferBuilder.h +++ b/Kernel/KBufferBuilder.h @@ -9,7 +9,6 @@ #include <AK/StringBuilder.h> #include <AK/StringView.h> #include <Kernel/KBuffer.h> -#include <stdarg.h> namespace Kernel { diff --git a/Kernel/kprintf.cpp b/Kernel/kprintf.cpp index 6fe2d22a1f..5c6f5c3202 100644 --- a/Kernel/kprintf.cpp +++ b/Kernel/kprintf.cpp @@ -20,8 +20,6 @@ #include <Kernel/TTY/ConsoleManagement.h> #include <Kernel/kstdio.h> -#include <LibC/stdarg.h> - namespace Kernel { extern Atomic<Graphics::Console*> g_boot_console; } @@ -90,49 +88,13 @@ static void console_out(char ch) } } -static void buffer_putch(char*& bufptr, char ch) -{ - *bufptr++ = ch; -} - // Declare it, so that the symbol is exported, because libstdc++ uses it. // However, *only* libstdc++ uses it, and none of the rest of the Kernel. extern "C" int sprintf(char* buffer, char const* fmt, ...); -int sprintf(char* buffer, char const* fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - int ret = printf_internal(buffer_putch, buffer, fmt, ap); - buffer[ret] = '\0'; - va_end(ap); - return ret; -} - -int snprintf(char* buffer, size_t size, char const* fmt, ...) +int sprintf(char*, char const*, ...) { - va_list ap; - va_start(ap, fmt); - size_t space_remaining = 0; - if (size) { - space_remaining = size - 1; - } else { - space_remaining = 0; - } - auto sized_buffer_putch = [&](char*& bufptr, char ch) { - if (space_remaining) { - *bufptr++ = ch; - --space_remaining; - } - }; - int ret = printf_internal(sized_buffer_putch, buffer, fmt, ap); - if (space_remaining) { - buffer[ret] = '\0'; - } else if (size > 0) { - buffer[size - 1] = '\0'; - } - va_end(ap); - return ret; + VERIFY_NOT_REACHED(); } static inline void internal_dbgputch(char ch) diff --git a/Kernel/kstdio.h b/Kernel/kstdio.h index be755c1698..03f6d65048 100644 --- a/Kernel/kstdio.h +++ b/Kernel/kstdio.h @@ -15,7 +15,6 @@ void kernelputstr(char const*, size_t); void kernelcriticalputstr(char const*, size_t); void dbgputchar(char); void kernelearlyputstr(char const*, size_t); -int snprintf(char* buf, size_t, char const* fmt, ...) __attribute__((format(printf, 3, 4))); void set_serial_debug_enabled(bool desired_state); bool is_serial_debug_enabled(); } |