@@ -813,7 +813,7 @@ static inline void filetime_to_timespec(const FILETIME *ft, struct timespec *ts)
813
813
*/
814
814
static int has_valid_directory_prefix (wchar_t * wfilename )
815
815
{
816
- int n = wcslen (wfilename );
816
+ size_t n = wcslen (wfilename );
817
817
818
818
while (n > 0 ) {
819
819
wchar_t c = wfilename [-- n ];
@@ -1390,7 +1390,8 @@ static const char *parse_interpreter(const char *cmd)
1390
1390
{
1391
1391
static char buf [MAX_PATH ];
1392
1392
char * p , * opt ;
1393
- int n , fd ;
1393
+ ssize_t n ; /* read() can return negative values */
1394
+ int fd ;
1394
1395
1395
1396
/* don't even try a .exe */
1396
1397
n = strlen (cmd );
@@ -1455,7 +1456,7 @@ static char *path_lookup(const char *cmd, int exe_only)
1455
1456
{
1456
1457
const char * path ;
1457
1458
char * prog = NULL ;
1458
- int len = strlen (cmd );
1459
+ size_t len = strlen (cmd );
1459
1460
int isexe = len >= 4 && !strcasecmp (cmd + len - 4 , ".exe" );
1460
1461
1461
1462
if (strpbrk (cmd , "/\\" ))
@@ -2072,7 +2073,7 @@ char *mingw_getenv(const char *name)
2072
2073
#define GETENV_MAX_RETAIN 64
2073
2074
static char * values [GETENV_MAX_RETAIN ];
2074
2075
static int value_counter ;
2075
- int len_key , len_value ;
2076
+ size_t len_key , len_value ;
2076
2077
wchar_t * w_key ;
2077
2078
char * value ;
2078
2079
wchar_t w_value [32768 ];
@@ -2084,7 +2085,8 @@ char *mingw_getenv(const char *name)
2084
2085
/* We cannot use xcalloc() here because that uses getenv() itself */
2085
2086
w_key = calloc (len_key , sizeof (wchar_t ));
2086
2087
if (!w_key )
2087
- die ("Out of memory, (tried to allocate %u wchar_t's)" , len_key );
2088
+ die ("Out of memory, (tried to allocate %" PRIuMAX " wchar_t's)" ,
2089
+ (uintmax_t )len_key );
2088
2090
xutftowcs (w_key , name , len_key );
2089
2091
/* GetEnvironmentVariableW() only sets the last error upon failure */
2090
2092
SetLastError (ERROR_SUCCESS );
@@ -2099,7 +2101,8 @@ char *mingw_getenv(const char *name)
2099
2101
/* We cannot use xcalloc() here because that uses getenv() itself */
2100
2102
value = calloc (len_value , sizeof (char ));
2101
2103
if (!value )
2102
- die ("Out of memory, (tried to allocate %u bytes)" , len_value );
2104
+ die ("Out of memory, (tried to allocate %" PRIuMAX " bytes)" ,
2105
+ (uintmax_t )len_value );
2103
2106
xwcstoutf (value , w_value , len_value );
2104
2107
2105
2108
/*
@@ -2117,7 +2120,7 @@ char *mingw_getenv(const char *name)
2117
2120
2118
2121
int mingw_putenv (const char * namevalue )
2119
2122
{
2120
- int size ;
2123
+ size_t size ;
2121
2124
wchar_t * wide , * equal ;
2122
2125
BOOL result ;
2123
2126
@@ -2127,7 +2130,8 @@ int mingw_putenv(const char *namevalue)
2127
2130
size = strlen (namevalue ) * 2 + 1 ;
2128
2131
wide = calloc (size , sizeof (wchar_t ));
2129
2132
if (!wide )
2130
- die ("Out of memory, (tried to allocate %u wchar_t's)" , size );
2133
+ die ("Out of memory, (tried to allocate %" PRIuMAX " wchar_t's)" ,
2134
+ (uintmax_t )size );
2131
2135
xutftowcs (wide , namevalue , size );
2132
2136
equal = wcschr (wide , L'=' );
2133
2137
if (!equal )
@@ -3454,7 +3458,8 @@ static void maybe_redirect_std_handles(void)
3454
3458
*/
3455
3459
int wmain (int argc , const wchar_t * * wargv )
3456
3460
{
3457
- int i , maxlen , exit_status ;
3461
+ int i , exit_status ;
3462
+ size_t maxlen ;
3458
3463
char * buffer , * * save ;
3459
3464
const char * * argv ;
3460
3465
0 commit comments