mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-07-26 18:48:55 +02:00
id: avoid unnecessary buffer flushing
* src/groups.c (main): * src/id.c (main, print_stuff): Don’t flush stdout before testing for write error. Do the test only when in a loop, as a one-shot will test for write error soon anyway.
This commit is contained in:
@@ -22,7 +22,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
** Improvements
|
||||
|
||||
'groups' and 'id' will now exit immediately upon receiving a write error,
|
||||
'groups' and 'id' will now exit sooner after a write error,
|
||||
which is significant when listing information for many users.
|
||||
|
||||
'nl' now supports multi-byte --section-delimiter characters.
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ main (int argc, char **argv)
|
||||
ok = false;
|
||||
putchar ('\n');
|
||||
|
||||
if (fflush (stdout) < 0)
|
||||
if (ferror (stdout))
|
||||
write_error ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,6 +277,8 @@ main (int argc, char **argv)
|
||||
ruid = euid = pwd->pw_uid;
|
||||
rgid = egid = pwd->pw_gid;
|
||||
print_stuff (pw_name);
|
||||
if (ferror (stdout))
|
||||
write_error ();
|
||||
}
|
||||
free (pw_name);
|
||||
}
|
||||
@@ -458,7 +460,4 @@ print_stuff (char const *pw_name)
|
||||
{
|
||||
putchar (opt_zero ? '\0' : '\n');
|
||||
}
|
||||
|
||||
if (fflush (stdout) < 0)
|
||||
write_error ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user