diff --git a/libs/libc/misc/lib_dumpbuffer.c b/libs/libc/misc/lib_dumpbuffer.c index 010cc21b06..cd220bccce 100644 --- a/libs/libc/misc/lib_dumpbuffer.c +++ b/libs/libc/misc/lib_dumpbuffer.c @@ -47,8 +47,8 @@ * Pre-processor definitions ****************************************************************************/ -#define _NITEMS 32 /* 32 bytes displayed per line */ -#define _LINESIZE (3 * _NITEMS + 4) /* 2 hex chars, ASCII char, 3 spaces, NUL */ +#define _NITEMS 16 /* 32 bytes displayed per line */ +#define _LINESIZE (3 * _NITEMS + _NITEMS + 4) /* 2 hex chars, ASCII char, 3 spaces, NUL */ /**************************************************************************** * Private Functions @@ -97,7 +97,11 @@ void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer, unsigned int j; unsigned int k; - syslog(LOG_INFO, "%s (%p):\n", msg, buffer); + if (msg) + { + syslog(LOG_INFO, "%s (%p):\n", msg, buffer); + } + for (i = 0; i < buflen; i += _NITEMS) { FAR char *ptr = buf; @@ -108,11 +112,6 @@ void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer, { k = i + j; - if (j == (_NITEMS / 2)) - { - *ptr++ = ' '; - } - if (k < buflen) { *ptr++ = lib_nibble((buffer[k] >> 4) & 0xf); @@ -123,6 +122,8 @@ void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer, *ptr++ = ' '; *ptr++ = ' '; } + + *ptr++ = ' '; } *ptr++ = ' '; /* Plus 1 byte */ @@ -133,11 +134,6 @@ void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer, { k = i + j; - if (j == (_NITEMS / 2)) - { - *ptr++ = ' '; - } - if (k < buflen) { if (buffer[k] >= 0x20 && buffer[k] < 0x7f) @@ -152,6 +148,6 @@ void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer, } *ptr = '\0'; /* Plus 1 byte */ - syslog(LOG_INFO, "%04x: %s\n", i, buf); + syslog(LOG_INFO, "%04x %s\n", i, buf); } }