Skip to content

Commit

Permalink
Fix nasa#964, UtPrintx function
Browse files Browse the repository at this point in the history
Fix the UtPrintx() routine such that the loop stops correctly.
Also improves the output to print the address, not just the data.

Note if UtPrintf is used, one sees the file/line of the UtPrintx
function, not the actual test location, so it is better to call
UT_BSP_DoText directly so it omits this extraneous info.
  • Loading branch information
jphickey committed Apr 27, 2021
1 parent afb5f7b commit d059147
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ut_assert/src/uttools.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,22 @@ void UtPrintx(const void *Memory, uint32 Length)
uint32 i;
uint32 j;
const uint8 *Byte_ptr = Memory;
char OutputLine[50];
char OutputLine[80];
char * OutPtr;

i = 0;
while (1)
while (i < Length)
{
snprintf(OutputLine, sizeof(OutputLine), "%16lx: ", (unsigned long)&Byte_ptr[i]);
OutPtr = OutputLine;
OutPtr += strlen(OutputLine);
for (j = 0; j < 16 && i < Length; j++, i++)
{
sprintf(OutPtr, "%02X ", Byte_ptr[i]);
OutPtr += 3;
}
UtPrintf("%s\n", OutputLine);

UT_BSP_DoText(UTASSERT_CASETYPE_INFO, OutputLine);
}
}

Expand Down

0 comments on commit d059147

Please sign in to comment.