aboutsummaryrefslogtreecommitdiff
path: root/include/membuff.h
diff options
context:
space:
mode:
authorIon Agorria2024-01-05 09:22:10 +0200
committerMattijs Korpershoek2024-01-09 14:58:33 +0100
commite58bafc35fe37491bb3546299593dcc054145adb (patch)
treea50d65fe54980ff838d40d1a205433da49908d98 /include/membuff.h
parent90087dd076d42c196de3506b6fa4d052f0869670 (diff)
lib: membuff: fix readline not returning line in case of overflow
If line overflows readline it will not be returned, fix this behavior, make it optional and documented properly. Signed-off-by: Ion Agorria <ion@agorria.com> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Link: https://lore.kernel.org/r/20240105072212.6615-6-clamor95@gmail.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Diffstat (limited to 'include/membuff.h')
-rw-r--r--include/membuff.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/membuff.h b/include/membuff.h
index 21051b0c54e..4eba626ce1c 100644
--- a/include/membuff.h
+++ b/include/membuff.h
@@ -192,10 +192,11 @@ int membuff_free(struct membuff *mb);
* @mb: membuff to adjust
* @str: Place to put the line
* @maxlen: Maximum line length (excluding terminator)
+ * @must_fit: If true then str is empty if line doesn't fit
* Return: number of bytes read (including terminator) if a line has been
- * read, 0 if nothing was there
+ * read, 0 if nothing was there or line didn't fit when must_fit is set
*/
-int membuff_readline(struct membuff *mb, char *str, int maxlen, int minch);
+int membuff_readline(struct membuff *mb, char *str, int maxlen, int minch, bool must_fit);
/**
* membuff_extend_by() - expand a membuff