Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
strbuf: strbuf_read_file() should return ssize_t
author
Michael Haggerty
<mhagger@alum.mit.edu>
Fri, 3 Jul 2015 13:59:32 +0000
(15:59 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Sat, 4 Jul 2015 01:25:02 +0000
(18:25 -0700)
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>
strbuf.c
patch
|
blob
|
history
strbuf.h
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
351d06d
)
diff --git
a/strbuf.c
b/strbuf.c
index 88cafd4a70b8179a4e911c18704fb4ab0f2a21f5..b4da9f5d05fc1f22f8910a21d8e352f2e5e9673f 100644
(file)
--- a/
strbuf.c
+++ b/
strbuf.c
@@
-481,9
+481,10
@@
int strbuf_getwholeline_fd(struct strbuf *sb, int fd, int term)
return 0;
}
return 0;
}
-
in
t 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)
fd = open(path, O_RDONLY);
if (fd < 0)
diff --git
a/strbuf.h
b/strbuf.h
index 1883494ca3ad4931640c2a295c94800e287c1664..1ea9d0bdeb0980dcaa8670aa43e4ff703fd9d6b8 100644
(file)
--- a/
strbuf.h
+++ b/
strbuf.h
@@
-364,7
+364,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.
*/
* 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
in
t 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
/**
* Read the target of a symbolic link, specified by its path. The third