diff options
| author | Ada Christine <adachristine18@gmail.com> | 2022-02-13 18:47:21 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2022-02-13 18:47:21 +0000 |
| commit | 78788acf026b21b516fd981d321b0809c07de921 (patch) | |
| tree | 75796bb39f73474ec38178f3ac9a308d042ae836 /kc | |
| parent | 43c10da9cf77bb7676db3733499c1b578826dca9 (diff) | |
bug when kprintf is fed a 0, it does nothing
Diffstat (limited to 'kc')
| -rw-r--r-- | kc/core/kprint.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/kc/core/kprint.c b/kc/core/kprint.c index 5a0fffd..8c2bf12 100644 --- a/kc/core/kprint.c +++ b/kc/core/kprint.c @@ -6,13 +6,11 @@ #include <stdint.h> #include <stdbool.h> - __attribute__((optimize("O3"))) int kputchar(int c) { return serial_putchar(c); } - __attribute__((optimize("O3"))) int kputs(const char *s) { int count = 0; @@ -301,13 +299,14 @@ static char *convert_integer( // at the last byte of the string char *result = buffer + bufsz - 1; - // result >= buffer condition ensures we don't overflow + // result >= buffer condition ensures we don't underflow - while (value > 0 && result >= buffer) + do { *--result = stringdigits[value % base]; value /= base; - } + } + while (value > 0 && result >= buffer); return result; } |
