strbuf: strbuf_read_file() should return ssize_t

It is currently declared to return int, which could overflow for large files. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Jul 3, 2015 at 15:59 UTC 6c8afe495b2cb6e2069942d7c006f6660e186690
2 files changed +4 -3
strbuf.c
+3 -2
@@ -481,9 +481,10 @@ int strbuf_getwholeline_fd(struct strbuf *sb, int fd, int term)
481 return 0;
482 }
483
484 -int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
484 +ssize_t strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
485 {
486 - int fd, len;
486 + int fd;
487 + ssize_t len;
488
489 fd = open(path, O_RDONLY);
490 if (fd < 0)
strbuf.h
+1 -1
@@ -364,7 +364,7 @@ extern ssize_t strbuf_read(struct strbuf *, int fd, size_t hint);
364 * Read the contents of a file, specified by its path. The third argument
365 * can be used to give a hint about the file size, to avoid reallocs.
366 */
367 -extern int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);
367 +extern ssize_t strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);
368
369 /**
370 * Read the target of a symbolic link, specified by its path. The third