mirror of
https://git.savannah.gnu.org/git/make.git
synced 2025-01-12 16:45:35 +00:00
Clean up some warnings on Windows builds
* src/arscan.c (parse_int): Avoid conversion from int to char and check for overflow given a max value. (ar_scan): Check intmax sizes then cast to the proper type. (ar_member_touch): Get proper return type from ar_scan and cast it to off_t. * src/function.c (a_word_hash_cmp): Don't cast from size_t to int. (func_filter_filterout): Count using unsigned long to avoid casts. (construct_include_path): Explicitly cast to void*. * src/shuffle.c (reverse_shuffle_array): Use size_t index. * src/w32/subproc/sub_proc.c (process_wait_for_multiple_objects): Initialize the return value in case the count is 0.
This commit is contained in:
parent
7ddfc42ee3
commit
3e20e376b7
5 changed files with 44 additions and 24 deletions
47
src/arscan.c
47
src/arscan.c
|
@ -376,15 +376,17 @@ struct ar_hdr
|
|||
# define AR_HDR_SIZE (sizeof (struct ar_hdr))
|
||||
#endif
|
||||
|
||||
#include "intprops.h"
|
||||
|
||||
#include "output.h"
|
||||
|
||||
|
||||
static uintmax_t
|
||||
parse_int (const char *ptr, const size_t len, const int base,
|
||||
parse_int (const char *ptr, const size_t len, const int base, uintmax_t max,
|
||||
const char *type, const char *archive, const char *name)
|
||||
{
|
||||
const char *const ep = ptr + len;
|
||||
const char max = '0' + base - 1;
|
||||
const int maxchar = '0' + base - 1;
|
||||
uintmax_t val = 0;
|
||||
|
||||
/* In all the versions I know of the spaces come last, but be safe. */
|
||||
|
@ -393,10 +395,16 @@ parse_int (const char *ptr, const size_t len, const int base,
|
|||
|
||||
while (ptr < ep && *ptr != ' ')
|
||||
{
|
||||
if (*ptr < '0' || *ptr > max)
|
||||
OSSS (fatal, NILF, _("Invalid %s for archive %s member %s"),
|
||||
type, archive, name);
|
||||
val = (val * base) + (*ptr - '0');
|
||||
uintmax_t nv;
|
||||
|
||||
if (*ptr < '0' || *ptr > maxchar)
|
||||
OSSS (fatal, NILF,
|
||||
_("Invalid %s for archive %s member %s"), type, archive, name);
|
||||
nv = (val * base) + (*ptr - '0');
|
||||
if (nv < val || nv > max)
|
||||
OSSS (fatal, NILF,
|
||||
_("Invalid %s for archive %s member %s"), type, archive, name);
|
||||
val = nv;
|
||||
++ptr;
|
||||
}
|
||||
|
||||
|
@ -562,6 +570,8 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
|
|||
#endif
|
||||
long int eltsize;
|
||||
unsigned int eltmode;
|
||||
intmax_t eltdate;
|
||||
int eltuid, eltgid;
|
||||
intmax_t fnval;
|
||||
off_t o;
|
||||
|
||||
|
@ -732,8 +742,16 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
|
|||
}
|
||||
|
||||
#ifndef M_XENIX
|
||||
eltmode = parse_int (TOCHAR (member_header.ar_mode), sizeof (member_header.ar_mode), 8, "mode", archive, name);
|
||||
eltsize = parse_int (TOCHAR (member_header.ar_size), sizeof (member_header.ar_size), 10, "size", archive, name);
|
||||
#define PARSE_INT(_m, _t, _b, _n) \
|
||||
(_t) parse_int (TOCHAR (member_header._m), sizeof (member_header._m), \
|
||||
_b, TYPE_MAXIMUM (_t), _n, archive, name)
|
||||
|
||||
eltmode = PARSE_INT (ar_mode, unsigned int, 8, "mode");
|
||||
eltsize = PARSE_INT (ar_size, long, 10, "size");
|
||||
eltdate = PARSE_INT (ar_date, intmax_t, 10, "date");
|
||||
eltuid = PARSE_INT (ar_uid, int, 10, "uid");
|
||||
eltgid = PARSE_INT (ar_gid, int, 10, "gid");
|
||||
#undef PARSE_INT
|
||||
#else /* Xenix. */
|
||||
eltmode = (unsigned short int) member_header.ar_mode;
|
||||
eltsize = member_header.ar_size;
|
||||
|
@ -743,9 +761,7 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
|
|||
(*function) (desc, name, ! long_name, member_offset,
|
||||
member_offset + AR_HDR_SIZE, eltsize,
|
||||
#ifndef M_XENIX
|
||||
parse_int (TOCHAR (member_header.ar_date), sizeof (member_header.ar_date), 10, "date", archive, name),
|
||||
parse_int (TOCHAR (member_header.ar_uid), sizeof (member_header.ar_uid), 10, "uid", archive, name),
|
||||
parse_int (TOCHAR (member_header.ar_gid), sizeof (member_header.ar_gid), 10, "gid", archive, name),
|
||||
eltdate, eltuid, eltgid,
|
||||
#else /* Xenix. */
|
||||
member_header.ar_date,
|
||||
member_header.ar_uid,
|
||||
|
@ -906,7 +922,8 @@ ar_member_pos (int desc UNUSED, const char *mem, int truncated,
|
|||
int
|
||||
ar_member_touch (const char *arname, const char *memname)
|
||||
{
|
||||
long int pos = ar_scan (arname, ar_member_pos, memname);
|
||||
intmax_t pos = ar_scan (arname, ar_member_pos, memname);
|
||||
off_t opos;
|
||||
int fd;
|
||||
struct ar_hdr ar_hdr;
|
||||
off_t o;
|
||||
|
@ -919,11 +936,13 @@ ar_member_touch (const char *arname, const char *memname)
|
|||
if (!pos)
|
||||
return 1;
|
||||
|
||||
opos = (off_t) pos;
|
||||
|
||||
EINTRLOOP (fd, open (arname, O_RDWR, 0666));
|
||||
if (fd < 0)
|
||||
return -3;
|
||||
/* Read in this member's header */
|
||||
EINTRLOOP (o, lseek (fd, pos, 0));
|
||||
EINTRLOOP (o, lseek (fd, opos, 0));
|
||||
if (o < 0)
|
||||
goto lose;
|
||||
r = readbuf (fd, &ar_hdr, AR_HDR_SIZE);
|
||||
|
@ -944,7 +963,7 @@ ar_member_touch (const char *arname, const char *memname)
|
|||
ar_hdr.ar_date = statbuf.st_mtime;
|
||||
#endif
|
||||
/* Write back this member's header */
|
||||
EINTRLOOP (o, lseek (fd, pos, 0));
|
||||
EINTRLOOP (o, lseek (fd, opos, 0));
|
||||
if (o < 0)
|
||||
goto lose;
|
||||
r = writebuf (fd, &ar_hdr, AR_HDR_SIZE);
|
||||
|
|
|
@ -985,12 +985,13 @@ a_word_hash_2 (const void *key)
|
|||
static int
|
||||
a_word_hash_cmp (const void *x, const void *y)
|
||||
{
|
||||
int result = (int) ((struct a_word const *) x)->length - ((struct a_word const *) y)->length;
|
||||
if (result)
|
||||
return result;
|
||||
return_STRING_N_COMPARE (((struct a_word const *) x)->str,
|
||||
((struct a_word const *) y)->str,
|
||||
((struct a_word const *) y)->length);
|
||||
const struct a_word *ax = x;
|
||||
const struct a_word *ay = y;
|
||||
|
||||
if (ax->length != ay->length)
|
||||
return ax->length > ay->length ? 1 : -1;
|
||||
|
||||
return_STRING_N_COMPARE (ax->str, ay->str, ax->length);
|
||||
}
|
||||
|
||||
struct a_pattern
|
||||
|
@ -1009,7 +1010,7 @@ func_filter_filterout (char *o, char **argv, const char *funcname)
|
|||
struct a_pattern *patterns;
|
||||
struct a_pattern *pat_end;
|
||||
struct a_pattern *pp;
|
||||
size_t pat_count = 0, word_count = 0;
|
||||
unsigned long pat_count = 0, word_count = 0;
|
||||
|
||||
struct hash_table a_word_table;
|
||||
int is_filter = funcname[CSTRLEN ("filter")] == '\0';
|
||||
|
|
|
@ -3071,7 +3071,7 @@ construct_include_path (const char **arg_dirs)
|
|||
do_variable_definition (NILF, ".INCLUDE_DIRS", *cpp,
|
||||
o_default, f_append, 0);
|
||||
|
||||
free (include_directories);
|
||||
free ((void *) include_directories);
|
||||
include_directories = dirs;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ reverse_shuffle_array (void **a, size_t len)
|
|||
void *t;
|
||||
|
||||
/* Pick mirror and swap. */
|
||||
unsigned int j = len - 1 - i;
|
||||
size_t j = len - 1 - i;
|
||||
|
||||
/* Swap. */
|
||||
t = a[i];
|
||||
|
|
|
@ -92,7 +92,7 @@ DWORD process_wait_for_multiple_objects(
|
|||
for (;;) {
|
||||
DWORD objectCount = nCount;
|
||||
int blockCount = 0;
|
||||
DWORD retVal;
|
||||
DWORD retVal = 0;
|
||||
|
||||
assert(bWaitAll == FALSE); /* This logic only works for this use case */
|
||||
assert(dwMilliseconds == 0 || dwMilliseconds == INFINITE); /* No support for timeouts */
|
||||
|
|
Loading…
Reference in a new issue