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

@ -31,9 +31,7 @@
wchar_t *utf16to32(const char16_t *p, size_t n, size_t *z) {
wint_t x, y;
wchar_t *r, *q;
unsigned m, j, w;
const char16_t *e;
int16_t v1[8], v2[8], v3[8], vz[8];
if (z) *z = 0;
if (n == -1) n = p ? strlen16(p) : 0;
if ((q = r = malloc(n * 4 + 8 + 1))) {

View file

@ -41,9 +41,9 @@ static const int16_t kDel16[8] = {127, 127, 127, 127, 127, 127, 127, 127};
* @param z if non-NULL receives output length
*/
char *utf16to8(const char16_t *p, size_t n, size_t *z) {
unsigned w;
char *r, *q;
wint_t x, y;
unsigned m, j, w;
const char16_t *e;
int16_t v1[8], v2[8], v3[8], vz[8];
if (z) *z = 0;

View file

@ -37,7 +37,6 @@
* @param z if non-NULL receives output length
*/
wchar_t *utf8to32(const char *p, size_t n, size_t *z) {
int e;
size_t i;
unsigned m, j;
wint_t x, a, b;

View file

@ -3,7 +3,7 @@
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
char *xasprintf(const char *, ...) printfesque(1) paramsnonnull((1))
char *xasprintf(const char *, ...) paramsnonnull((1))
returnspointerwithnoaliases dontthrow nocallback dontdiscard returnsnonnull;
char *xvasprintf(const char *, va_list) paramsnonnull()
returnspointerwithnoaliases dontthrow nocallback dontdiscard returnsnonnull;

View file

@ -31,9 +31,9 @@
* @note this is uninterruptible
*/
int xbarf(const char *path, const void *data, size_t size) {
char *p;
ssize_t rc;
int fd, res;
const char *p;
size_t i, wrote;
res = 0;
p = data;

View file

@ -26,8 +26,9 @@
*/
char *xbasename(const char *path) {
char *base;
path = xstrdup(path);
base = xstrdup(basename(path));
free(path);
char *path2;
path2 = xstrdup(path);
base = xstrdup(basename(path2));
free(path2);
return base;
}

View file

@ -25,8 +25,9 @@
*/
char *xdirname(const char *path) {
char *dirp;
path = xstrdup(path);
dirp = xstrdup(dirname(path));
free(path);
char *path2;
path2 = xstrdup(path);
dirp = xstrdup(dirname(path2));
free(path2);
return dirp;
}

View file

@ -25,7 +25,6 @@
* Returns home directory.
*/
char *xhomedir(void) {
int fd;
const char *a, *b;
if ((a = getenv("HOME"))) {
b = "";

View file

@ -33,8 +33,8 @@
*/
void *xslurp(const char *path, size_t *opt_out_size) {
int fd;
char *res;
size_t i, got;
char *res, *p;
ssize_t rc, size;
res = NULL;
if ((fd = open(path, O_RDONLY)) != -1) {

View file

@ -25,7 +25,7 @@
*/
char *xstrmul(const char *s, size_t n) {
char *p;
size_t i, m, size;
size_t i, m;
m = strlen(s);
p = xcalloc(n + 1, m);
for (i = 0; i < n; ++i) memcpy(p + i * m, s, m);