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

@ -22,6 +22,7 @@
#include "libc/dce.h"
#include "libc/elf/def.h"
#include "libc/elf/struct/ehdr.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/intrin/bits.h"
#include "libc/limits.h"
@ -36,7 +37,6 @@
#include "libc/sysv/consts/o.h"
#include "libc/sysv/consts/prot.h"
#include "third_party/getopt/getopt.internal.h"
#include "libc/errno.h"
#include "third_party/regex/regex.h"
#define VERSION \
@ -194,7 +194,7 @@ static int GetElfArch(void) {
static void GetElfHeader(Elf64_Ehdr *ehdr, const char *image, size_t n) {
int c, i;
char *p, *e;
const char *p, *e;
for (p = image, e = p + MIN(n, 8192); p < e; ++p) {
TryAgain:
if (READ64LE(p) != READ64LE("printf '")) continue;
@ -383,7 +383,7 @@ static int GetMode(int fd) {
}
static void CopyFile(int infd, const char *map, size_t size, //
void *hdr, size_t hdrsize) {
const void *hdr, size_t hdrsize) {
int outfd;
if (!outpath) return;
if ((outfd = creat(outpath, GetMode(infd))) == -1) DieSys(outpath);
@ -393,7 +393,7 @@ static void CopyFile(int infd, const char *map, size_t size, //
}
static void WriteOutput(int infd, const char *map, size_t size, //
void *hdr, size_t hdrsize) {
const void *hdr, size_t hdrsize) {
int outfd, oflags, omode;
if (outpath) {
CopyFile(infd, map, size, hdr, hdrsize);