Skip to content

Commit

Permalink
Update #404, Use loop in Console Write
Browse files Browse the repository at this point in the history
This ensures that the return value of the write() call is checked,
and avoids a potential compiler warning.  There is still no recourse if
the write call fails, but it can retry if it was short.
  • Loading branch information
jphickey committed Apr 13, 2020
1 parent b05e906 commit f59b16b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/bsp/pc-linux/src/bsp_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,21 @@ static void OS_BSP_ExecTput(const char *cap, const char *param)
------------------------------------------------------------------*/
void OS_BSP_ConsoleOutput_Impl(const char *Str, uint32 DataLen)
{
/* writes the raw data directly to STDOUT_FILENO (unbuffered) */
write(STDOUT_FILENO, Str, DataLen);
ssize_t WriteLen;

do
{
/* writes the raw data directly to STDOUT_FILENO (unbuffered) */
WriteLen = write(STDOUT_FILENO, Str, DataLen);
if (WriteLen <= 0)
{
/* no recourse if this fails, just stop. */
break;
}
Str += WriteLen;
DataLen -= WriteLen;
}
while(true);
}

/*----------------------------------------------------------------
Expand Down

0 comments on commit f59b16b

Please sign in to comment.