1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00

support: Change xgetline to return 0 on EOF

The advantage is that the buffer will always contain the number
of characters as returned from the function, which allows one to use
a sequence like

  /* No more audit module output.  */
  line_length = xgetline (&buffer, &buffer_length, fp);
  TEST_COMPARE_BLOB ("", 0, buffer, line_length);

to check for an expected EOF, while also reporting any unexpected
extra data encountered.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Florian Weimer
2020-04-02 17:09:36 +02:00
parent 17fd707f88
commit cea56af185
3 changed files with 19 additions and 10 deletions

View File

@@ -59,7 +59,7 @@ support_process_state_wait (pid_t pid, enum support_process_state state)
for (;;)
{
char cur_state = -1;
while (xgetline (&line, &linesiz, fstatus) != -1)
while (xgetline (&line, &linesiz, fstatus) > 0)
if (strncmp (line, "State:", strlen ("State:")) == 0)
{
TEST_COMPARE (sscanf (line, "%*s %c", &cur_state), 1);