mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 10:48:29 +00:00
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:
parent
e2b3c3618e
commit
0d748ad58e
571 changed files with 1306 additions and 1888 deletions
|
@ -17,7 +17,7 @@ int snprintf(char *, size_t, const char *, ...)
|
|||
printfesque(3) dontthrow nocallback;
|
||||
int vsnprintf(char *, size_t, const char *, va_list)
|
||||
dontthrow nocallback;
|
||||
int sprintf(char *, const char *, ...) printfesque(2) dontthrow nocallback;
|
||||
int sprintf(char *, const char *, ...) dontthrow nocallback;
|
||||
int vsprintf(char *, const char *, va_list)
|
||||
dontthrow nocallback;
|
||||
int sscanf(const char *, const char *, ...) scanfesque(2);
|
||||
|
|
|
@ -14,7 +14,7 @@ char *sleb64(char *, int64_t);
|
|||
char *zleb64(char[hasatleast 10], int64_t);
|
||||
char *uleb64(char[hasatleast 10], uint64_t);
|
||||
int unzleb64(const char *, size_t, int64_t *);
|
||||
int unuleb64(char *, size_t, uint64_t *);
|
||||
int unuleb64(const char *, size_t, uint64_t *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* _COSMO_SOURCE */
|
||||
|
|
|
@ -28,9 +28,9 @@ extern const struct MagnumStr kSockOptnames[];
|
|||
extern const struct MagnumStr kTcpOptnames[];
|
||||
extern const struct MagnumStr kPollNames[];
|
||||
|
||||
char *DescribeMagnum(char *, const struct MagnumStr *, const char *, int);
|
||||
const char *DescribeMagnum(char *, const struct MagnumStr *, const char *, int);
|
||||
|
||||
__funline char *GetMagnumStr(const struct MagnumStr *ms, int x) {
|
||||
__funline const char *GetMagnumStr(const struct MagnumStr *ms, int x) {
|
||||
int i;
|
||||
for (i = 0; ms[i].x != MAGNUM_TERMINATOR; ++i) {
|
||||
if (x == MAGNUM_NUMBER(ms, i)) {
|
||||
|
@ -44,7 +44,7 @@ __funline char *GetMagnumStr(const struct MagnumStr *ms, int x) {
|
|||
* Converts errno value to descriptive sentence.
|
||||
* @return non-null rodata string or null if not found
|
||||
*/
|
||||
__funline char *_strerdoc(int x) {
|
||||
__funline const char *_strerdoc(int x) {
|
||||
if (x) {
|
||||
return GetMagnumStr(kErrnoDocs, x);
|
||||
} else {
|
||||
|
@ -56,7 +56,7 @@ __funline char *_strerdoc(int x) {
|
|||
* Converts errno value to symbolic name.
|
||||
* @return non-null rodata string or null if not found
|
||||
*/
|
||||
__funline char *_strerrno(int x) {
|
||||
__funline const char *_strerrno(int x) {
|
||||
if (x) {
|
||||
return GetMagnumStr(kErrnoNames, x);
|
||||
} else {
|
||||
|
|
|
@ -53,7 +53,7 @@ long strtol(const char *s, char **endptr, int base) {
|
|||
char t = 0;
|
||||
long x = 0;
|
||||
int d, c = *s;
|
||||
CONSUME_SPACES(s, c);
|
||||
CONSUME_SPACES(char, s, c);
|
||||
GET_SIGN(s, c, d);
|
||||
GET_RADIX(s, c, base);
|
||||
if ((c = kBase36[c & 255]) && --c < base) {
|
||||
|
@ -67,7 +67,9 @@ long strtol(const char *s, char **endptr, int base) {
|
|||
} while ((c = kBase36[*++s & 255]) && --c < base);
|
||||
}
|
||||
}
|
||||
if (t && endptr) *endptr = s;
|
||||
if (t && endptr) {
|
||||
*endptr = (char *)s;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#define COSMOPOLITAN_LIBC_FMT_STRTOL_H_
|
||||
#include "libc/errno.h"
|
||||
|
||||
#define CONSUME_SPACES(s, c) \
|
||||
if (endptr) *endptr = s; \
|
||||
#define CONSUME_SPACES(t, s, c) \
|
||||
if (endptr) *endptr = (t *)(s); \
|
||||
while (c == ' ' || c == '\t') c = *++s
|
||||
|
||||
#define GET_SIGN(s, c, d) \
|
||||
|
|
|
@ -42,20 +42,24 @@ unsigned long strtoul(const char *s, char **endptr, int base) {
|
|||
char t = 0;
|
||||
int d, c = *s;
|
||||
unsigned long x = 0;
|
||||
CONSUME_SPACES(s, c);
|
||||
CONSUME_SPACES(char, s, c);
|
||||
GET_SIGN(s, c, d);
|
||||
GET_RADIX(s, c, base);
|
||||
if ((c = kBase36[c & 255]) && --c < base) {
|
||||
t |= 1;
|
||||
do {
|
||||
if (ckd_mul(&x, x, base) || ckd_add(&x, x, c)) {
|
||||
if (endptr) *endptr = s + 1;
|
||||
if (endptr) {
|
||||
*endptr = (char *)(s + 1);
|
||||
}
|
||||
errno = ERANGE;
|
||||
return ULONG_MAX;
|
||||
}
|
||||
} while ((c = kBase36[*++s & 255]) && --c < base);
|
||||
}
|
||||
if (t && endptr) *endptr = s;
|
||||
if (t && endptr) {
|
||||
*endptr = (char *)s;
|
||||
}
|
||||
return d > 0 ? x : -x;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* @param x receives number number
|
||||
* @return bytes decoded or -1 on error
|
||||
*/
|
||||
int unuleb64(char *p, size_t n, uint64_t *x) {
|
||||
int unuleb64(const char *p, size_t n, uint64_t *x) {
|
||||
int k;
|
||||
size_t i;
|
||||
uint64_t t;
|
||||
|
|
|
@ -41,7 +41,7 @@ long wcstol(const wchar_t *s, wchar_t **endptr, int base) {
|
|||
char t = 0;
|
||||
long x = 0;
|
||||
int d, c = *s;
|
||||
CONSUME_SPACES(s, c);
|
||||
CONSUME_SPACES(wchar_t, s, c);
|
||||
GET_SIGN(s, c, d);
|
||||
GET_RADIX(s, c, base);
|
||||
if ((c = kBase36[c & 255]) && --c < base) {
|
||||
|
@ -55,7 +55,9 @@ long wcstol(const wchar_t *s, wchar_t **endptr, int base) {
|
|||
} while ((c = kBase36[*++s & 255]) && --c < base);
|
||||
}
|
||||
}
|
||||
if (t && endptr) *endptr = s;
|
||||
if (t && endptr) {
|
||||
*endptr = (wchar_t *)s;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,20 +41,24 @@ unsigned long wcstoul(const wchar_t *s, wchar_t **endptr, int base) {
|
|||
char t = 0;
|
||||
int d, c = *s;
|
||||
unsigned long x = 0;
|
||||
CONSUME_SPACES(s, c);
|
||||
CONSUME_SPACES(wchar_t, s, c);
|
||||
GET_SIGN(s, c, d);
|
||||
GET_RADIX(s, c, base);
|
||||
if ((c = kBase36[c & 255]) && --c < base) {
|
||||
t |= 1;
|
||||
do {
|
||||
if (ckd_mul(&x, x, base) || ckd_add(&x, x, c)) {
|
||||
if (endptr) *endptr = s + 1;
|
||||
if (endptr) {
|
||||
*endptr = (wchar_t *)(s + 1);
|
||||
}
|
||||
errno = ERANGE;
|
||||
return ULONG_MAX;
|
||||
}
|
||||
} while ((c = kBase36[*++s & 255]) && --c < base);
|
||||
}
|
||||
if (t && endptr) *endptr = s;
|
||||
if (t && endptr) {
|
||||
*endptr = (wchar_t *)s;
|
||||
}
|
||||
return d > 0 ? x : -x;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue