git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] strbuf: describe the return value of strbuf_read_file()

From
Pranit Bauva <pranit.bauva@gmail.com>
Date
Jun 13, 2016, 20:23 UTC
Message-ID
<20160613202346.6473-1-pranit.bauva@gmail.com>
Mentored-by: Lars Schneider <larsxschneider@gmail.com>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
---
It is easy to be misguided on the return value of the function
strbuf_read_file(). It does follow the pattern of other standard functions
for reading files but its better to explicitly specify it.
 strbuf.h | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/strbuf.h b/strbuf.h
index 7987405..4b487f7 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -377,6 +377,8 @@ extern ssize_t strbuf_read_once(struct strbuf *, int fd, size_t hint);
 /**
  * Read the contents of a file, specified by its path. The third argument
  * can be used to give a hint about the file size, to avoid reallocs.
+ * Return the number of bytes read or -1 if some error occurred while
+ * opening or reading the file.
  */
 extern ssize_t strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);
 
-- 
2.8.4
Next: Junio C Hamano
Message 1 of 3 in “strbuf: describe the return value of strbuf_read_file()”
  1. strbuf: describe the return value of strbuf_read_file()Pranit Bauva, Jun 13, 2016
  2. Junio C HamanoJun 13, 2016
  3. Pranit BauvaJun 14, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.