Hi there,
setbuf(3) etc "are obsoleted by setvbuf(3)" and "should be avoided".
The patch below replaces all occurrences in ping, ping6, lptest & rmt.
Cheers,
Frederic
Index: ping/ping.c
===================================================================
RCS file: /cvs/src/sbin/ping/ping.c,v
retrieving revision 1.131
diff -u -p -r1.131 ping.c
--- ping/ping.c 30 Oct 2015 11:00:52 -0000 1.131
+++ ping/ping.c 4 Nov 2015 20:32:01 -0000
@@ -234,7 +234,7 @@ main(int argc, char *argv[])
if (getuid())
errx(1, "%s", strerror(EPERM));
options |= F_FLOOD;
- setbuf(stdout, (char *)NULL);
+ setvbuf(stdout, NULL, _IONBF, 0);
break;
case 'I':
case 'S': /* deprecated */
Index: ping6/ping6.c
===================================================================
RCS file: /cvs/src/sbin/ping6/ping6.c,v
retrieving revision 1.135
diff -u -p -r1.135 ping6.c
--- ping6/ping6.c 25 Oct 2015 20:01:21 -0000 1.135
+++ ping6/ping6.c 4 Nov 2015 20:32:01 -0000
@@ -276,7 +276,7 @@ main(int argc, char *argv[])
errx(1, "Must be superuser to flood ping");
}
options |= F_FLOOD;
- setbuf(stdout, (char *)NULL);
+ setvbuf(stdout, NULL, _IONBF, 0);
break;
case 'H':
options |= F_HOSTNAME;
Index: lpr/lptest/lptest.c
===================================================================
RCS file: /cvs/src/usr.sbin/lpr/lptest/lptest.c,v
retrieving revision 1.8
diff -u -p -r1.8 lptest.c
--- lpr/lptest/lptest.c 27 Oct 2009 23:59:52 -0000 1.8
+++ lpr/lptest/lptest.c 4 Nov 2015 20:36:15 -0000
@@ -44,7 +44,7 @@ main(int argc, char **argv)
int i, j, fc, nc;
char outbuf[BUFSIZ];
- setbuf(stdout, outbuf);
+ setvbuf(stdout, outbuf, _IOFBF, sizeof outbuf);
if (argc >= 2)
len = atoi(argv[1]);
else
Index: rmt/rmt.c
===================================================================
RCS file: /cvs/src/usr.sbin/rmt/rmt.c,v
retrieving revision 1.18
diff -u -p -r1.18 rmt.c
--- rmt/rmt.c 20 Oct 2015 18:47:21 -0000 1.18
+++ rmt/rmt.c 4 Nov 2015 20:36:15 -0000
@@ -113,7 +113,7 @@ main(int argc, char *argv[])
debug = fopen(*argv, "w");
if (debug == 0)
err(1, "cannot open debug file");
- (void) setbuf(debug, (char *)0);
+ setvbuf(debug, NULL, _IONBF, 0);
}
if (dir) {