From e1de726c15937a8dbf81d12ef0c872cf6576ebd0 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 12 Mar 2012 22:55:40 -0700 Subject: 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. --- src/mwindow.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/mwindow.c') diff --git a/src/mwindow.c b/src/mwindow.c index 39f6aeacc..e3de0709c 100644 --- a/src/mwindow.c +++ b/src/mwindow.c @@ -178,8 +178,10 @@ static git_mwindow *new_window( * window. */ - if (git_futils_mmap_ro(&w->window_map, fd, w->offset, (size_t)len) < GIT_SUCCESS) - goto cleanup; + if (git_futils_mmap_ro(&w->window_map, fd, w->offset, (size_t)len) < 0) { + git__free(w); + return NULL; + } ctl->mmap_calls++; ctl->open_windows++; @@ -191,10 +193,6 @@ static git_mwindow *new_window( ctl->peak_open_windows = ctl->open_windows; return w; - -cleanup: - git__free(w); - return NULL; } /* @@ -253,11 +251,10 @@ unsigned char *git_mwindow_open( int git_mwindow_file_register(git_mwindow_file *mwf) { git_mwindow_ctl *ctl = &GIT_GLOBAL->mem_ctl; - int error; if (ctl->windowfiles.length == 0 && - (error = git_vector_init(&ctl->windowfiles, 8, NULL)) < GIT_SUCCESS) - return error; + git_vector_init(&ctl->windowfiles, 8, NULL) < 0) + return -1; return git_vector_insert(&ctl->windowfiles, mwf); } -- cgit v1.2.1