{"thread":{"id":"42596","subject":"[PATCH] strbuf: describe the return value of strbuf_read_file()","startedAt":"2016-06-16T06:55:52Z","lastAt":"2016-06-16T06:55:52Z","messageCount":3,"participants":["Pranit Bauva","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"289164","messageId":"20160613202346.6473-1-pranit.bauva@gmail.com","threadId":"42596","inReplyTo":null,"subject":"[PATCH] strbuf: describe the return value of strbuf_read_file()","fromName":"Pranit Bauva","fromEmail":"pranit.bauva@gmail.com","sentAt":"2016-06-13T20:23:46Z","receivedAt":"2016-06-16T06:55:52Z","isPatch":true,"sender":{"key":"pranit.bauva@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2959938?v=4"},"body":"Mentored-by: Lars Schneider <larsxschneider@gmail.com>\nMentored-by: Christian Couder <chriscool@tuxfamily.org>\nSigned-off-by: Pranit Bauva <pranit.bauva@gmail.com>\n---\nIt is easy to be misguided on the return value of the function\nstrbuf_read_file(). It does follow the pattern of other standard functions\nfor reading files but its better to explicitly specify it.\n\n strbuf.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/strbuf.h b/strbuf.h\nindex 7987405..4b487f7 100644\n--- a/strbuf.h\n+++ b/strbuf.h\n@@ -377,6 +377,8 @@ extern ssize_t strbuf_read_once(struct strbuf *, int fd, size_t hint);\n /**\n  * Read the contents of a file, specified by its path. The third argument\n  * can be used to give a hint about the file size, to avoid reallocs.\n+ * Return the number of bytes read or -1 if some error occurred while\n+ * opening or reading the file.\n  */\n extern ssize_t strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);\n \n-- \n2.8.4\n"},{"id":"289170","messageId":"xmqqfusgbv0e.fsf@gitster.mtv.corp.google.com","threadId":"42596","inReplyTo":"20160613202346.6473-1-pranit.bauva@gmail.com","subject":"Re: [PATCH] strbuf: describe the return value of strbuf_read_file()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-13T22:10:09Z","receivedAt":"2016-06-16T06:55:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pranit Bauva <pranit.bauva@gmail.com> writes:\n\n> Mentored-by: Lars Schneider <larsxschneider@gmail.com>\n> Mentored-by: Christian Couder <chriscool@tuxfamily.org>\n> Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>\n> ---\n> It is easy to be misguided on the return value of the function\n> strbuf_read_file(). It does follow the pattern of other standard functions\n> for reading files but its better to explicitly specify it.\n\nGood thing to do; I wonder if we want to explicitly say -1 or\nleave it at \"negative values are errors\", though (my knee-jerk\nreaction being \"do not over-specify more than absolute minimum\nto write callers correctly\").\n\n>\n>  strbuf.h | 2 ++\n>  1 file changed, 2 insertions(+)\n>\n> diff --git a/strbuf.h b/strbuf.h\n> index 7987405..4b487f7 100644\n> --- a/strbuf.h\n> +++ b/strbuf.h\n> @@ -377,6 +377,8 @@ extern ssize_t strbuf_read_once(struct strbuf *, int fd, size_t hint);\n>  /**\n>   * Read the contents of a file, specified by its path. The third argument\n>   * can be used to give a hint about the file size, to avoid reallocs.\n> + * Return the number of bytes read or -1 if some error occurred while\n> + * opening or reading the file.\n>   */\n>  extern ssize_t strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);\n"},{"id":"289185","messageId":"CAFZEwPPd_+9nFPCG51nr5s1XMs5SKXG3O3vbAZmxA-BHvZdFPg@mail.gmail.com","threadId":"42596","inReplyTo":"xmqqfusgbv0e.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] strbuf: describe the return value of strbuf_read_file()","fromName":"Pranit Bauva","fromEmail":"pranit.bauva@gmail.com","sentAt":"2016-06-14T05:57:54Z","receivedAt":"2016-06-16T06:55:52Z","isPatch":true,"sender":{"key":"pranit.bauva@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2959938?v=4"},"body":"Hey Junio,\n\nOn Tue, Jun 14, 2016 at 3:40 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> It is easy to be misguided on the return value of the function\n>> strbuf_read_file(). It does follow the pattern of other standard functions\n>> for reading files but its better to explicitly specify it.\n>\n> Good thing to do; I wonder if we want to explicitly say -1 or\n> leave it at \"negative values are errors\", though (my knee-jerk\n> reaction being \"do not over-specify more than absolute minimum\n> to write callers correctly\").\n\nSure I will re-roll with specifying about negative values as errors.\n\nRegards,\nPranit Bauva\n"}]}