All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Luiz Fernando N. Capitulino" <lcapitulino@mandriva.com.br>
To: junkio@cox.net
Cc: Git List <git@vger.kernel.org>
Subject: [PATCH 3/5] read_cache_from(): small simplification
Date: Wed, 25 Apr 2007 11:18:17 -0300	[thread overview]
Message-ID: <20070425111817.4d4e4af5@localhost> (raw)

This change 'opens' the code block which maps the index file into
memory, making the code clearer and easier to read.

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
---
 read-cache.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index d2f332a..24e5581 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -856,15 +856,15 @@ int read_cache_from(const char *path)
 		die("index file open failed (%s)", strerror(errno));
 	}
 
-	if (!fstat(fd, &st)) {
-		cache_mmap_size = xsize_t(st.st_size);
-		errno = EINVAL;
-		if (cache_mmap_size >= sizeof(struct cache_header) + 20)
-			cache_mmap = xmmap(NULL, cache_mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
-		else
-			die("index file smaller than expected");
-	} else
+	if (fstat(fd, &st))
 		die("cannot stat the open index (%s)", strerror(errno));
+
+	errno = EINVAL;
+	cache_mmap_size = xsize_t(st.st_size);
+	if (cache_mmap_size < sizeof(struct cache_header) + 20)
+		die("index file smaller than expected");
+
+	cache_mmap = xmmap(NULL, cache_mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
 	close(fd);
 
 	hdr = cache_mmap;
-- 
1.5.1.1.320.g1cf2

                 reply	other threads:[~2007-04-25 14:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070425111817.4d4e4af5@localhost \
    --to=lcapitulino@mandriva.com.br \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.