On Thu, 2016-08-18 at 18:17 +0200, Peter Meerwald-Stadler wrote: > read() can return a number of bytes read less than k There seem to be other fixes too, which are not mentioned in the commit message: handling of EAGAIN (but not EINTR - looks like pa_read() would be suitable here too), fix for the completely broken error handling (errors didn't cause termination of the loop), and handling of EOF (AFAIK not all fds have a concept of EOF, and not knowing what this function is used on, I don't know if the EOF handling is necessary - but it can't hurt either). > CID 1137981 > --- > Â src/utils/padsp.c | 11 +++++++++-- > Â 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/src/utils/padsp.c b/src/utils/padsp.c > index 943479b..bb01f7f 100644 > --- a/src/utils/padsp.c > +++ b/src/utils/padsp.c > @@ -1768,11 +1768,18 @@ static int dsp_flush_fd(int fd) { > Â Â Â Â Â while (l > 0) { > Â Â Â Â Â Â Â Â Â char buf[1024]; > Â Â Â Â Â Â Â Â Â size_t k; > +Â Â Â Â Â Â Â Â ssize_t r; > Â > Â Â Â Â Â Â Â Â Â k = (size_t) l > sizeof(buf) ? sizeof(buf) : (size_t) l; > -Â Â Â Â Â Â Â Â if (read(fd, buf, k) < 0) > +Â Â Â Â Â Â Â Â r = read(fd, buf, k); > +Â Â Â Â Â Â Â Â if (r < 0) { > +Â Â Â Â Â Â Â Â Â Â Â Â if (errno == EAGAIN) > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; > Â Â Â Â Â Â Â Â Â Â Â Â Â debug(DEBUG_LEVEL_NORMAL, __FILE__": read(): %s\n", > strerror(errno)); > -Â Â Â Â Â Â Â Â l -= k; > +Â Â Â Â Â Â Â Â Â Â Â Â return -1; > +Â Â Â Â Â Â Â Â } else if (r == 0) > +Â Â Â Â Â Â Â Â Â Â Â Â return 0; Nitpicking: is there a reason why the errno == EAGAIN check uses "break", but this returns zero directly? The end result is the same anyway. --Â Tanu