X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lockfile.c;h=efcb7d7dfe30a2fbad03244ba4ca9e536a3649e4;hb=e3b7705207b3e9c661026e43b95cfb2f40d7e6f2;hp=aa69210d8b3a9063517d2d84153dc3ba738bef30;hpb=d6e11a6ebb61d22349f15df790fc8fe080ad5b52;p=platform%2Fupstream%2Fgit.git diff --git a/lockfile.c b/lockfile.c index aa69210..efcb7d7 100644 --- a/lockfile.c +++ b/lockfile.c @@ -72,7 +72,6 @@ static void resolve_symlink(struct strbuf *path) /* Make sure errno contains a meaningful value on error */ static int lock_file(struct lock_file *lk, const char *path, int flags) { - int fd; struct strbuf filename = STRBUF_INIT; strbuf_addstr(&filename, path); @@ -80,9 +79,9 @@ static int lock_file(struct lock_file *lk, const char *path, int flags) resolve_symlink(&filename); strbuf_addstr(&filename, LOCK_SUFFIX); - fd = create_tempfile(&lk->tempfile, filename.buf); + lk->tempfile = create_tempfile(filename.buf); strbuf_release(&filename); - return fd; + return lk->tempfile ? lk->tempfile->fd : -1; } /* @@ -191,7 +190,7 @@ char *get_locked_file_path(struct lock_file *lk) { struct strbuf ret = STRBUF_INIT; - strbuf_addstr(&ret, get_tempfile_path(&lk->tempfile)); + strbuf_addstr(&ret, get_tempfile_path(lk->tempfile)); if (ret.len <= LOCK_SUFFIX_LEN || strcmp(ret.buf + ret.len - LOCK_SUFFIX_LEN, LOCK_SUFFIX)) die("BUG: get_locked_file_path() called for malformed lock object");