Pokus o lepsi praci s pracovnim bufferem zpravy

This commit is contained in:
Pavel Brychta 2018-05-09 19:05:33 +02:00
parent ab635dd013
commit 4dbd2697e0

View File

@ -47,10 +47,10 @@ static TraceLine &trace_line(uint16_t index)
static void print(uint8_t severity, const char *buffer, int length) static void print(uint8_t severity, const char *buffer, int length)
{ {
char lin[(MAX_LINE_LEN * 4) + 1]; char lin[MAX_LINE_LEN + 1];
int lineptr = 0; int lineptr = 0;
while (0 != *buffer) while ((0 != *buffer) && (lineptr < (sizeof(lin) - 1)))
{ {
if (*buffer > 0x1f) if (*buffer > 0x1f)
lin[lineptr] = *buffer; lin[lineptr] = *buffer;
@ -59,8 +59,6 @@ static void print(uint8_t severity, const char *buffer, int length)
++lineptr; ++lineptr;
++buffer; ++buffer;
} }
if (lineptr > MAX_LINE_LEN)
lineptr = MAX_LINE_LEN;
lin[lineptr] = 0; // ukoncime retezec lin[lineptr] = 0; // ukoncime retezec
TraceLine line(severity, lin, lineptr); TraceLine line(severity, lin, lineptr);