Mercurial > dovecot > core-2.2
changeset 19549:dd68e15cdc22
lib: i_stream_get_error() now returns "EOF" if stream_errno==0 and eof==TRUE.
This can be used to replace a lot of code like:
input->stream_errno == 0 ? "EOF" : i_stream_get_error(input)
with simply:
i_stream_get_error(input)
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 11 Jan 2016 19:00:07 +0200 |
parents | 93b54ac4851c |
children | 596abdda5081 |
files | src/lib/istream.c src/lib/istream.h |
diffstat | 2 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/istream.c Sat Jan 09 22:55:15 2016 +0200 +++ b/src/lib/istream.c Mon Jan 11 19:00:07 2016 +0200 @@ -82,10 +82,11 @@ { struct istream *s; - /* we'll only return errors for streams that have stream_errno set. - we might be returning unintended error otherwise. */ + /* we'll only return errors for streams that have stream_errno set or + that have reached EOF. we might be returning unintended error + otherwise. */ if (stream->stream_errno == 0) - return "<no error>"; + return stream->eof ? "EOF" : "<no error>"; for (s = stream; s != NULL; s = s->real_stream->parent) { if (s->stream_errno == 0)
--- a/src/lib/istream.h Sat Jan 09 22:55:15 2016 +0200 +++ b/src/lib/istream.h Mon Jan 11 19:00:07 2016 +0200 @@ -74,7 +74,8 @@ /* Return file descriptor for stream, or -1 if none is available. */ int i_stream_get_fd(struct istream *stream); -/* Returns error string for the last error. */ +/* Returns error string for the last error. It also returns "EOF" in case there + is no error, but eof is set. Otherwise it returns "<no error>". */ const char *i_stream_get_error(struct istream *stream); /* Mark the stream and all of its parent streams closed. Any reads after this