git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH] close clobbers mmap's errno in read_cache
Date: Fri, 7 Oct 2005 23:45:51 +0200	[thread overview]
Message-ID: <20051007214551.GA8893@steel.home> (raw)

Save errno before close(fd) for strerror in die().

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>

--- a/read-cache.c	2005-10-03 09:16:31.000000000 +0200
+++ b/read-cache.c	2005-10-07 23:23:40.000000000 +0200
@@ -482,9 +482,10 @@ int read_cache(void)
 		if (size >= sizeof(struct cache_header) + 20)
 			map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
 	}
+	i = errno;
 	close(fd);
 	if (map == MAP_FAILED)
-		die("index file mmap failed (%s)", strerror(errno));
+		die("index file mmap failed (%s)", strerror(i));
 
 	hdr = map;
 	if (verify_hdr(hdr, size) < 0)

             reply	other threads:[~2005-10-07 21:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-07 21:45 Alex Riesen [this message]
2005-10-07 21:48 ` [PATCH] close clobbers mmap's errno in read_cache Sven Verdoolaege
2005-10-07 23:50   ` Alex Riesen

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=20051007214551.GA8893@steel.home \
    --to=raa.lkml@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).