summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-03-12 22:55:40 -0700
committerRussell Belfer <arrbee@arrbee.com>2012-03-12 22:55:40 -0700
commite1de726c15937a8dbf81d12ef0c872cf6576ebd0 (patch)
tree84b437dd23e8250b0a4f983875fb3849569ad63a /src/fileops.c
parentdda708e78f3c3f43d814d46c29ab9f2b9d47ed5c (diff)
downloadlibgit2-e1de726c15937a8dbf81d12ef0c872cf6576ebd0.tar.gz
Migrate ODB files to new error handling
This migrates odb.c, odb_loose.c, odb_pack.c and pack.c to the new style of error handling. Also got the unix and win32 versions of map.c. There are some minor changes to other files but no others were completely converted. This also contains an update to filebuf so that a zeroed out filebuf will not think that the fd (== 0) is actually open (and inadvertently call close() on fd 0 if cleaned up). Lastly, this was built and tested on win32 and contains a bunch of fixes for the win32 build which was pretty broken.
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/fileops.c b/src/fileops.c
index c9fd2c5bc..0ce48828b 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -117,7 +117,7 @@ int git_futils_readbuffer_updated(git_buf *buf, const char *path, time_t *mtime,
return fd;
if (p_fstat(fd, &st) < 0 || S_ISDIR(st.st_mode) || !git__is_sizet(st.st_size+1)) {
- close(fd);
+ p_close(fd);
giterr_set(GITERR_OS, "Invalid regular file stat for '%s'", path);
return -1;
}
@@ -127,7 +127,7 @@ int git_futils_readbuffer_updated(git_buf *buf, const char *path, time_t *mtime,
* has been modified.
*/
if (mtime != NULL && *mtime >= st.st_mtime) {
- close(fd);
+ p_close(fd);
return 0;
}
@@ -139,8 +139,8 @@ int git_futils_readbuffer_updated(git_buf *buf, const char *path, time_t *mtime,
git_buf_clear(buf);
if (git_buf_grow(buf, len + 1) < 0) {
- close(fd);
- return GIT_ENOMEM;
+ p_close(fd);
+ return -1;
}
buf->ptr[len] = '\0';
@@ -149,7 +149,7 @@ int git_futils_readbuffer_updated(git_buf *buf, const char *path, time_t *mtime,
ssize_t read_size = p_read(fd, buf->ptr, len);
if (read_size < 0) {
- close(fd);
+ p_close(fd);
giterr_set(GITERR_OS, "Failed to read descriptor for '%s'", path);
return -1;
}