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

@ -51,7 +51,7 @@
#define MRS_TPIDR_EL0 0xd53bd040u
#define MOV_REG(DST, SRC) (0xaa0003e0u | (SRC) << 16 | (DST))
static const unsigned char kFatNops[8][8] = {
const unsigned char kFatNops[8][8] = {
{}, //
{0x90}, // nop
{0x66, 0x90}, // xchg %ax,%ax
@ -68,9 +68,9 @@ static char *symstrs;
static char *secstrs;
static ssize_t esize;
static Elf64_Sym *syms;
static Elf64_Ehdr *elf;
static const char *epath;
static Elf64_Xword symcount;
static const Elf64_Ehdr *elf;
static wontreturn void Die(const char *reason) {
tinyprint(2, epath, ": ", reason, "\n", NULL);
@ -139,11 +139,10 @@ static void GetOpts(int argc, char *argv[]) {
}
static void CheckPrivilegedCrossReferences(void) {
long i;
unsigned long x;
Elf64_Shdr *shdr;
const char *secname;
Elf64_Rela *rela, *erela;
const Elf64_Shdr *shdr;
const Elf64_Rela *rela, *erela;
shdr = FindElfSectionByName(elf, esize, secstrs, ".rela.privileged");
if (!shdr || !(rela = GetElfSectionAddress(elf, esize, shdr))) return;
erela = rela + shdr->sh_size / sizeof(*rela);
@ -170,7 +169,7 @@ static void CheckPrivilegedCrossReferences(void) {
// Modify ARM64 code to use x28 for TLS rather than tpidr_el0.
static void RewriteTlsCode(void) {
int i, dest;
int i;
Elf64_Shdr *shdr;
uint32_t *p, *pe;
for (i = 0; i < elf->e_shnum; ++i) {
@ -205,7 +204,6 @@ static void RewriteTlsCode(void) {
static void OptimizePatchableFunctionEntries(void) {
#ifdef __x86_64__
long i, n;
int nopcount;
Elf64_Shdr *shdr;
unsigned char *p, *pe;
for (i = 0; i < symcount; ++i) {
@ -365,7 +363,7 @@ static void FixupObject(void) {
}
int main(int argc, char *argv[]) {
int i, opt;
int i;
if (!IsOptimized()) {
ShowCrashReports();
}