*: introduce and use ffulsh_all()
function old new delta
buffer_fill_and_print 179 196 +17
fflush_all - 9 +9
spawn 87 92 +5
rtcwake_main 455 453 -2
...
alarm_intr 93 84 -9
readcmd 1072 1062 -10
bb_ask 345 333 -12
more_main 845 832 -13
flush_stdout_stderr 42 23 -19
xfflush_stdout 27 - -27
flush_stderr 30 - -30
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/50 up/down: 31/-397) Total: -366 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/networking/arping.c b/networking/arping.c
index 71690cf..e3418a9 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -237,7 +237,7 @@
} else {
printf(" UNSOLICITED?\n");
}
- fflush(stdout);
+ fflush_all();
}
received++;
if (FROM->sll_pkttype != PACKET_HOST)
diff --git a/networking/ftpd.c b/networking/ftpd.c
index 70a3533..9937cc3 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -630,7 +630,7 @@
cwd = xrealloc_getcwd_or_warn(NULL);
xpiped_pair(outfd);
- /*fflush(NULL); - so far we dont use stdio on output */
+ /*fflush_all(); - so far we dont use stdio on output */
pid = BB_MMU ? fork() : vfork();
if (pid < 0)
bb_perror_msg_and_die(BB_MMU ? "fork" : "vfork");
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index d0c5cce..88d1944 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -969,7 +969,7 @@
pid_t child;
int status;
- fflush(NULL);
+ fflush_all();
child = vfork();
switch (child) {
case -1: /* failure */
@@ -1038,7 +1038,7 @@
xpiped_pair(infd);
xpiped_pair(outfd);
- fflush(NULL);
+ fflush_all();
pid = vfork();
switch (pid) {
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index 86d2754..fcf9623 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -182,7 +182,7 @@
}
}
bb_putchar('\n');
- /*fflush(stdout);*/
+ /*fflush_all();*/
return 0;
}
@@ -344,7 +344,7 @@
printf(" %s", buf);
}
bb_putchar('\n');
- /*fflush(stdout);*/
+ /*fflush_all();*/
return 0;
}
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c
index e524731..659f3a9 100644
--- a/networking/libiproute/iprule.c
+++ b/networking/libiproute/iprule.c
@@ -151,7 +151,7 @@
fputs(rtnl_rtntype_n2a(r->rtm_type, b1), stdout);
bb_putchar('\n');
- /*fflush(stdout);*/
+ /*fflush_all();*/
return 0;
}
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c
index 9aaeec1..ad98bed 100644
--- a/networking/nc_bloaty.c
+++ b/networking/nc_bloaty.c
@@ -152,7 +152,7 @@
/* Debug: squirt whatever message and sleep a bit so we can see it go by. */
/* Beware: writes to stdOUT... */
#if 0
-#define Debug(...) do { printf(__VA_ARGS__); printf("\n"); fflush(stdout); sleep(1); } while (0)
+#define Debug(...) do { printf(__VA_ARGS__); printf("\n"); fflush_all(); sleep(1); } while (0)
#else
#define Debug(...) do { } while (0)
#endif
diff --git a/networking/ping.c b/networking/ping.c
index 71b2a4b..d30eb5c 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -491,7 +491,7 @@
if (tp)
printf(" time=%u.%03u ms", triptime / 1000, triptime % 1000);
puts(dupmsg);
- fflush(stdout);
+ fflush_all();
}
static void unpack4(char *buf, int sz, struct sockaddr_in *from)
{
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 163efaa..b0a1cc4 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -288,7 +288,7 @@
/*ts->size2 = 0;*/
}
- fflush(NULL); /* flush all streams */
+ fflush_all();
pid = vfork(); /* NOMMU-friendly */
if (pid < 0) {
free(ts);
@@ -331,7 +331,7 @@
/*termbuf.c_lflag &= ~ICANON;*/
tcsetattr_stdin_TCSANOW(&termbuf);
- /* Uses FILE-based I/O to stdout, but does fflush(stdout),
+ /* Uses FILE-based I/O to stdout, but does fflush_all(),
* so should be safe with vfork.
* I fear, though, that some users will have ridiculously big
* issue files, and they may block writing to fd 1,
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 7284f00..fa45db9 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -815,7 +815,7 @@
if (!first && pausemsecs > 0)
usleep(pausemsecs * 1000);
- fflush(stdout);
+ fflush_all();
t1 = monotonic_us();
send_probe(++seq, ttl);