From e3868dab3db27242f066bf52d95d0b3f2c0df7e3 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 25 Mar 2013 17:30:56 +0000 Subject: [PATCH] string: Simplify return value of for_each_line(). No caller used this function for counting lines, so simplify it by always returning the number of bytes not processed. --- string.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/string.c b/string.c index c22dc7cf..c0a1951d 100644 --- a/string.c +++ b/string.c @@ -370,10 +370,10 @@ __malloc char *para_hostname(void) * incomplete line) is moved to the beginning of the buffer if FELF_READ_ONLY is * unset. * - * \return If \p FELF_READ_ONLY is not set in \a flags, this function returns - * the number of bytes not handled to \p line_handler, otherwise the number of - * complete lines. On errors the negative error code of the \p line_handler is - * returned. + * \return On success this function returns the number of bytes not handled to + * \p line_handler. The only possible error is a negative return value from the + * line handler. In this case processing stops and the return value of the line + * handler is returned to indicate failure. * * \sa \ref for_each_line_flags. */ @@ -415,10 +415,8 @@ int for_each_line(unsigned flags, char *buf, size_t size, return ret; start = ++end; } - if (flags & FELF_READ_ONLY) - return num_lines; i = buf + size - start; - if (i && i != size) + if (i && i != size && !(flags & FELF_READ_ONLY)) memmove(buf, start, i); return i; } -- 2.30.2