mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-08 20:28:30 +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
|
@ -861,8 +861,6 @@ void FixupPeImage(char *map, size_t size, //
|
|||
Elf64_Sxword off_skew) {
|
||||
assert(!(rva_skew & 65535));
|
||||
|
||||
Elf64_Sxword skew = rva_skew;
|
||||
|
||||
// fixup pe header
|
||||
if (ckd_sub(&pe->OptionalHeader.ImageBase, //
|
||||
pe->OptionalHeader.ImageBase, rva_skew))
|
||||
|
@ -972,7 +970,6 @@ static void AddLoader(const char *path) {
|
|||
}
|
||||
|
||||
static void GetOpts(int argc, char *argv[]) {
|
||||
char *endptr;
|
||||
int opt, bits;
|
||||
bool got_support_vector = false;
|
||||
while ((opt = getopt(argc, argv, "hvgsGBo:l:S:M:V:")) != -1) {
|
||||
|
@ -1282,7 +1279,7 @@ static char *GenerateMachoSegment(char *p, struct Input *in, Elf64_Phdr *phdr) {
|
|||
load = (struct MachoLoadSegment *)p;
|
||||
load->command = MAC_LC_SEGMENT_64;
|
||||
load->size = sizeof(*load);
|
||||
FormatInt32(stpcpy(load->name, "__APE"), macholoadcount);
|
||||
FormatInt32(__veil("r", stpcpy(load->name, "__APE")), macholoadcount);
|
||||
++macholoadcount;
|
||||
load->vaddr = phdr->p_vaddr;
|
||||
load->memsz = phdr->p_memsz;
|
||||
|
@ -1482,9 +1479,7 @@ static char *SecondPass2(char *p, struct Input *in) {
|
|||
// focusing on embedding the executable files passed via the flags.
|
||||
static Elf64_Off ThirdPass(Elf64_Off offset, struct Input *in) {
|
||||
int i;
|
||||
char *data;
|
||||
Elf64_Addr vaddr;
|
||||
Elf64_Phdr *phdr;
|
||||
Elf64_Xword image_align;
|
||||
|
||||
// determine microprocessor page size
|
||||
|
@ -1814,9 +1809,8 @@ static void CopyZips(Elf64_Off offset) {
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
char *p;
|
||||
int i, j, opt;
|
||||
int i, j;
|
||||
Elf64_Off offset;
|
||||
char empty[64] = {0};
|
||||
Elf64_Xword prologue_bytes;
|
||||
#ifndef NDEBUG
|
||||
ShowCrashReports();
|
||||
|
|
|
@ -318,7 +318,7 @@ int main(int argc, char *argv[]) {
|
|||
if (argc < 3) {
|
||||
ShowUsage(1, 2);
|
||||
}
|
||||
const char *flags = argv[1];
|
||||
char *flags = argv[1];
|
||||
const char *outpath = argv[2];
|
||||
|
||||
// we only support one mode of operation, which is creating a new
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -31,10 +31,8 @@
|
|||
|
||||
void PrintMultiplyKernel(int n, int m) {
|
||||
bool cf, of;
|
||||
uint128_t x;
|
||||
bool *Rs, *Ra;
|
||||
int j, i, k1, k2, g;
|
||||
uint64_t *R, *H;
|
||||
printf("\
|
||||
/**\n\
|
||||
* Computes %d-bit product of %d-bit and %d-bit numbers.\n\
|
||||
|
@ -67,7 +65,7 @@ void Multiply%dx%d(uint64_t C[%d], const uint64_t A[%d], const uint64_t B[%d]) {
|
|||
(printf)("\
|
||||
asm(\"xorl\\t%%k0,%%k0\" : \"=r\"(z), \"+m\"(cf), \"+m\"(of));\n",
|
||||
j);
|
||||
for (cf = of = i = 0; i < n; ++i) {
|
||||
for (cf = of = false, i = 0; i < n; ++i) {
|
||||
if (!i) {
|
||||
if (!Rs[i + j] && !Rs[i + j + 1]) {
|
||||
assert(!cf);
|
||||
|
|
|
@ -58,7 +58,7 @@ static void GetOpts(int argc, char *argv[]) {
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i, mode;
|
||||
char buf[PATH_MAX], *endptr;
|
||||
char *endptr;
|
||||
prog = argv[0];
|
||||
if (!prog) prog = "chmod";
|
||||
GetOpts(argc, argv);
|
||||
|
|
|
@ -313,7 +313,6 @@ void PrintReset(void) {
|
|||
}
|
||||
|
||||
void PrintMakeCommand(void) {
|
||||
const char *s;
|
||||
appends(&output, "make MODE=");
|
||||
appends(&output, mode);
|
||||
appends(&output, " -j");
|
||||
|
@ -476,14 +475,15 @@ void AddArg(char *actual) {
|
|||
}
|
||||
appends(&command, s);
|
||||
if (!args.n) {
|
||||
appends(&shortened, StripPrefix(basename(s), "x86_64-linux-musl-"));
|
||||
appends(&shortened,
|
||||
StripPrefix(basename(gc(strdup(s))), "x86_64-linux-musl-"));
|
||||
} else if (*s != '-') {
|
||||
appendw(&shortened, ' ');
|
||||
if ((isar || isbfd || ispkg) &&
|
||||
(strcmp(args.p[args.n - 1], "-o") &&
|
||||
(endswith(s, ".o") || endswith(s, ".pkg") ||
|
||||
(endswith(s, ".a") && !isar)))) {
|
||||
appends(&shortened, basename(s));
|
||||
appends(&shortened, basename(gc(strdup(s))));
|
||||
} else {
|
||||
appends(&shortened, s);
|
||||
}
|
||||
|
@ -511,11 +511,11 @@ static int GetBaseCpuFreqMhz(void) {
|
|||
}
|
||||
|
||||
void SetCpuLimit(int secs) {
|
||||
int mhz, lim;
|
||||
struct rlimit rlim;
|
||||
if (secs <= 0) return;
|
||||
if (IsWindows()) return;
|
||||
#ifdef __x86_64__
|
||||
int mhz, lim;
|
||||
struct rlimit rlim;
|
||||
if (!(mhz = GetBaseCpuFreqMhz())) return;
|
||||
lim = ceil(3100. / mhz * secs);
|
||||
rlim.rlim_cur = lim;
|
||||
|
@ -851,13 +851,12 @@ char *MakeTmpOut(const char *path) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int columns;
|
||||
uint64_t us;
|
||||
bool isineditor;
|
||||
size_t i, j, n, m;
|
||||
bool isproblematic;
|
||||
char *s, *q, **envp;
|
||||
int ws, opt, exitcode;
|
||||
char *s, *p, *q, **envp;
|
||||
|
||||
#ifndef NDEBUG
|
||||
ShowCrashReports();
|
||||
|
@ -1070,7 +1069,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
#ifdef __x86_64__
|
||||
} else if (!strcmp(argv[i], "-march=native")) {
|
||||
struct X86ProcessorModel *model;
|
||||
const struct X86ProcessorModel *model;
|
||||
if (X86_HAVE(XOP)) AddArg("-mxop");
|
||||
if (X86_HAVE(SSE4A)) AddArg("-msse4a");
|
||||
if (X86_HAVE(SSE3)) AddArg("-msse3");
|
||||
|
|
|
@ -35,7 +35,7 @@ __attribute__((__constructor__)) void init(void) {
|
|||
for (i = j = 0; i < 2; ++i) {
|
||||
while ((c = s[j] & 255)) {
|
||||
++j;
|
||||
if ('0' <= c & c <= '9') {
|
||||
if ('0' <= c && c <= '9') {
|
||||
arg[i] *= 10;
|
||||
arg[i] += c - '0';
|
||||
} else {
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
// see tool/hello/hello-pe.c for an example program this can link
|
||||
// make -j8 m=tiny o/tiny/tool/hello/hello-pe.com
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||
|
||||
#define VERSION \
|
||||
"elf2pe v0.1\n" \
|
||||
"copyright 2023 justine tunney\n" \
|
||||
|
@ -273,7 +275,6 @@ static void RelocateRela(struct Elf *elf, struct Segment *segment,
|
|||
RelocateVaddrWithinSegment(elf, rela->r_offset, segment);
|
||||
Elf64_Addr symbol_vaddr = elf->symtab[ELF64_R_SYM(rela->r_info)].st_value;
|
||||
char *place_ptr = segment->ptr_new + (place_vaddr - segment->vaddr_new_min);
|
||||
Elf64_Sxword addend = rela->r_addend;
|
||||
switch (ELF64_R_TYPE(rela->r_info)) {
|
||||
case R_X86_64_NONE: // do nothing
|
||||
case R_X86_64_COPY: // do nothing
|
||||
|
@ -1032,7 +1033,6 @@ static struct ImagePointer GeneratePe(struct Elf *elf, char *fp, int64_t vp) {
|
|||
|
||||
static void GetOpts(int argc, char *argv[]) {
|
||||
int opt;
|
||||
char *endptr;
|
||||
while ((opt = getopt(argc, argv, "ho:D:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
|
|
|
@ -35,7 +35,6 @@ int main(int argc, char *argv[]) {
|
|||
int line;
|
||||
char *l1, *l2;
|
||||
FILE *f1, *f2;
|
||||
int differences;
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "usage: %s FILE1 FILE2\n", argv[0]);
|
||||
exit(1);
|
||||
|
@ -48,7 +47,7 @@ int main(int argc, char *argv[]) {
|
|||
perror(argv[2]);
|
||||
exit(1);
|
||||
}
|
||||
for (differences = 0, line = 1;; ++line) {
|
||||
for (line = 1;; ++line) {
|
||||
l1 = fgets(line1, sizeof(line1), f1);
|
||||
l2 = fgets(line2, sizeof(line2), f2);
|
||||
if (!l1 && !l2) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ void GetOpts(int argc, char *argv[]) {
|
|||
void Compress(const char *inpath) {
|
||||
FILE *input;
|
||||
gzFile output;
|
||||
int rc, n, errnum;
|
||||
int rc, errnum;
|
||||
const char *outpath;
|
||||
char *p, openflags[5];
|
||||
if ((!inpath || opt_usestdout) && (!isatty(1) || opt_force)) {
|
||||
|
|
|
@ -33,7 +33,6 @@ static bool IsSymbolChar2(char c) {
|
|||
}
|
||||
|
||||
static bool IsSymbolString(const char *s) {
|
||||
int i;
|
||||
if (!IsSymbolChar1(*s++)) return false;
|
||||
while (*s) {
|
||||
if (!IsSymbolChar2(*s++)) return false;
|
||||
|
@ -54,7 +53,8 @@ static bool IsSymbolString(const char *s) {
|
|||
*/
|
||||
struct Asmdown *ParseAsmdown(const char *code, size_t size) {
|
||||
struct Asmdown *ad;
|
||||
char *p1, *p2, *p3, *symbol, *alias;
|
||||
const char *p1;
|
||||
char *p2, *p3, *symbol, *alias;
|
||||
enum { BOL, COM, SYM, OTHER } state;
|
||||
int i, j, line, start_line, start_docstring, end_docstring, start_symbol;
|
||||
ad = calloc(1, sizeof(struct Asmdown));
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
/* TODO(jart): replace with new append*() library */
|
||||
|
||||
void AppendData(struct Buffer *b, char *data, unsigned len) {
|
||||
void AppendData(struct Buffer *b, const char *data, size_t len) {
|
||||
char *p;
|
||||
unsigned n;
|
||||
if (b->i + len + 1 > b->n) {
|
||||
|
@ -63,7 +63,6 @@ void AppendWide(struct Buffer *b, wint_t wc) {
|
|||
|
||||
int AppendFmt(struct Buffer *b, const char *fmt, ...) {
|
||||
int n;
|
||||
char *p;
|
||||
va_list va, vb;
|
||||
va_start(va, fmt);
|
||||
va_copy(vb, va);
|
||||
|
|
|
@ -9,7 +9,7 @@ struct Buffer {
|
|||
};
|
||||
|
||||
void AppendChar(struct Buffer *, char);
|
||||
void AppendData(struct Buffer *, char *, unsigned);
|
||||
void AppendData(struct Buffer *, const char *, size_t);
|
||||
void AppendStr(struct Buffer *, const char *);
|
||||
void AppendWide(struct Buffer *, wint_t);
|
||||
int AppendFmt(struct Buffer *, const char *, ...);
|
||||
|
|
|
@ -47,7 +47,7 @@ void SpawnCxxFilt(void) {
|
|||
if (!(g_cxxfilt.pid = vfork())) {
|
||||
dup2(pipefds[1][0], 0);
|
||||
dup2(pipefds[0][1], 1);
|
||||
execv(path, (char *const[]){cxxfilt, NULL});
|
||||
execv(path, (char *const[]){(char *)cxxfilt, 0});
|
||||
abort();
|
||||
}
|
||||
g_cxxfilt.reader = pipefds[0][0];
|
||||
|
@ -87,7 +87,7 @@ char *DemangleCxxFilt(char *p, size_t pn, const char *s, size_t sn) {
|
|||
if (!g_cxxfilt.pid) SpawnCxxFilt();
|
||||
if (g_cxxfilt.pid == -1) return NULL;
|
||||
buf[0] = '\n';
|
||||
iov[0].iov_base = s;
|
||||
iov[0].iov_base = (void *)s;
|
||||
iov[0].iov_len = sn;
|
||||
iov[1].iov_base = buf;
|
||||
iov[1].iov_len = 1;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "tool/build/lib/eztls.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/errno.h"
|
||||
|
@ -27,7 +28,6 @@
|
|||
#include "net/https/https.h"
|
||||
#include "third_party/mbedtls/net_sockets.h"
|
||||
#include "third_party/mbedtls/ssl.h"
|
||||
#include "tool/build/lib/eztls.h"
|
||||
|
||||
struct EzTlsBio ezbio;
|
||||
mbedtls_ssl_config ezconf;
|
||||
|
@ -72,7 +72,7 @@ int EzTlsFlush(struct EzTlsBio *bio, const unsigned char *buf, size_t len) {
|
|||
if (len || bio->c > 0) {
|
||||
v[0].iov_base = bio->u;
|
||||
v[0].iov_len = MAX(0, bio->c);
|
||||
v[1].iov_base = buf;
|
||||
v[1].iov_base = (void *)buf;
|
||||
v[1].iov_len = len;
|
||||
if (EzWritevAll(bio->fd, v, 2) != -1) {
|
||||
if (bio->c > 0) bio->c = 0;
|
||||
|
@ -90,7 +90,6 @@ int EzTlsFlush(struct EzTlsBio *bio, const unsigned char *buf, size_t len) {
|
|||
|
||||
static int EzTlsSend(void *ctx, const unsigned char *buf, size_t len) {
|
||||
int rc;
|
||||
struct iovec v[2];
|
||||
struct EzTlsBio *bio = ctx;
|
||||
if (bio->c >= 0 && bio->c + len <= sizeof(bio->u)) {
|
||||
memcpy(bio->u + bio->c, buf, len);
|
||||
|
@ -103,7 +102,6 @@ static int EzTlsSend(void *ctx, const unsigned char *buf, size_t len) {
|
|||
|
||||
static int EzTlsRecvImpl(void *ctx, unsigned char *p, size_t n, uint32_t o) {
|
||||
int r;
|
||||
ssize_t s;
|
||||
struct iovec v[2];
|
||||
struct EzTlsBio *bio = ctx;
|
||||
if ((r = EzTlsFlush(bio, 0, 0)) < 0) return r;
|
||||
|
|
|
@ -117,7 +117,6 @@ const char *getargs_next(struct GetArgs *ga) {
|
|||
int fd;
|
||||
char *p;
|
||||
size_t k;
|
||||
unsigned m;
|
||||
ssize_t size;
|
||||
for (;;) {
|
||||
if (ga->map) {
|
||||
|
@ -128,6 +127,7 @@ const char *getargs_next(struct GetArgs *ga) {
|
|||
}
|
||||
k = 0;
|
||||
#if defined(__SSE2__) && defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
unsigned m;
|
||||
typedef unsigned char xmm_t
|
||||
__attribute__((__vector_size__(16), __aligned__(1)));
|
||||
for (; ga->j + k + 16 <= ga->mapsize; k += 16) {
|
||||
|
|
|
@ -94,8 +94,8 @@ size_t interncount(const struct Interner *t) {
|
|||
size_t internobj(struct Interner *t, const void *data, size_t size) {
|
||||
char *p2;
|
||||
size_t n2;
|
||||
char *item;
|
||||
unsigned hash;
|
||||
const char *item;
|
||||
struct InternerObject *it;
|
||||
size_t i, off, step, need, bytes;
|
||||
step = 0;
|
||||
|
|
|
@ -120,7 +120,6 @@ static void SplitLines(struct Lines *lines, char *p) {
|
|||
}
|
||||
|
||||
static bool ConsumeFileOverview(struct Lines *lines) {
|
||||
int i;
|
||||
if (lines->n && lines->p[0].n >= strlen(FILEOVERVIEW) &&
|
||||
startswith(lines->p[0].p, FILEOVERVIEW)) {
|
||||
lines->p[0].p += strlen(FILEOVERVIEW);
|
||||
|
@ -192,10 +191,9 @@ static int ExtractText(struct Javadown *jd, struct Lines *lines, int i) {
|
|||
}
|
||||
|
||||
static void ExtractTags(struct Javadown *jd, struct Lines *lines, int i) {
|
||||
size_t n;
|
||||
char *p, *tag, *text, *p2;
|
||||
char *tag, *text, *p2;
|
||||
unsigned taglen, textlen, n2;
|
||||
for (p = NULL, n = 0; i < lines->n; ++i) {
|
||||
for (; i < lines->n; ++i) {
|
||||
if (!lines->p[i].n) continue;
|
||||
if (lines->p[i].p[0] != '@') continue;
|
||||
tag = lines->p[i].p + 1;
|
||||
|
|
|
@ -65,7 +65,6 @@ static int tpdecode(const char *s, wint_t *out) {
|
|||
ssize_t PrintPanels(int fd, long pn, struct Panel *p, long tyn, long txn) {
|
||||
wint_t wc;
|
||||
ssize_t rc;
|
||||
size_t wrote;
|
||||
struct Buffer b, *l;
|
||||
int x, y, i, j, width;
|
||||
enum { kUtf8, kAnsi, kAnsiCsi } state;
|
||||
|
|
|
@ -59,7 +59,7 @@ int main(int argc, char *argv[]) {
|
|||
const char *lz4path = "/dev/stdin";
|
||||
const char *outpath = "/dev/stdout";
|
||||
const char *initprio = "400,_init_";
|
||||
const unsigned char *lz4data;
|
||||
unsigned char *lz4data;
|
||||
int opt;
|
||||
FILE *fin, *fout;
|
||||
|
||||
|
@ -140,7 +140,7 @@ int main(int argc, char *argv[]) {
|
|||
fprintf(fout, "\n");
|
||||
fprintf(fout, "\t.init.start %s%s\n", initprio, symbol);
|
||||
fprintf(fout, "\tpush\t%%rsi\n");
|
||||
fprintf(fout, "\tmov\t$%u,%%edx\n", size);
|
||||
fprintf(fout, "\tmov\t$%zu,%%edx\n", size);
|
||||
fprintf(fout, "\tcall\tlz4cpy\n");
|
||||
if (misalign) {
|
||||
fprintf(fout, "\tlea\t%zu(%%rax),%%rdi\n", misalign);
|
||||
|
@ -148,7 +148,7 @@ int main(int argc, char *argv[]) {
|
|||
fprintf(fout, "\tmov\t%%rax,%%rdi\n");
|
||||
}
|
||||
fprintf(fout, "\tpop\t%%rsi\n");
|
||||
fprintf(fout, "\tadd\t$%u,%%rsi\n", ROUNDUP(size, 8));
|
||||
fprintf(fout, "\tadd\t$%zu,%%rsi\n", ROUNDUP(size, 8));
|
||||
fprintf(fout, "\t.init.end %s%s\n", initprio, symbol);
|
||||
|
||||
fprintf(fout, "\n");
|
||||
|
|
|
@ -111,7 +111,7 @@ int main(int argc, char *argv[]) {
|
|||
if (X86_HAVE(BMI2)) Puts("-mbmi2");
|
||||
if (X86_HAVE(ADX)) Puts("-madx");
|
||||
if (X86_HAVE(FXSR)) Puts("-mfxsr");
|
||||
if ((model = getx86processormodel(kX86ProcessorModelKey))) {
|
||||
if ((model = (void *)getx86processormodel(kX86ProcessorModelKey))) {
|
||||
switch (model->march) {
|
||||
case X86_MARCH_CORE2:
|
||||
Puts("-march=core2");
|
||||
|
|
|
@ -206,8 +206,8 @@ static void Crunch(void) {
|
|||
free(sources.p);
|
||||
sources.p = 0;
|
||||
sources.i = j;
|
||||
if (radix_sort_int64((const long *)sauces, sources.i) == -1 ||
|
||||
radix_sort_int64((const long *)edges.p, edges.i) == -1) {
|
||||
if (radix_sort_int64((long *)sauces, sources.i) == -1 ||
|
||||
radix_sort_int64((long *)edges.p, edges.i) == -1) {
|
||||
DieOom();
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ static void LoadRelationships(int argc, char *argv[]) {
|
|||
char *map;
|
||||
ssize_t rc;
|
||||
struct GetArgs ga;
|
||||
size_t i, n, size, inclen;
|
||||
size_t n, size, inclen;
|
||||
unsigned srcid, dependency;
|
||||
const char *p, *pe, *src, *path, *pathend;
|
||||
getargs_init(&ga, argv + optind);
|
||||
|
@ -368,7 +368,6 @@ static bool IsObjectSource(const char *name) {
|
|||
}
|
||||
|
||||
__funline bool Bts(uint32_t *p, size_t i) {
|
||||
bool r;
|
||||
uint32_t k;
|
||||
k = 1u << (i & 31);
|
||||
if (p[i >> 5] & k) return true;
|
||||
|
|
|
@ -158,7 +158,7 @@ char *Join(const char *a, const char *b) {
|
|||
|
||||
void Mv(char *src, char *dst) {
|
||||
ssize_t rc;
|
||||
const char *s, *d;
|
||||
const char *d;
|
||||
if (strlen(src) + 1 > PATH_MAX) _Exit(2);
|
||||
if (strlen(dst) + 1 > PATH_MAX) _Exit(2);
|
||||
basename(src);
|
||||
|
|
|
@ -325,7 +325,6 @@ static void HandleElf(const char *inpath, Elf64_Ehdr *elf, size_t esize) {
|
|||
int i, loadcount;
|
||||
Elf64_Off maxoff;
|
||||
Elf64_Phdr *phdr;
|
||||
char empty[64] = {0};
|
||||
Elf64_Shdr *macho_shdr;
|
||||
struct MachoHeader *macho;
|
||||
struct MachoLoadCommand *loadcommand;
|
||||
|
@ -416,7 +415,7 @@ static void HandleInput(const char *inpath) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i, opt;
|
||||
int i;
|
||||
prog = argv[0];
|
||||
if (!prog) prog = "objbincopy";
|
||||
GetOpts(argc, argv);
|
||||
|
|
|
@ -204,7 +204,7 @@ static void PrintObject(struct Package *pkg, struct Object *obj) {
|
|||
}
|
||||
|
||||
static void PrintPackage(struct Package *pkg) {
|
||||
int i, j, o;
|
||||
int i;
|
||||
kprintf("- %s\n", pkg->strings.p + pkg->path);
|
||||
kprintf(" objects=%d\n", pkg->objects.i);
|
||||
for (i = 0; i < pkg->objects.i; ++i) {
|
||||
|
@ -224,7 +224,7 @@ static void PrintPackages(struct Package *p, int n) {
|
|||
|
||||
static struct Package *LoadPackage(const char *path) {
|
||||
int fd;
|
||||
ssize_t i, size;
|
||||
ssize_t size;
|
||||
struct Package *pkg;
|
||||
if ((fd = open(path, O_RDONLY)) == -1) {
|
||||
SysExit(path, "open");
|
||||
|
@ -339,7 +339,7 @@ FLAGS\n\
|
|||
|
||||
static void GetOpts(struct Package *pkg, struct Packages *deps, int argc,
|
||||
char *argv[]) {
|
||||
long i, si, opt;
|
||||
long opt;
|
||||
const char *arg;
|
||||
struct GetArgs ga;
|
||||
pkg->path = -1;
|
||||
|
@ -381,10 +381,8 @@ static void GetOpts(struct Package *pkg, struct Packages *deps, int argc,
|
|||
static void IndexSections(struct Package *pkg, struct Object *obj) {
|
||||
int i;
|
||||
const char *name;
|
||||
const uint8_t *code;
|
||||
struct Section sect;
|
||||
const Elf64_Shdr *shdr;
|
||||
struct XedDecodedInst xedd;
|
||||
obj->section_offset = pkg->sections.i;
|
||||
for (i = 0; i < obj->elf->e_shnum; ++i) {
|
||||
bzero(§, sizeof(sect));
|
||||
|
@ -566,7 +564,7 @@ static struct Symbol *BisectSymbol(struct Package *pkg, const char *name) {
|
|||
static bool FindSymbol(const char *name, struct Package *pkg,
|
||||
struct Packages *directdeps, struct Package **out_pkg,
|
||||
struct Symbol **out_sym) {
|
||||
size_t i, j;
|
||||
size_t i;
|
||||
struct Symbol *sym;
|
||||
if ((sym = BisectSymbol(pkg, name))) {
|
||||
if (out_sym) *out_sym = sym;
|
||||
|
@ -607,7 +605,7 @@ static void CheckStrictDeps(struct Package *pkg, struct Packages *deps) {
|
|||
}
|
||||
|
||||
static void CheckYourPrivilege(struct Package *pkg, struct Packages *deps) {
|
||||
int i, j, o, f;
|
||||
int i, f;
|
||||
const char *name;
|
||||
struct Symbol *sym;
|
||||
struct Package *dep;
|
||||
|
@ -634,7 +632,7 @@ static bool IsSymbolDirectlyReachable(struct Package *pkg,
|
|||
|
||||
static void Package(int argc, char *argv[], struct Package *pkg,
|
||||
struct Packages *deps) {
|
||||
size_t i, j;
|
||||
size_t i;
|
||||
GetOpts(pkg, deps, argc, argv);
|
||||
LoadObjects(pkg);
|
||||
CheckStrictDeps(pkg, deps);
|
||||
|
|
|
@ -583,9 +583,7 @@ Finish:
|
|||
int main(int argc, char *argv[]) {
|
||||
const char *s;
|
||||
bool hasfunbits;
|
||||
int fdin, fdout;
|
||||
char buf[PATH_MAX];
|
||||
int e, zipfd, memfd;
|
||||
int useruid, usergid;
|
||||
int owneruid, ownergid;
|
||||
int oldfsuid, oldfsgid;
|
||||
|
|
|
@ -62,7 +62,7 @@ void Process(const char *p, const char *pe, const char *path, bool isheader) {
|
|||
int level;
|
||||
bool noformat;
|
||||
const char *p2, *dq, *name;
|
||||
for (noformat = level = 0; p < pe; p = p2) {
|
||||
for (noformat = false, level = 0; p < pe; p = p2) {
|
||||
p2 = memchr(p, '\n', pe - p);
|
||||
p2 = p2 ? p2 + 1 : pe;
|
||||
if (LOOKINGAT(p, pe, "#if")) {
|
||||
|
|
|
@ -230,15 +230,12 @@ bool Send(int tmpfd, const void *output, size_t outputsize) {
|
|||
bool SendRequest(int tmpfd) {
|
||||
int fd;
|
||||
char *p;
|
||||
size_t i;
|
||||
bool okall;
|
||||
ssize_t rc;
|
||||
uint32_t crc;
|
||||
struct stat st;
|
||||
const char *name;
|
||||
unsigned char *hdr, *q;
|
||||
size_t progsize, namesize, hdrsize;
|
||||
unsigned have;
|
||||
CHECK_NE(-1, (fd = open(g_prog, O_RDONLY)));
|
||||
CHECK_NE(-1, fstat(fd, &st));
|
||||
CHECK_NE(MAP_FAILED, (p = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0)));
|
||||
|
@ -302,8 +299,7 @@ bool Recv(unsigned char *p, size_t n) {
|
|||
|
||||
int ReadResponse(void) {
|
||||
int res;
|
||||
ssize_t rc;
|
||||
size_t n, m;
|
||||
size_t n;
|
||||
uint32_t size;
|
||||
unsigned char b[512];
|
||||
for (res = -1; res == -1;) {
|
||||
|
@ -378,7 +374,7 @@ bool ShouldRunInParallel(void) {
|
|||
int SpawnSubprocesses(int argc, char *argv[]) {
|
||||
const char *tpath;
|
||||
sigset_t chldmask, savemask;
|
||||
int i, rc, ws, pid, tmpfd, *pids, exitcode;
|
||||
int i, ws, pid, tmpfd, *pids, exitcode;
|
||||
struct sigaction ignore, saveint, savequit;
|
||||
char *args[5] = {argv[0], argv[1], argv[2]};
|
||||
|
||||
|
|
|
@ -275,8 +275,7 @@ void SendOutputFragmentMessage(enum RunitCommand kind, unsigned char *buf,
|
|||
}
|
||||
|
||||
void Recv(void *output, size_t outputsize) {
|
||||
int rc;
|
||||
ssize_t tx, chunk, received, totalgot;
|
||||
ssize_t chunk, received, totalgot;
|
||||
static bool once;
|
||||
static int zstatus;
|
||||
static char buf[32768];
|
||||
|
@ -294,7 +293,6 @@ void Recv(void *output, size_t outputsize) {
|
|||
totalgot = 0;
|
||||
for (;;) {
|
||||
if (rbuf.len >= outputsize) {
|
||||
tx = MIN(outputsize, rbuf.len);
|
||||
memcpy(output, rbuf.data + rbuf.off, outputsize);
|
||||
rbuf.len -= outputsize;
|
||||
rbuf.off += outputsize;
|
||||
|
@ -362,17 +360,15 @@ void Recv(void *output, size_t outputsize) {
|
|||
}
|
||||
|
||||
void HandleClient(void) {
|
||||
const size_t kMaxNameSize = 128;
|
||||
const size_t kMaxFileSize = 10 * 1024 * 1024;
|
||||
ssize_t got;
|
||||
uint32_t crc;
|
||||
sigset_t sigmask;
|
||||
ssize_t got, wrote;
|
||||
struct sockaddr_in addr;
|
||||
struct timespec now, deadline;
|
||||
char *addrstr, *exename, *exe;
|
||||
unsigned char msg[4 + 1 + 4 + 4 + 4];
|
||||
uint32_t addrsize, namesize, filesize, remaining;
|
||||
int rc, events, exitcode, wstatus, child, pipefds[2];
|
||||
uint32_t addrsize, namesize, filesize;
|
||||
int events, exitcode, wstatus, child, pipefds[2];
|
||||
|
||||
/* read request to run program */
|
||||
addrsize = sizeof(addr);
|
||||
|
@ -436,7 +432,7 @@ void HandleClient(void) {
|
|||
exe = g_exepath;
|
||||
} else {
|
||||
exe = "ape-m1.com";
|
||||
args[i++] = exe;
|
||||
args[i++] = (char *)exe;
|
||||
args[i++] = "-";
|
||||
args[i++] = g_exepath;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ void Execute(char *argv[]) {
|
|||
int Visit(const char *fpath, const struct stat *sb, int tflag,
|
||||
struct FTW *ftwbuf) {
|
||||
if (tflag == FTW_F && endswith(fpath, ".gz")) {
|
||||
Execute((char *[]){"build/bootstrap/gzip.com", "-d", fpath, 0});
|
||||
Execute((char *[]){"build/bootstrap/gzip.com", "-d", (char *)fpath, 0});
|
||||
strcpy(binpath, fpath);
|
||||
binpath[strlen(binpath) - 3] = 0;
|
||||
chmod(binpath, 0755);
|
||||
|
|
|
@ -114,7 +114,7 @@ static void CopyZip(void) {
|
|||
int rela, recs;
|
||||
Elf64_Ehdr *ehdr;
|
||||
unsigned long ldest, cdest, ltotal, ctotal, length;
|
||||
unsigned char *szip, *ineof, *stop, *eocd, *cdir, *lfile, *cfile;
|
||||
unsigned char *ineof, *stop, *eocd, *cdir, *lfile, *cfile;
|
||||
|
||||
// find zip eocd header
|
||||
//
|
||||
|
@ -211,7 +211,6 @@ static void CopyZip(void) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i, opt;
|
||||
#ifndef NDEBUG
|
||||
ShowCrashReports();
|
||||
#endif
|
||||
|
|
|
@ -138,7 +138,6 @@ void GetOpts(int *argc, char ***argv) {
|
|||
void ProcessFile(struct ElfWriter *elf, const char *path) {
|
||||
int fd;
|
||||
void *map;
|
||||
size_t pathlen;
|
||||
struct stat st;
|
||||
const char *name;
|
||||
if (stat(path, &st)) {
|
||||
|
@ -167,7 +166,7 @@ void ProcessFile(struct ElfWriter *elf, const char *path) {
|
|||
name = name_;
|
||||
} else {
|
||||
name = path;
|
||||
if (basenamify_) name = basename(name);
|
||||
if (basenamify_) name = basename(gc(xstrdup(name)));
|
||||
name = StripComponents(name, strip_components_);
|
||||
if (path_prefix_) name = gc(xjoinpaths(path_prefix_, name));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue