diff --git a/kernel/kprintf.c b/kernel/kprintf.c index 16fc909..fae848e 100644 --- a/kernel/kprintf.c +++ b/kernel/kprintf.c @@ -312,17 +312,12 @@ void parse_fmt_sequence(struct fmt_sequence *sequence, const char **restrict pos static ssize_t render_c(const struct fmt_sequence *sequence, va_list *ap) { - ssize_t ret; - - if (sequence->length_modifier == LENGTH_L) { - wchar_t val = (wchar_t)va_arg(*ap, wint_t); - ret = printer->write(printer, &val, sizeof(val)); - } else { - char val = (char)va_arg(*ap, int); - ret = printer->write(printer, &val, sizeof(val)); - } + /* we don't support wchars until we have a UTF-8 encoder */ + if (sequence->length_modifier != LENGTH_DEFAULT) + return -1; - return ret; + char val = (char)va_arg(*ap, int); + return printer->write(printer, &val, sizeof(val)); } static ssize_t render_s(const struct fmt_sequence *sequence, va_list *ap) @@ -331,7 +326,13 @@ static ssize_t render_s(const struct fmt_sequence *sequence, va_list *ap) * the string is a wchar_t if LENGTH_L is set, but that would require * a full UTF-8 encoder which i won't write in the near future. Cope. */ + if (sequence->length_modifier != LENGTH_DEFAULT) + return -1; + const char *s = va_arg(*ap, char *); + if (s == nil) + return write_asciz("(null)"); + if (sequence->max_precision) return write_bytes(s, strnlen(s, sequence->max_precision)); else