From 0fb19906b5eb8fff9af59531aacd023920a24495 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Fri, 23 Oct 2015 08:02:51 +0200 Subject: [PATCH 1/2] read_branches_file: plug a FILE* leak The earlier rewrite f28e3ab2 (read_branches_file: simplify string handling) of read_branches_file() lost an fclose() call. Put it back. As on Windows files that are open cannot be removed, the leak manifests in a failure of 'git remote rename origin origin' when the remote's URL is specified in .git/branches/origin, because by the time that the command attempts to remove this file, it is still open. Signed-off-by: Johannes Sixt Acked-by: Jeff King Signed-off-by: Junio C Hamano --- remote.c | 1 + 1 file changed, 1 insertion(+) diff --git a/remote.c b/remote.c index 1101f82eaf..fb161530cd 100644 --- a/remote.c +++ b/remote.c @@ -282,6 +282,7 @@ static void read_branches_file(struct remote *remote) return; strbuf_getline(&buf, f, '\n'); + fclose(f); strbuf_trim(&buf); if (!buf.len) { strbuf_release(&buf); From d62c89afb278ab625dd399222ceb8d48b0358756 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Fri, 23 Oct 2015 08:02:52 +0200 Subject: [PATCH 2/2] compat/mingw.c: remove printf format warning 5096d490 (convert trivial sprintf / strcpy calls to xsnprintf) converted two sprintf calls. Now GCC warns that "format '%u' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int'". Instead of changing the format string, use a variable of type unsigned in place of the typedef-ed type DWORD, which hides that it is actually an unsigned long. There is no correctness issue with the old code because unsigned long and unsigned are always of the same size on Windows, even in 64-bit builds. Signed-off-by: Johannes Sixt Acked-by: Jeff King Signed-off-by: Junio C Hamano --- compat/mingw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/mingw.c b/compat/mingw.c index a168800ae0..90bdb1edde 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2131,7 +2131,7 @@ void mingw_startup() int uname(struct utsname *buf) { - DWORD v = GetVersion(); + unsigned v = (unsigned)GetVersion(); memset(buf, 0, sizeof(*buf)); xsnprintf(buf->sysname, sizeof(buf->sysname), "Windows"); xsnprintf(buf->release, sizeof(buf->release),