refs.c: remove lock_fd from struct ref_lock

The 'lock_fd' is the same as 'lk->fd'. No need to store it twice so remove it. No functional changes intended. Signed-off-by: Stefan Beller <sbeller@google.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Apr 16, 2015 at 16:17 UTC 1238ac8c5d8a49c8d56e711ea9e65202fb4a1573
1 file changed +5 -10
refs.c
+5 -10
@@ -11,7 +11,6 @@ struct ref_lock {
11 char *orig_ref_name;
12 struct lock_file *lk;
13 unsigned char old_sha1[20];
14 - int lock_fd;
14 };
15
16 /*
@@ -2284,7 +2283,6 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
2283 int attempts_remaining = 3;
2284
2285 lock = xcalloc(1, sizeof(struct ref_lock));
2287 - lock->lock_fd = -1;
2286
2287 if (mustexist)
2288 resolve_flags |= RESOLVE_REF_READING;
@@ -2356,8 +2354,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
2354 goto error_return;
2355 }
2356
2359 - lock->lock_fd = hold_lock_file_for_update(lock->lk, ref_file, lflags);
2360 - if (lock->lock_fd < 0) {
2357 + if (hold_lock_file_for_update(lock->lk, ref_file, lflags) < 0) {
2358 last_errno = errno;
2359 if (errno == ENOENT && --attempts_remaining > 0)
2360 /*
@@ -2868,7 +2865,6 @@ static int close_ref(struct ref_lock *lock)
2865 {
2866 if (close_lock_file(lock->lk))
2867 return -1;
2871 - lock->lock_fd = -1;
2868 return 0;
2869 }
2870
@@ -2876,7 +2872,6 @@ static int commit_ref(struct ref_lock *lock)
2872 {
2873 if (commit_lock_file(lock->lk))
2874 return -1;
2879 - lock->lock_fd = -1;
2875 return 0;
2876 }
2877
@@ -3046,8 +3041,8 @@ static int write_ref_sha1(struct ref_lock *lock,
3041 errno = EINVAL;
3042 return -1;
3043 }
3049 - if (write_in_full(lock->lock_fd, sha1_to_hex(sha1), 40) != 40 ||
3050 - write_in_full(lock->lock_fd, &term, 1) != 1 ||
3044 + if (write_in_full(lock->lk->fd, sha1_to_hex(sha1), 40) != 40 ||
3045 + write_in_full(lock->lk->fd, &term, 1) != 1 ||
3046 close_ref(lock) < 0) {
3047 int save_errno = errno;
3048 error("Couldn't write %s", lock->lk->filename.buf);
@@ -4084,9 +4079,9 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
4079 status |= error("couldn't write %s: %s", log_file,
4080 strerror(errno));
4081 } else if (update &&
4087 - (write_in_full(lock->lock_fd,
4082 + (write_in_full(lock->lk->fd,
4083 sha1_to_hex(cb.last_kept_sha1), 40) != 40 ||
4089 - write_str_in_full(lock->lock_fd, "\n") != 1 ||
4084 + write_str_in_full(lock->lk->fd, "\n") != 1 ||
4085 close_ref(lock) < 0)) {
4086 status |= error("couldn't write %s",
4087 lock->lk->filename.buf);