* [PATCH] close clobbers mmap's errno in read_cache
@ 2005-10-07 21:45 Alex Riesen
2005-10-07 21:48 ` Sven Verdoolaege
0 siblings, 1 reply; 3+ messages in thread
From: Alex Riesen @ 2005-10-07 21:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] close clobbers mmap's errno in read_cache
2005-10-07 21:45 [PATCH] close clobbers mmap's errno in read_cache Alex Riesen
@ 2005-10-07 21:48 ` Sven Verdoolaege
2005-10-07 23:50 ` Alex Riesen
0 siblings, 1 reply; 3+ messages in thread
From: Sven Verdoolaege @ 2005-10-07 21:48 UTC (permalink / raw)
To: Alex Riesen; +Cc: Junio C Hamano, git
On Fri, Oct 07, 2005 at 11:45:51PM +0200, Alex Riesen wrote:
> }
> + i = errno;
> close(fd);
> if (map == MAP_FAILED)
> - die("index file mmap failed (%s)", strerror(errno));
> + die("index file mmap failed (%s)", strerror(i));
>
Why don't you just move the close after the test ?
There's no point in closing if you're going to die.
skimo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] close clobbers mmap's errno in read_cache
2005-10-07 21:48 ` Sven Verdoolaege
@ 2005-10-07 23:50 ` Alex Riesen
0 siblings, 0 replies; 3+ messages in thread
From: Alex Riesen @ 2005-10-07 23:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
Sven Verdoolaege, Fri, Oct 07, 2005 23:48:45 +0200:
> On Fri, Oct 07, 2005 at 11:45:51PM +0200, Alex Riesen wrote:
> > }
> > + i = errno;
> > close(fd);
> > if (map == MAP_FAILED)
> > - die("index file mmap failed (%s)", strerror(errno));
> > + die("index file mmap failed (%s)", strerror(i));
> >
>
> Why don't you just move the close after the test ?
I don't know.
> There's no point in closing if you're going to die.
>
> skimo
Of course you're right :) I'm just blind after eight.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-10-07 23:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-07 21:45 [PATCH] close clobbers mmap's errno in read_cache Alex Riesen
2005-10-07 21:48 ` Sven Verdoolaege
2005-10-07 23:50 ` Alex Riesen
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).