Git fork

compat/win32: fix -Wsign-compare warning in "wWinMain()"

GCC generates a warning in "headless.c" because we compare `slash` with
`size`, where the former is an `int` and the latter is a `size_t`. Fix
the warning by storing `slash` as a `size_t`, as well.

This commit is being singled out because the file does not include the
"git-compat-util.h" header, and consequently, we cannot easily mark it
with the `DISABLE_SIGN_COMPARE_WARNING` macro.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
709fdce0 6e1d0ce4

+9 -8
+9 -8
compat/win32/headless.c
··· 53 53 wchar_t git_command_line[32768]; 54 54 size_t size = sizeof(git_command_line) / sizeof(wchar_t); 55 55 const wchar_t *needs_quotes = L""; 56 - int slash = 0, i; 56 + size_t slash = 0; 57 + int len; 57 58 58 59 STARTUPINFO startup_info = { 59 60 .cb = sizeof(STARTUPINFO), ··· 66 67 DWORD exit_code; 67 68 68 69 /* First, determine the full path of argv[0] */ 69 - for (i = 0; _wpgmptr[i]; i++) 70 + for (size_t i = 0; _wpgmptr[i]; i++) 70 71 if (_wpgmptr[i] == L' ') 71 72 needs_quotes = L"\""; 72 73 else if (_wpgmptr[i] == L'\\') ··· 79 80 extend_path(_wpgmptr, slash); 80 81 81 82 /* Then, add the full path of `git.exe` as argv[0] */ 82 - i = swprintf_s(git_command_line, size, L"%ls%.*ls\\git.exe%ls", 83 - needs_quotes, slash, _wpgmptr, needs_quotes); 84 - if (i < 0) 83 + len = swprintf_s(git_command_line, size, L"%ls%.*ls\\git.exe%ls", 84 + needs_quotes, (int) slash, _wpgmptr, needs_quotes); 85 + if (len < 0) 85 86 return 127; /* Too long path */ 86 87 87 88 if (*command_line) { 88 89 /* Now, append the command-line arguments */ 89 - i = swprintf_s(git_command_line + i, size - i, 90 - L" %ls", command_line); 91 - if (i < 0) 90 + len = swprintf_s(git_command_line + len, size - len, 91 + L" %ls", command_line); 92 + if (len < 0) 92 93 return 127; 93 94 } 94 95