summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-09-17 09:46:46 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-10-14 12:52:10 +0200
commit13d9ed111f326a1fa4c38e44617cb74a8ab474d2 (patch)
treeb65a486b1cdfa2d00900ae12890509b1e6fb1c43 /lib
parent09fd5267dfb934f0850c372727453bee6b029d7e (diff)
downloadbarebox-13d9ed111f326a1fa4c38e44617cb74a8ab474d2.tar.gz
barebox-13d9ed111f326a1fa4c38e44617cb74a8ab474d2.tar.xz
libfile: Document that read_file() returns a terminated buffer
read_file() and read_file_2() return a '\0' terminated buffer to make sure the buffer is usable as a string. Other code like read_file_line() depends on this behaviour, so document it explicitly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/libfile.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libfile.c b/lib/libfile.c
index 3f3ec21fdb..02078dd43d 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -158,7 +158,9 @@ EXPORT_SYMBOL_GPL(read_file_line);
* bytes are read. The actual read size is returned in @size. -EFBIG is
* returned if the file is bigger than @max_size, but the buffer is read
* anyway up to @max_size in this case. Free the buffer with free() after
- * usage.
+ * usage. The allocated buffer is actually one byte bigger than the file
+ * and the extra byte is initialized to '\0' so that the returned buffer
+ * can safely be interpreted as a string.
*
* Return: 0 for success, or negative error code. -EFBIG is returned
* when the file has been bigger than max_size.