This is a bit easier to read than the old version, which nested part
of the non-error code in an "if" block.

Signed-off-by: Michael Haggerty <mhag...@alum.mit.edu>
---
 lockfile.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/lockfile.c b/lockfile.c
index c1ca5b1..87b40c4 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -182,15 +182,16 @@ static int lock_file(struct lock_file *lk, const char 
*path, int flags)
        strbuf_addstr(&lk->lock_filename, ".lock");
 
        lk->fd = open(lk->lock_filename.buf, O_RDWR | O_CREAT | O_EXCL, 0666);
-       if (0 <= lk->fd) {
-               if (adjust_shared_perm(lk->lock_filename.buf)) {
-                       error("cannot fix permission bits on %s", 
lk->lock_filename.buf);
-                       rollback_lock_file(lk);
-                       return -1;
-               }
-       }
-       else
+       if (lk->fd < 0) {
                strbuf_setlen(&lk->lock_filename, 0);
+               return -1;
+       }
+       if (adjust_shared_perm(lk->lock_filename.buf)) {
+               error("cannot fix permission bits on %s", 
lk->lock_filename.buf);
+               rollback_lock_file(lk);
+               return -1;
+       }
+
        return lk->fd;
 }
 
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to