diff options
author | Brandon Casey <casey@nrlssc.navy.mil> | 2008-01-16 13:12:46 -0600 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-01-16 15:35:35 -0800 |
commit | 4ed7cd3ab07f7c721daf4241fe1dac306fefd1fb (patch) | |
tree | e3b03a59cd0bca192fb396522f813210451404b8 /config.c | |
parent | d6cf61bfd4bccffcc8b095f8469dbe749d70abdf (diff) | |
download | git-4ed7cd3ab07f7c721daf4241fe1dac306fefd1fb.tar.gz |
Improve use of lockfile API
Remove remaining double close(2)'s. i.e. close() before
commit_locked_index() or commit_lock_file().
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -955,14 +955,12 @@ int git_config_set_multivar(const char* key, const char* value, munmap(contents, contents_sz); } - if (close(fd) || commit_lock_file(lock) < 0) { + if (commit_lock_file(lock) < 0) { fprintf(stderr, "Cannot commit config file!\n"); ret = 4; goto out_free; } - /* fd is closed, so don't try to close it below. */ - fd = -1; /* * lock is committed, so don't try to roll it back below. * NOTE: Since lockfile.c keeps a linked list of all created @@ -973,8 +971,6 @@ int git_config_set_multivar(const char* key, const char* value, ret = 0; out_free: - if (0 <= fd) - close(fd); if (lock) rollback_lock_file(lock); free(config_filename); @@ -1072,7 +1068,7 @@ int git_config_rename_section(const char *old_name, const char *new_name) } fclose(config_file); unlock_and_out: - if (close(out_fd) || commit_lock_file(lock) < 0) + if (commit_lock_file(lock) < 0) ret = error("Cannot commit config file!"); out: free(config_filename); |