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

@ -37,8 +37,8 @@ dontasan static inline const char *rawmemchr_sse(const char *s,
unsigned char c) {
unsigned k;
unsigned m;
xmm_t v, *p;
xmm_t n = {c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c};
const xmm_t *p;
xmm_t v, n = {c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c};
k = (uintptr_t)s & 15;
p = (const xmm_t *)((uintptr_t)s & -16);
v = *p;
@ -54,7 +54,7 @@ dontasan static inline const char *rawmemchr_sse(const char *s,
}
#endif
static inline dontasan uint64_t UncheckedAlignedRead64(unsigned char *p) {
static inline dontasan uint64_t UncheckedAlignedRead64(const unsigned char *p) {
return (uint64_t)p[7] << 070 | (uint64_t)p[6] << 060 | (uint64_t)p[5] << 050 |
(uint64_t)p[4] << 040 | (uint64_t)p[3] << 030 | (uint64_t)p[2] << 020 |
(uint64_t)p[1] << 010 | (uint64_t)p[0] << 000;
@ -84,7 +84,7 @@ void *rawmemchr(const void *s, int c) {
c &= 255;
v = 0x0101010101010101ul * c;
for (; (uintptr_t)p & 7; ++p) {
if (*p == c) return p;
if (*p == c) return (void *)p;
}
for (;; p += 8) {
w = UncheckedAlignedRead64(p);
@ -94,6 +94,6 @@ void *rawmemchr(const void *s, int c) {
}
}
assert(*p == c);
return p;
return (void *)p;
#endif
}