iankronquist/kernel-of-truth

Extend klogf and kprintf and add the printf attribute to them.

iankronquist opened this issue · 0 comments

Right now we can only reliably print out 32 bit hexidecimal numbers. That's not so bad, nearly everything I have dealt with so far can be represented that way. However, it would be nice to have a real printf implementation which supports the following:

  • %d, %i (32 bit signed integers as decimal)
  • %u (32 bit unsigned integers as decimal)
  • %x (32 bit unsigned integers as hex)
  • %p (32 bit (void*) pointers as hex)
  • %z, %l, %zu, %lu (64 bit signed and unsigned integers as decimal)
  • %s (char* strings)
  • %c (single characters)

Don't bother with %f and friends, as I don't have the FPU set up, and don't worry about padding.

Then it would be nice to update the signatures of klogf and kprintf so that the format strings are type checked. The signatures should look like this:

void klogf(char* string, ...) __attribute((printf(1,2)));
void kprintf(char* string, ...) __attribute((printf(1,2)));

After this change, many of the format strings throughout the code base will have to be updated.

Additionally, please note that kprint_uint and kprint_int are buggy and need to be fixed and maybe tested.