@@ -782,7 +782,7 @@ static inline void filetime_to_timespec(const FILETIME *ft, struct timespec *ts)
782
782
*/
783
783
static int has_valid_directory_prefix (wchar_t * wfilename )
784
784
{
785
- int n = wcslen (wfilename );
785
+ size_t n = wcslen (wfilename );
786
786
787
787
while (n > 0 ) {
788
788
wchar_t c = wfilename [-- n ];
@@ -891,7 +891,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
891
891
*/
892
892
static int do_stat_internal (int follow , const char * file_name , struct stat * buf )
893
893
{
894
- int namelen ;
894
+ size_t namelen ;
895
895
char alt_name [PATH_MAX ];
896
896
897
897
if (!do_lstat (follow , file_name , buf ))
@@ -1274,7 +1274,8 @@ static const char *parse_interpreter(const char *cmd)
1274
1274
{
1275
1275
static char buf [100 ];
1276
1276
char * p , * opt ;
1277
- int n , fd ;
1277
+ ssize_t n ; /* read() can return negative values */
1278
+ int fd ;
1278
1279
1279
1280
/* don't even try a .exe */
1280
1281
n = strlen (cmd );
@@ -1339,7 +1340,7 @@ static char *path_lookup(const char *cmd, int exe_only)
1339
1340
{
1340
1341
const char * path ;
1341
1342
char * prog = NULL ;
1342
- int len = strlen (cmd );
1343
+ size_t len = strlen (cmd );
1343
1344
int isexe = len >= 4 && !strcasecmp (cmd + len - 4 , ".exe" );
1344
1345
1345
1346
if (strpbrk (cmd , "/\\" ))
@@ -1956,7 +1957,7 @@ char *mingw_getenv(const char *name)
1956
1957
#define GETENV_MAX_RETAIN 64
1957
1958
static char * values [GETENV_MAX_RETAIN ];
1958
1959
static int value_counter ;
1959
- int len_key , len_value ;
1960
+ size_t len_key , len_value ;
1960
1961
wchar_t * w_key ;
1961
1962
char * value ;
1962
1963
wchar_t w_value [32768 ];
@@ -1968,7 +1969,8 @@ char *mingw_getenv(const char *name)
1968
1969
/* We cannot use xcalloc() here because that uses getenv() itself */
1969
1970
w_key = calloc (len_key , sizeof (wchar_t ));
1970
1971
if (!w_key )
1971
- die ("Out of memory, (tried to allocate %u wchar_t's)" , len_key );
1972
+ die ("Out of memory, (tried to allocate %" PRIuMAX " wchar_t's)" ,
1973
+ (uintmax_t )len_key );
1972
1974
xutftowcs (w_key , name , len_key );
1973
1975
/* GetEnvironmentVariableW() only sets the last error upon failure */
1974
1976
SetLastError (ERROR_SUCCESS );
@@ -1983,7 +1985,8 @@ char *mingw_getenv(const char *name)
1983
1985
/* We cannot use xcalloc() here because that uses getenv() itself */
1984
1986
value = calloc (len_value , sizeof (char ));
1985
1987
if (!value )
1986
- die ("Out of memory, (tried to allocate %u bytes)" , len_value );
1988
+ die ("Out of memory, (tried to allocate %" PRIuMAX " bytes)" ,
1989
+ (uintmax_t )len_value );
1987
1990
xwcstoutf (value , w_value , len_value );
1988
1991
1989
1992
/*
@@ -2001,7 +2004,7 @@ char *mingw_getenv(const char *name)
2001
2004
2002
2005
int mingw_putenv (const char * namevalue )
2003
2006
{
2004
- int size ;
2007
+ size_t size ;
2005
2008
wchar_t * wide , * equal ;
2006
2009
BOOL result ;
2007
2010
@@ -2011,7 +2014,8 @@ int mingw_putenv(const char *namevalue)
2011
2014
size = strlen (namevalue ) * 2 + 1 ;
2012
2015
wide = calloc (size , sizeof (wchar_t ));
2013
2016
if (!wide )
2014
- die ("Out of memory, (tried to allocate %u wchar_t's)" , size );
2017
+ die ("Out of memory, (tried to allocate %" PRIuMAX " wchar_t's)" ,
2018
+ (uintmax_t )size );
2015
2019
xutftowcs (wide , namevalue , size );
2016
2020
equal = wcschr (wide , L'=' );
2017
2021
if (!equal )
@@ -3085,7 +3089,8 @@ static void maybe_redirect_std_handles(void)
3085
3089
*/
3086
3090
int wmain (int argc , const wchar_t * * wargv )
3087
3091
{
3088
- int i , maxlen , exit_status ;
3092
+ int i , exit_status ;
3093
+ size_t maxlen ;
3089
3094
char * buffer , * * save ;
3090
3095
const char * * argv ;
3091
3096
0 commit comments