Merge branch 'sk/msvc-warnings' into next

Fixes compile time warnings with 64-bit MSVC.

* sk/msvc-warnings:
  mingw.c: Fix complier warnings for a 64 bit msvc
This commit is contained in:
Taylor Blau
2024-10-18 14:51:13 -04:00
committed by Johannes Schindelin
3 changed files with 20 additions and 11 deletions

View File

@@ -9,7 +9,7 @@
static inline void get_compiler_info(struct strbuf *info)
{
int len = info->len;
size_t len = info->len;
#ifdef __clang__
strbuf_addf(info, "clang: %s\n", __clang_version__);
#elif defined(__GNUC__)
@@ -27,7 +27,7 @@ static inline void get_compiler_info(struct strbuf *info)
static inline void get_libc_info(struct strbuf *info)
{
int len = info->len;
size_t len = info->len;
#ifdef __GLIBC__
strbuf_addf(info, "glibc: %s\n", gnu_get_libc_version());

View File

@@ -1049,7 +1049,7 @@ int mingw_chmod(const char *filename, int mode)
*/
static int has_valid_directory_prefix(wchar_t *wfilename)
{
int n = wcslen(wfilename);
size_t n = wcslen(wfilename);
while (n > 0) {
wchar_t c = wfilename[--n];
@@ -1628,7 +1628,8 @@ static const char *parse_interpreter(const char *cmd)
{
static char buf[MAX_PATH];
char *p, *opt;
int n, fd;
ssize_t n; /* read() can return negative values */
int fd;
/* don't even try a .exe */
n = strlen(cmd);
@@ -1752,7 +1753,7 @@ static char *path_lookup(const char *cmd, int exe_only)
{
const char *path;
char *prog = NULL;
int len = strlen(cmd);
size_t len = strlen(cmd);
int isexe = len >= 4 && !strcasecmp(cmd+len-4, ".exe");
if (strpbrk(cmd, "/\\"))
@@ -2389,7 +2390,7 @@ char *mingw_getenv(const char *name)
#define GETENV_MAX_RETAIN 64
static char *values[GETENV_MAX_RETAIN];
static int value_counter;
int len_key, len_value;
size_t len_key, len_value;
wchar_t *w_key;
char *value;
wchar_t w_value[32768];
@@ -2401,7 +2402,8 @@ char *mingw_getenv(const char *name)
/* We cannot use xcalloc() here because that uses getenv() itself */
w_key = calloc(len_key, sizeof(wchar_t));
if (!w_key)
die("Out of memory, (tried to allocate %u wchar_t's)", len_key);
die("Out of memory, (tried to allocate %"PRIuMAX" wchar_t's)",
(uintmax_t)len_key);
xutftowcs(w_key, name, len_key);
/* GetEnvironmentVariableW() only sets the last error upon failure */
SetLastError(ERROR_SUCCESS);
@@ -2416,7 +2418,8 @@ char *mingw_getenv(const char *name)
/* We cannot use xcalloc() here because that uses getenv() itself */
value = calloc(len_value, sizeof(char));
if (!value)
die("Out of memory, (tried to allocate %u bytes)", len_value);
die("Out of memory, (tried to allocate %"PRIuMAX" bytes)",
(uintmax_t)len_value);
xwcstoutf(value, w_value, len_value);
/*
@@ -2434,7 +2437,7 @@ char *mingw_getenv(const char *name)
int mingw_putenv(const char *namevalue)
{
int size;
size_t size;
wchar_t *wide, *equal;
BOOL result;
@@ -2444,7 +2447,8 @@ int mingw_putenv(const char *namevalue)
size = strlen(namevalue) * 2 + 1;
wide = calloc(size, sizeof(wchar_t));
if (!wide)
die("Out of memory, (tried to allocate %u wchar_t's)", size);
die("Out of memory, (tried to allocate %" PRIuMAX " wchar_t's)",
(uintmax_t)size);
xutftowcs(wide, namevalue, size);
equal = wcschr(wide, L'=');
if (!equal)
@@ -4072,7 +4076,8 @@ static BOOL WINAPI handle_ctrl_c(DWORD ctrl_type)
*/
int wmain(int argc, const wchar_t **wargv)
{
int i, maxlen, exit_status;
int i, exit_status;
size_t maxlen;
char *buffer, **save;
const char **argv;

View File

@@ -14,7 +14,11 @@ typedef _mode_t mode_t;
#ifndef _SSIZE_T_
#define _SSIZE_T_
#ifdef _WIN64
typedef __int64 _ssize_t;
#else
typedef long _ssize_t;
#endif /* _WIN64 */
#ifndef _OFF_T_
#define _OFF_T_