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

@ -38,7 +38,6 @@ typedef long long v2di __attribute__((__vector_size__(16), __aligned__(1)));
* @return pointer to EOCD64 or EOCD, otherwise null
*/
void *GetZipEocd(const void *f, size_t n, int *e) {
v2di x;
int err;
size_t i, j;
uint32_t magic;
@ -53,7 +52,7 @@ void *GetZipEocd(const void *f, size_t n, int *e) {
READ16LE("PK"), READ16LE("PK"), READ16LE("PK"), READ16LE("PK")};
asm("" : "+x"(pk));
if (i >= 14) {
x = *(const v2di *)(p + i - 14);
v2di x = *(const v2di *)(p + i - 14);
if (!(__builtin_ia32_pmovmskb128(
(v16qi)__builtin_ia32_pcmpeqw128((v8hi)x, pk)) |
__builtin_ia32_pmovmskb128((v16qi)__builtin_ia32_pcmpeqw128(
@ -70,7 +69,7 @@ void *GetZipEocd(const void *f, size_t n, int *e) {
}
if (magic == kZipCdir64LocatorMagic && i + kZipCdir64LocatorSize <= n &&
(err = IsZipEocd64(p, n, ZIP_LOCATE64_OFFSET(p + i))) == kZipOk) {
return p + ZIP_LOCATE64_OFFSET(p + i);
return (void *)(p + ZIP_LOCATE64_OFFSET(p + i));
} else if (magic == kZipCdirHdrMagic &&
(err = IsZipEocd32(p, n, i)) == kZipOk) {
j = i;
@ -78,10 +77,10 @@ void *GetZipEocd(const void *f, size_t n, int *e) {
if (READ32LE(p + j) == kZipCdir64LocatorMagic &&
j + kZipCdir64LocatorSize <= n &&
IsZipEocd64(p, n, ZIP_LOCATE64_OFFSET(p + j)) == kZipOk) {
return p + ZIP_LOCATE64_OFFSET(p + j);
return (void *)(p + ZIP_LOCATE64_OFFSET(p + j));
}
} while (j-- && i - j < 128);
return p + i;
return (void *)(p + i);
}
} while (i > 0 && i-- + 0x10000 + 0x1000 >= n);
if (e) *e = err;