Fix warnings

This change fixes Cosmopolitan so it has fewer opinions about compiler
warnings. The whole repository had to be cleaned up to be buildable in
-Werror -Wall mode. This lets us benefit from things like strict const
checking. Some actual bugs might have been caught too.
This commit is contained in:
Justine Tunney 2023-09-01 20:49:13 -07:00
parent e2b3c3618e
commit 0d748ad58e
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
571 changed files with 1306 additions and 1888 deletions

View file

@ -220,7 +220,7 @@ static void put_16(unsigned char *s, unsigned c, int e)
static unsigned get_32(const unsigned char *s, int e)
{
e &= 3;
return s[e]+0U<<24 | s[e^1]<<16 | s[e^2]<<8 | s[e^3];
return (s[e]+0U)<<24 | s[e^1]<<16 | s[e^2]<<8 | s[e^3];
}
static void put_32(unsigned char *s, unsigned c, int e)
@ -240,7 +240,7 @@ static unsigned legacy_map(const unsigned char *map, unsigned c)
{
if (c < 4*map[-1]) return c;
unsigned x = c - 4*map[-1];
x = map[x*5/4]>>2*x%8 | map[x*5/4+1]<<8-2*x%8 & 1023;
x = (map[x*5/4]>>(2*x%8)) | ((map[x*5/4+1]<<(8-(2*x%8))) & 1023);
return x < 256 ? x : legacy_chars[x-256];
}
@ -535,7 +535,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri
if (c >= 93 || d >= 94) {
c += (0xa1-0x81);
d += 0xa1;
if (c >= 93 || c>=0xc6-0x81 && d>0x52)
if (c >= 93 || ((c>=0xc6-0x81) && d>0x52))
goto ilseq;
if (d-'A'<26) d = d-'A';
else if (d-'a'<26) d = d-'a'+26;