Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does UtPrintx have an infinite loop in it? #964

Closed
asgibson opened this issue Apr 15, 2021 · 1 comment · Fixed by #973 or #979
Closed

Why does UtPrintx have an infinite loop in it? #964

asgibson opened this issue Apr 15, 2021 · 1 comment · Fixed by #973 or #979
Assignees
Labels
bug question unit-test Tickets related to the OSAL unit testing (functional and/or coverage)
Milestone

Comments

@asgibson
Copy link
Contributor

Describe the bug
Any use of UtPrintx results in an infinite printing of the given Memory and Length.

To Reproduce
Steps to reproduce the behavior:

  1. Put UtPrintx in a unit test, give it an address and size (from 0 to max uint32)
  2. Run tests
  3. Enter loop

Expected behavior

  1. Print the number of bytes given as Length starting at the given address Memory (with newline at end)
  2. Return

Code snips

void UtPrintx(const void *Memory, uint32 Length)
{
uint32 i;
uint32 j;
const uint8 *Byte_ptr = Memory;
char OutputLine[50];
char * OutPtr;
i = 0;
while (1)
{
OutPtr = OutputLine;
for (j = 0; j < 16 && i < Length; j++, i++)
{
sprintf(OutPtr, "%02X ", Byte_ptr[i]);
OutPtr += 3;
}
UtPrintf("%s\n", OutputLine);
}
}

System observed on:

  • RHEL 7.8

Reporter Info
Alan Gibson
NASA/GSFC 587

@asgibson asgibson added bug question unit-test Tickets related to the OSAL unit testing (functional and/or coverage) labels Apr 15, 2021
@skliper skliper added this to the 6.0.0 milestone Apr 16, 2021
@skliper
Copy link
Contributor

skliper commented Apr 16, 2021

Guessing the intent was to break the output into lines, but definitely needs a fix.

jphickey added a commit to jphickey/osal that referenced this issue Apr 27, 2021
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.
@jphickey jphickey self-assigned this Apr 27, 2021
astrogeco added a commit that referenced this issue May 3, 2021
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
Fix nasa#909, reorganize ES public API + msg definitions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug question unit-test Tickets related to the OSAL unit testing (functional and/or coverage)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants