Skip to content

Commit

Permalink
Merge branch 'mh/strbuf-read-file-returns-ssize-t'
Browse files Browse the repository at this point in the history
Avoid possible ssize_t to int truncation.

* mh/strbuf-read-file-returns-ssize-t:
  strbuf: strbuf_read_file() should return ssize_t
  • Loading branch information
Junio C Hamano committed Jul 13, 2015
2 parents 6cf7eef + 6c8afe4 commit d790ba9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions strbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,10 @@ int strbuf_getwholeline_fd(struct strbuf *sb, int fd, int term)
return 0;
}

int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
ssize_t strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
{
int fd, len;
int fd;
ssize_t len;

fd = open(path, O_RDONLY);
if (fd < 0)
Expand Down
2 changes: 1 addition & 1 deletion strbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ extern ssize_t strbuf_read(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.
*/
extern int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);
extern ssize_t strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);

/**
* Read the target of a symbolic link, specified by its path. The third
Expand Down

0 comments on commit d790ba9

Please sign in to comment.