linuxkpi: Avoid trailing whitespaces in lkpi_hex_dump()
We use the return value of the callback to track the number of bytes
written. We use it to determine if a group of characters should be
prepended with a whitespace. This way, we never add a trailing
whitespace.
We need to pay attention to the return value of the callback: if it is
negative, it's an error and we return immediately. Otherwise, we would
decrease the number of written bytes and possibly make it negative.
Reviewed by: bz, christos
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D51558