@@ -1049,7 +1049,7 @@ int mingw_chmod(const char *filename, int mode)
1049
1049
*/
1050
1050
static int has_valid_directory_prefix (wchar_t * wfilename )
1051
1051
{
1052
- int n = wcslen (wfilename );
1052
+ size_t n = wcslen (wfilename );
1053
1053
1054
1054
while (n > 0 ) {
1055
1055
wchar_t c = wfilename [-- n ];
@@ -1628,7 +1628,8 @@ static const char *parse_interpreter(const char *cmd)
1628
1628
{
1629
1629
static char buf [MAX_PATH ];
1630
1630
char * p , * opt ;
1631
- int n , fd ;
1631
+ ssize_t n ; /* read() can return negative values */
1632
+ int fd ;
1632
1633
1633
1634
/* don't even try a .exe */
1634
1635
n = strlen (cmd );
@@ -1752,7 +1753,7 @@ static char *path_lookup(const char *cmd, int exe_only)
1752
1753
{
1753
1754
const char * path ;
1754
1755
char * prog = NULL ;
1755
- int len = strlen (cmd );
1756
+ size_t len = strlen (cmd );
1756
1757
int isexe = len >= 4 && !strcasecmp (cmd + len - 4 , ".exe" );
1757
1758
1758
1759
if (strpbrk (cmd , "/\\" ))
@@ -2389,7 +2390,7 @@ char *mingw_getenv(const char *name)
2389
2390
#define GETENV_MAX_RETAIN 64
2390
2391
static char * values [GETENV_MAX_RETAIN ];
2391
2392
static int value_counter ;
2392
- int len_key , len_value ;
2393
+ size_t len_key , len_value ;
2393
2394
wchar_t * w_key ;
2394
2395
char * value ;
2395
2396
wchar_t w_value [32768 ];
@@ -2401,7 +2402,8 @@ char *mingw_getenv(const char *name)
2401
2402
/* We cannot use xcalloc() here because that uses getenv() itself */
2402
2403
w_key = calloc (len_key , sizeof (wchar_t ));
2403
2404
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 );
2405
2407
xutftowcs (w_key , name , len_key );
2406
2408
/* GetEnvironmentVariableW() only sets the last error upon failure */
2407
2409
SetLastError (ERROR_SUCCESS );
@@ -2416,7 +2418,8 @@ char *mingw_getenv(const char *name)
2416
2418
/* We cannot use xcalloc() here because that uses getenv() itself */
2417
2419
value = calloc (len_value , sizeof (char ));
2418
2420
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 );
2420
2423
xwcstoutf (value , w_value , len_value );
2421
2424
2422
2425
/*
@@ -2434,7 +2437,7 @@ char *mingw_getenv(const char *name)
2434
2437
2435
2438
int mingw_putenv (const char * namevalue )
2436
2439
{
2437
- int size ;
2440
+ size_t size ;
2438
2441
wchar_t * wide , * equal ;
2439
2442
BOOL result ;
2440
2443
@@ -2444,7 +2447,8 @@ int mingw_putenv(const char *namevalue)
2444
2447
size = strlen (namevalue ) * 2 + 1 ;
2445
2448
wide = calloc (size , sizeof (wchar_t ));
2446
2449
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 );
2448
2452
xutftowcs (wide , namevalue , size );
2449
2453
equal = wcschr (wide , L'=' );
2450
2454
if (!equal )
@@ -4072,7 +4076,8 @@ static BOOL WINAPI handle_ctrl_c(DWORD ctrl_type)
4072
4076
*/
4073
4077
int wmain (int argc , const wchar_t * * wargv )
4074
4078
{
4075
- int i , maxlen , exit_status ;
4079
+ int i , exit_status ;
4080
+ size_t maxlen ;
4076
4081
char * buffer , * * save ;
4077
4082
const char * * argv ;
4078
4083
0 commit comments