libc/dumpvbuffer: update the vector ptr correctly

fix a bug that the vector pointer is not updated correctly.

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2020-12-29 18:33:22 +08:00 committed by Brennan Ashton
parent 0d8dc13b67
commit d7b004e179

View File

@ -85,7 +85,6 @@ void lib_dumpvbuffer(FAR const char *msg, FAR const struct iovec *iov,
int iovcnt) int iovcnt)
{ {
FAR const struct iovec *piov = iov; FAR const struct iovec *piov = iov;
FAR const uint8_t *iov_buf;
unsigned int len = 0; unsigned int len = 0;
char line[_LINESIZE]; char line[_LINESIZE];
unsigned int nitems; unsigned int nitems;
@ -104,11 +103,12 @@ void lib_dumpvbuffer(FAR const char *msg, FAR const struct iovec *iov,
while (piov != &iov[iovcnt] && piov->iov_len) while (piov != &iov[iovcnt] && piov->iov_len)
{ {
iov_buf = piov->iov_base;
ptr = line; ptr = line;
for (nitems = 0; nitems < _NITEMS; nitems++) for (nitems = 0; nitems < _NITEMS; nitems++)
{ {
FAR const uint8_t *iov_buf = piov->iov_base;
*ptr++ = lib_nibble((iov_buf[len] >> 4) & 0xf); *ptr++ = lib_nibble((iov_buf[len] >> 4) & 0xf);
*ptr++ = lib_nibble(iov_buf[len] & 0xf); *ptr++ = lib_nibble(iov_buf[len] & 0xf);
*ptr++ = ' '; *ptr++ = ' ';
@ -129,9 +129,9 @@ void lib_dumpvbuffer(FAR const char *msg, FAR const struct iovec *iov,
len = 0; len = 0;
if (++piov == &iov[iovcnt]) if (++piov == &iov[iovcnt])
{ {
memset(ptr, ' ', (_NITEMS - nitems) * 3); memset(ptr, ' ', (_NITEMS - nitems - 1) * 3);
memset(&line[_ASCIICHAR_OFFSET + nitems], ' ', memset(&line[_ASCIICHAR_OFFSET + nitems + 1], ' ',
_NITEMS - nitems); _NITEMS - nitems - 1);
break; break;
} }
} }