@@ -1049,7 +1049,7 @@ int mingw_chmod(const char *filename, int mode)
10491049 */
10501050static int has_valid_directory_prefix (wchar_t * wfilename )
10511051{
1052- int n = wcslen (wfilename );
1052+ size_t n = wcslen (wfilename );
10531053
10541054 while (n > 0 ) {
10551055 wchar_t c = wfilename [-- n ];
@@ -1628,7 +1628,8 @@ static const char *parse_interpreter(const char *cmd)
16281628{
16291629 static char buf [MAX_PATH ];
16301630 char * p , * opt ;
1631- int n , fd ;
1631+ ssize_t n ; /* read() can return negative values */
1632+ int fd ;
16321633
16331634 /* don't even try a .exe */
16341635 n = strlen (cmd );
@@ -1752,7 +1753,7 @@ static char *path_lookup(const char *cmd, int exe_only)
17521753{
17531754 const char * path ;
17541755 char * prog = NULL ;
1755- int len = strlen (cmd );
1756+ size_t len = strlen (cmd );
17561757 int isexe = len >= 4 && !strcasecmp (cmd + len - 4 , ".exe" );
17571758
17581759 if (strpbrk (cmd , "/\\" ))
@@ -2389,7 +2390,7 @@ char *mingw_getenv(const char *name)
23892390#define GETENV_MAX_RETAIN 64
23902391 static char * values [GETENV_MAX_RETAIN ];
23912392 static int value_counter ;
2392- int len_key , len_value ;
2393+ size_t len_key , len_value ;
23932394 wchar_t * w_key ;
23942395 char * value ;
23952396 wchar_t w_value [32768 ];
@@ -2401,7 +2402,8 @@ char *mingw_getenv(const char *name)
24012402 /* We cannot use xcalloc() here because that uses getenv() itself */
24022403 w_key = calloc (len_key , sizeof (wchar_t ));
24032404 if (!w_key )
2404- die ("Out of memory, (tried to allocate %u wchar_t's)" , len_key );
2405+ die ("Out of memory, (tried to allocate %" PRIuMAX " wchar_t's)" ,
2406+ (uintmax_t )len_key );
24052407 xutftowcs (w_key , name , len_key );
24062408 /* GetEnvironmentVariableW() only sets the last error upon failure */
24072409 SetLastError (ERROR_SUCCESS );
@@ -2416,7 +2418,8 @@ char *mingw_getenv(const char *name)
24162418 /* We cannot use xcalloc() here because that uses getenv() itself */
24172419 value = calloc (len_value , sizeof (char ));
24182420 if (!value )
2419- die ("Out of memory, (tried to allocate %u bytes)" , len_value );
2421+ die ("Out of memory, (tried to allocate %" PRIuMAX " bytes)" ,
2422+ (uintmax_t )len_value );
24202423 xwcstoutf (value , w_value , len_value );
24212424
24222425 /*
@@ -2434,7 +2437,7 @@ char *mingw_getenv(const char *name)
24342437
24352438int mingw_putenv (const char * namevalue )
24362439{
2437- int size ;
2440+ size_t size ;
24382441 wchar_t * wide , * equal ;
24392442 BOOL result ;
24402443
@@ -2444,7 +2447,8 @@ int mingw_putenv(const char *namevalue)
24442447 size = strlen (namevalue ) * 2 + 1 ;
24452448 wide = calloc (size , sizeof (wchar_t ));
24462449 if (!wide )
2447- die ("Out of memory, (tried to allocate %u wchar_t's)" , size );
2450+ die ("Out of memory, (tried to allocate %" PRIuMAX " wchar_t's)" ,
2451+ (uintmax_t )size );
24482452 xutftowcs (wide , namevalue , size );
24492453 equal = wcschr (wide , L'=' );
24502454 if (!equal )
@@ -4072,7 +4076,8 @@ static BOOL WINAPI handle_ctrl_c(DWORD ctrl_type)
40724076 */
40734077int wmain (int argc , const wchar_t * * wargv )
40744078{
4075- int i , maxlen , exit_status ;
4079+ int i , exit_status ;
4080+ size_t maxlen ;
40764081 char * buffer , * * save ;
40774082 const char * * argv ;
40784083
0 commit comments