git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Clean up compatibility definitions.

From
Alex Riesen <raa.lkml@gmail.com>
Date
Dec 6, 2005, 08:07 UTC
Message-ID
<81b0412b0512060007s589e1d0dr4f47da68a7f3567a@mail.gmail.com>
In-Reply-To
<7vk6ei65r6.fsf@assigned-by-dhcp.cox.net>
On 12/6/05, Junio C Hamano <junkio@cox.net> wrote:
> > ... return MAP_FAILED if error, do not
> > exit process, do no output.
> Ah, that is what you meant.  I agree.

now, while we agree, how about the patch removing "user interface" from gitfakemmap altogether? The patch is not really tested (running tests is not useful in this case), but I looked over the call sites, and they seem either to handle mmap's or the previous open's return values. One exception is in config.c where neither is handled, the code will race between stat and open.

Signed-off-by: Alex Riesen <fork0@gmail.com>
cleanup mmap fake. No need to output anything, callers handle the return value
Signed-off-by: Alex Riesen <fork0@gmail.com>
---
 compat/mmap.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
311da12b7aaca9b7329a07807e1ce4afba4bff77
diff --git a/compat/mmap.c b/compat/mmap.c
index 55cb120..32d7a30 100644
--- a/compat/mmap.c
+++ b/compat/mmap.c
@@ -8,15 +8,17 @@ void *gitfakemmap(void *start, size_t le
 {
 	int n = 0;
 
-	if (start != NULL || !(flags & MAP_PRIVATE))
-		die("Invalid usage of gitfakemmap.");
+	if (start != NULL || !(flags & MAP_PRIVATE)) {
+		errno = ENOTSUP;
+		return MAP_FAILED;
+	}
 
 	if (lseek(fd, offset, SEEK_SET) < 0) {
 		errno = EINVAL;
 		return MAP_FAILED;
 	}
 
-	start = xmalloc(length);
+	start = malloc(length);
 	if (start == NULL) {
 		errno = ENOMEM;
 		return MAP_FAILED;
-- 
0.99.9.GIT
Previous: Junio C HamanoNext: Junio C Hamano
Message 16 of 23 in “make gitfakemmap standalone to fix linking error in git.c”
  1. Alex RiesenDec 5, 2005
  2. Alex RiesenDec 5, 2005
  3. Petr BaudisDec 5, 2005
  4. Alex RiesenDec 5, 2005
  5. Junio C HamanoDec 5, 2005
  6. Clean up compatibility definitions.Junio C Hamano, Dec 5, 2005
  7. Johannes SchindelinDec 5, 2005
  8. Junio C HamanoDec 5, 2005
  9. Alex RiesenDec 5, 2005
  10. Alex RiesenDec 6, 2005
  11. Junio C HamanoDec 6, 2005
  12. Alex RiesenDec 5, 2005
  13. Junio C HamanoDec 5, 2005
  14. Alex RiesenDec 6, 2005
  15. Junio C HamanoDec 6, 2005
  16. Alex RiesenDec 6, 2005
  17. Junio C HamanoDec 6, 2005
  18. Petr BaudisDec 5, 2005
  19. Junio C HamanoDec 6, 2005
  20. Petr BaudisDec 6, 2005
  21. Alex RiesenDec 5, 2005
  22. Junio C HamanoDec 5, 2005
  23. Alex RiesenDec 6, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.