On Tue, May 21, 2019 at 11:05 PM David Laight <david.lai...@aculab.com> wrote: > > From: Chang-Hsien Tsai > > @@ -678,7 +678,7 @@ void read_trace_pipe(void) > > static char buf[4096]; > > ssize_t sz; > > > > - sz = read(trace_fd, buf, sizeof(buf)); > > + sz = read(trace_fd, buf, sizeof(buf)-1); > > if (sz > 0) { > > buf[sz] = 0; > > puts(buf); > > Why not change the puts() to fwrite(buf, sz, 1, stdout) ? > Then you don't need the '\0' terminator. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 > 1PT, UK > Registration No: 1397386 (Wales) >
Yes. But, this will be different with the original code. puts(buf) prints buf and a terminating newline character. -- Chang-Hsien Tsai