@@ -813,7 +813,7 @@ static inline void filetime_to_timespec(const FILETIME *ft, struct timespec *ts)
813813 */
814814static int has_valid_directory_prefix (wchar_t * wfilename )
815815{
816- int n = wcslen (wfilename );
816+ size_t n = wcslen (wfilename );
817817
818818 while (n > 0 ) {
819819 wchar_t c = wfilename [-- n ];
@@ -1390,7 +1390,8 @@ static const char *parse_interpreter(const char *cmd)
13901390{
13911391 static char buf [MAX_PATH ];
13921392 char * p , * opt ;
1393- int n , fd ;
1393+ ssize_t n ; /* read() can return negative values */
1394+ int fd ;
13941395
13951396 /* don't even try a .exe */
13961397 n = strlen (cmd );
@@ -1455,7 +1456,7 @@ static char *path_lookup(const char *cmd, int exe_only)
14551456{
14561457 const char * path ;
14571458 char * prog = NULL ;
1458- int len = strlen (cmd );
1459+ size_t len = strlen (cmd );
14591460 int isexe = len >= 4 && !strcasecmp (cmd + len - 4 , ".exe" );
14601461
14611462 if (strpbrk (cmd , "/\\" ))
@@ -2072,7 +2073,7 @@ char *mingw_getenv(const char *name)
20722073#define GETENV_MAX_RETAIN 64
20732074 static char * values [GETENV_MAX_RETAIN ];
20742075 static int value_counter ;
2075- int len_key , len_value ;
2076+ size_t len_key , len_value ;
20762077 wchar_t * w_key ;
20772078 char * value ;
20782079 wchar_t w_value [32768 ];
@@ -2084,7 +2085,8 @@ char *mingw_getenv(const char *name)
20842085 /* We cannot use xcalloc() here because that uses getenv() itself */
20852086 w_key = calloc (len_key , sizeof (wchar_t ));
20862087 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 );
20882090 xutftowcs (w_key , name , len_key );
20892091 /* GetEnvironmentVariableW() only sets the last error upon failure */
20902092 SetLastError (ERROR_SUCCESS );
@@ -2099,7 +2101,8 @@ char *mingw_getenv(const char *name)
20992101 /* We cannot use xcalloc() here because that uses getenv() itself */
21002102 value = calloc (len_value , sizeof (char ));
21012103 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 );
21032106 xwcstoutf (value , w_value , len_value );
21042107
21052108 /*
@@ -2117,7 +2120,7 @@ char *mingw_getenv(const char *name)
21172120
21182121int mingw_putenv (const char * namevalue )
21192122{
2120- int size ;
2123+ size_t size ;
21212124 wchar_t * wide , * equal ;
21222125 BOOL result ;
21232126
@@ -2127,7 +2130,8 @@ int mingw_putenv(const char *namevalue)
21272130 size = strlen (namevalue ) * 2 + 1 ;
21282131 wide = calloc (size , sizeof (wchar_t ));
21292132 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 );
21312135 xutftowcs (wide , namevalue , size );
21322136 equal = wcschr (wide , L'=' );
21332137 if (!equal )
@@ -3454,7 +3458,8 @@ static void maybe_redirect_std_handles(void)
34543458 */
34553459int wmain (int argc , const wchar_t * * wargv )
34563460{
3457- int i , maxlen , exit_status ;
3461+ int i , exit_status ;
3462+ size_t maxlen ;
34583463 char * buffer , * * save ;
34593464 const char * * argv ;
34603465
0 commit comments