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,6 +51,7 @@
#include "libc/math.h"
#include "libc/mem/alloca.h"
#include "libc/mem/gc.h"
#include "libc/mem/gc.internal.h"
#include "libc/mem/mem.h"
#include "libc/nexgen32e/crc32.h"
#include "libc/nexgen32e/nt2sysv.h"
@ -139,6 +140,8 @@
#include "tool/net/luacheck.h"
#include "tool/net/sandbox.h"
#pragma GCC diagnostic ignored "-Wunused-variable"
STATIC_STACK_SIZE(0x80000);
__static_yoink("zipos");
@ -440,7 +443,6 @@ static bool daemonize;
static bool logrusage;
static bool logbodies;
static bool requiressl;
static bool isterminal;
static bool sslcliused;
static bool loglatency;
static bool terminated;
@ -448,7 +450,6 @@ static bool uniprocess;
static bool invalidated;
static bool logmessages;
static bool isinitialized;
static bool checkedmethod;
static bool sslinitialized;
static bool sslfetchverify;
static bool selfmodifiable;
@ -465,7 +466,6 @@ static bool ishandlingrequest;
static bool listeningonport443;
static bool hasonprocesscreate;
static bool hasonprocessdestroy;
static bool loggednetworkorigin;
static bool ishandlingconnection;
static bool hasonclientconnection;
static bool evadedragnetsurveillance;
@ -486,6 +486,7 @@ static int sslticketlifetime;
static uint32_t clientaddrsize;
static atomic_int terminatemonitor;
static char *brand;
static size_t zsize;
static lua_State *GL;
static lua_State *YL;
@ -493,25 +494,21 @@ static uint8_t *zmap;
static uint8_t *zcdir;
static size_t hdrsize;
static size_t amtread;
static char *replstack;
static reader_f reader;
static writer_f writer;
static char *extrahdrs;
static const char *zpath;
static const char *brand;
static char *monitorstack;
static char *serverheader;
static char gzip_footer[8];
static long maxpayloadsize;
static const char *pidpath;
static const char *logpath;
static uint32_t *interfaces;
static const char *histpath;
static struct pollfd *polls;
static size_t payloadlength;
static int64_t cacheseconds;
static const char *cachedirective;
static char *cachedirective;
static const char *monitortty;
static const char *serverheader;
static struct Strings stagedirs;
static struct Strings hidepaths;
static const char *launchbrowser;
@ -664,7 +661,7 @@ static char *MergePaths(const char *p, size_t n, const char *q, size_t m,
}
static long FindRedirect(const char *s, size_t n) {
int c, m, l, r, z;
int c, m, l, r;
l = 0;
r = redirects.n - 1;
while (l <= r) {
@ -941,7 +938,6 @@ static bool IsTrustedIp(uint32_t ip) {
static void DescribeAddress(char buf[40], uint32_t addr, uint16_t port) {
char *p;
const char *s;
p = buf;
p = FormatUint32(p, (addr & 0xFF000000) >> 030), *p++ = '.';
p = FormatUint32(p, (addr & 0x00FF0000) >> 020), *p++ = '.';
@ -965,7 +961,6 @@ static inline int GetClientAddr(uint32_t *ip, uint16_t *port) {
}
static inline int GetRemoteAddr(uint32_t *ip, uint16_t *port) {
char str[40];
GetClientAddr(ip, port);
if (HasHeader(kHttpXForwardedFor)) {
if (IsTrustedIp(*ip)) {
@ -1051,7 +1046,7 @@ static void ProgramTimeout(long ms) {
static void ProgramCache(long x, const char *s) {
cacheseconds = x;
if (s) cachedirective = s;
if (s) cachedirective = strdup(s);
}
static void SetDefaults(void) {
@ -1084,7 +1079,7 @@ static bool HasString(struct Strings *l, const char *s, size_t n) {
return false;
}
static const char *DEFAULTLUAPATH = "/zip/.lua/?.lua;/zip/.lua/?/init.lua";
const char *DEFAULTLUAPATH = "/zip/.lua/?.lua;/zip/.lua/?/init.lua";
static void UpdateLuaPath(const char *s) {
#ifndef STATIC
@ -1096,8 +1091,8 @@ static void UpdateLuaPath(const char *s) {
lua_getglobal(L, "package");
if (lua_istable(L, -1)) {
lua_getfield(L, -1, "path");
curpath = luaL_optstring(L, -1, "");
if (t = strstr(curpath, DEFAULTLUAPATH)) {
curpath = (void *)luaL_optstring(L, -1, "");
if ((t = strstr(curpath, DEFAULTLUAPATH))) {
// if the DEFAULT path is found, prepend the path in front of it
respath = xasprintf("%.*s%s/.lua/?.lua;%s/.lua/?/init.lua;%s",
t - curpath, curpath, s, s, t);
@ -1127,7 +1122,7 @@ static void ProgramDirectory(const char *path) {
}
static void ProgramHeader(const char *s) {
char *p, *v, *h;
char *p, *v;
if ((p = strchr(s, ':')) && IsValidHttpToken(s, p - s) &&
(v = EncodeLatin1(p + 1, -1, 0, kControlC0 | kControlC1 | kControlWs))) {
switch (GetHttpHeader(s, p - s)) {
@ -1202,7 +1197,7 @@ static void Daemonize(void) {
umask(0);
}
static void LogLuaError(char *hook, char *err) {
static void LogLuaError(const char *hook, const char *err) {
ERRORF("(lua) failed to run %s: %s", hook, err);
}
@ -1511,7 +1506,7 @@ static int TlsFlush(struct TlsBio *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 (WritevAll(bio->fd, v, 2) != -1) {
if (bio->c > 0) bio->c = 0;
@ -1533,7 +1528,6 @@ static int TlsFlush(struct TlsBio *bio, const unsigned char *buf, size_t len) {
static int TlsSend(void *ctx, const unsigned char *buf, size_t len) {
int rc;
struct iovec v[2];
struct TlsBio *bio = ctx;
if (bio->c >= 0 && bio->c + len <= sizeof(bio->u)) {
memcpy(bio->u + bio->c, buf, len);
@ -1546,7 +1540,6 @@ static int TlsSend(void *ctx, const unsigned char *buf, size_t len) {
static int TlsRecvImpl(void *ctx, unsigned char *p, size_t n, uint32_t o) {
int r;
ssize_t s;
struct iovec v[2];
struct TlsBio *bio = ctx;
if ((r = TlsFlush(bio, 0, 0)) < 0) return r;
@ -1580,7 +1573,6 @@ static int TlsRecvImpl(void *ctx, unsigned char *p, size_t n, uint32_t o) {
static int TlsRecv(void *ctx, unsigned char *buf, size_t len, uint32_t tmo) {
int rc;
struct TlsBio *bio = ctx;
if (oldin.n) {
rc = MIN(oldin.n, len);
memcpy(buf, oldin.p, rc);
@ -1711,7 +1703,6 @@ static void CertsDestroy(void) {
}
static void WipeServingKeys(void) {
size_t i;
if (uniprocess) return;
mbedtls_ssl_ticket_free(&ssltick);
mbedtls_ssl_key_cert_free(conf.key_cert), conf.key_cert = 0;
@ -1906,9 +1897,8 @@ static void ConfigureCertificate(mbedtls_x509write_cert *cw, struct Cert *ca,
const char *s;
bool isduplicate;
size_t i, j, k, nsan;
struct HostsTxt *htxt;
struct mbedtls_san *san;
const mbedtls_x509_name *xname;
const struct HostsTxt *htxt;
char *name, *subject, *issuer, notbefore[16], notafter[16], hbuf[256];
san = 0;
nsan = 0;
@ -1922,7 +1912,7 @@ static void ConfigureCertificate(mbedtls_x509write_cert *cw, struct Cert *ca,
if (ips.p[j] == READ32BE(htxt->entries.p[i].ip)) {
isduplicate = false;
s = htxt->strings.p + htxt->entries.p[i].name;
if (!name) name = s;
if (!name) name = (void *)s;
for (k = 0; k < nsan; ++k) {
if (san[k].tag == MBEDTLS_X509_SAN_DNS_NAME &&
!strcasecmp(s, san[k].val)) {
@ -2175,7 +2165,7 @@ static void IndexAssets(void) {
hash = Hash(ZIP_CFILE_NAME(zmap + cf), ZIP_CFILE_NAMESIZE(zmap + cf));
step = 0;
do {
i = (hash + (step * (step + 1)) >> 1) & (m - 1);
i = (hash + ((step * (step + 1)) >> 1)) & (m - 1);
++step;
} while (p[i].hash);
GetZipCfileTimestamps(zmap + cf, &lm, 0, 0, gmtoff);
@ -2193,8 +2183,8 @@ static void IndexAssets(void) {
static bool OpenZip(bool force) {
int fd;
size_t n;
uint8_t *m, *d;
struct stat st;
uint8_t *m, *d, *p;
if (stat(zpath, &st) != -1) {
if (force || st.st_ino != zst.st_ino || st.st_size > zst.st_size) {
if (st.st_ino == zst.st_ino) {
@ -2241,7 +2231,7 @@ static struct Asset *GetAssetZip(const char *path, size_t pathlen) {
if (pathlen > 1 && path[0] == '/') ++path, --pathlen;
hash = Hash(path, pathlen);
for (step = 0;; ++step) {
i = (hash + (step * (step + 1)) >> 1) & (assets.n - 1);
i = (hash + ((step * (step + 1)) >> 1)) & (assets.n - 1);
if (!assets.p[i].hash) return NULL;
if (hash == assets.p[i].hash &&
pathlen == ZIP_CFILE_NAMESIZE(zmap + assets.p[i].cf) &&
@ -2275,7 +2265,6 @@ static struct Asset *GetAssetFile(const char *path, size_t pathlen) {
}
static struct Asset *GetAsset(const char *path, size_t pathlen) {
char *path2;
struct Asset *a;
if (!(a = GetAssetFile(path, pathlen))) {
if (!(a = GetAssetZip(path, pathlen))) {
@ -2386,7 +2375,6 @@ static void *Deflate(const void *data, size_t size, size_t *out_size) {
}
static void *LoadAsset(struct Asset *a, size_t *out_size) {
int mode;
size_t size;
uint8_t *data;
if (S_ISDIR(GetMode(a))) {
@ -2657,11 +2645,9 @@ static int LuaCallWithYield(lua_State *L) {
static ssize_t DeflateGenerator(struct iovec v[3]) {
int i, rc;
size_t no;
void *res;
int level;
i = 0;
if (!dg.t) {
v[0].iov_base = kGzipHeader;
v[0].iov_base = (void *)kGzipHeader;
v[0].iov_len = sizeof(kGzipHeader);
++dg.t;
++i;
@ -2713,7 +2699,6 @@ static ssize_t DeflateGenerator(struct iovec v[3]) {
static char *ServeAssetCompressed(struct Asset *a) {
char *p;
uint32_t crc;
LockInc(&shared->c.deflates);
LockInc(&shared->c.compressedresponses);
DEBUGF("(srvr) ServeAssetCompressed()");
@ -2739,7 +2724,6 @@ static char *ServeAssetCompressed(struct Asset *a) {
static ssize_t InflateGenerator(struct iovec v[3]) {
int i, rc;
size_t no;
void *res;
i = 0;
if (!dg.t) {
++dg.t;
@ -2777,7 +2761,6 @@ static ssize_t InflateGenerator(struct iovec v[3]) {
static char *ServeAssetDecompressed(struct Asset *a) {
char *p;
size_t size;
uint32_t crc;
LockInc(&shared->c.inflates);
LockInc(&shared->c.decompressedresponses);
size = GetZipCfileUncompressedSize(zmap + a->cf);
@ -2853,12 +2836,13 @@ static char *ServeAssetRange(struct Asset *a) {
}
static char *GetAssetPath(uint8_t *zcf, size_t *out_size) {
char *p1, *p2;
char *p2;
size_t n1, n2;
const char *p1;
p1 = ZIP_CFILE_NAME(zcf);
n1 = ZIP_CFILE_NAMESIZE(zcf);
p2 = xmalloc(1 + n1 + 1);
n2 = 1 + n1 + 1;
p2 = xmalloc(n2);
p2[0] = '/';
memcpy(p2 + 1, p1, n1);
p2[1 + n1] = '\0';
@ -2937,7 +2921,7 @@ static void LaunchBrowser(const char *path) {
sigaction(SIGINT, &saveint, 0);
sigaction(SIGQUIT, &savequit, 0);
sigprocmask(SIG_SETMASK, &savemask, 0);
execv(prog, (char *const[]){prog, u, 0});
execv(prog, (char *const[]){(char *)prog, (char *)u, 0});
_Exit(127);
}
while (wait4(pid, &ws, 0, 0) == -1) {
@ -2988,12 +2972,11 @@ static char *ServeListing(void) {
int w[3];
uint8_t *zcf;
struct tm tm;
char *p, *path;
const char *and;
struct rusage ru;
char *p, *q, *path;
struct timespec lastmod;
size_t n, pathlen, rn[6];
char rb[8], tb[20], *rp[6];
size_t i, n, pathlen, rn[6];
LockInc(&shared->c.listingrequests);
if (cpm.msg.method != kHttpGet && cpm.msg.method != kHttpHead)
return BadMethod();
@ -3272,7 +3255,7 @@ static char *ServeLua(struct Asset *a, const char *s, size_t n) {
size_t codelen;
lua_State *L = GL;
LockInc(&shared->c.dynamicrequests);
effectivepath.p = s;
effectivepath.p = (void *)s;
effectivepath.n = n;
if ((code = FreeLater(LoadAsset(a, &codelen)))) {
int status =
@ -3446,9 +3429,10 @@ static int LuaServeIndex(lua_State *L) {
}
static int LuaServeRedirect(lua_State *L) {
size_t loclen;
const char *location, *eval;
int code;
char *eval;
size_t loclen;
const char *location;
OnlyCallDuringRequest(L, "ServeRedirect");
code = luaL_checkinteger(L, 1);
@ -3639,16 +3623,15 @@ static void GetDosLocalTime(int64_t utcunixts, uint16_t *out_time,
*out_date = DOS_DATE(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday + 1);
}
static void StoreAsset(char *path, size_t pathlen, char *data, size_t datalen,
int mode) {
static void StoreAsset(const char *path, size_t pathlen, const char *data,
size_t datalen, int mode) {
int64_t ft;
int i;
uint32_t crc;
char *comp, *p;
struct timespec now;
struct Asset *a;
struct iovec v[13];
uint8_t *cdir, era;
uint8_t era;
const char *use;
uint16_t gflags, iattrs, mtime, mdate, dosmode, method, disk;
size_t oldcdirsize, oldcdiroffset, records, cdiroffset, cdirsize, complen,
@ -3722,10 +3705,10 @@ static void StoreAsset(char *path, size_t pathlen, char *data, size_t datalen,
p = WRITE16LE(p, pathlen);
p = WRITE16LE(p, v[2].iov_len);
v[1].iov_len = pathlen;
v[1].iov_base = path;
v[1].iov_base = (void *)path;
// file data
v[3].iov_len = uselen;
v[3].iov_base = use;
v[3].iov_base = (void *)use;
// old central directory entries
oldcdirsize = GetZipCdirSize(zcdir);
oldcdiroffset = GetZipCdirOffset(zcdir);
@ -3788,7 +3771,7 @@ static void StoreAsset(char *path, size_t pathlen, char *data, size_t datalen,
p = WRITE16LE(p, mode);
p = WRITE32LE(p, MIN(zsize, 0xffffffff));
v[7].iov_len = pathlen;
v[7].iov_base = path;
v[7].iov_base = (void *)path;
// zip64 end of central directory
cdiroffset =
zsize + v[0].iov_len + v[1].iov_len + v[2].iov_len + v[3].iov_len;
@ -3817,7 +3800,7 @@ static void StoreAsset(char *path, size_t pathlen, char *data, size_t datalen,
v[10].iov_base = 0;
}
// end of central directory
v[12].iov_base = GetZipCdirComment(zcdir);
v[12].iov_base = (void *)GetZipCdirComment(zcdir);
v[12].iov_len = GetZipCdirCommentSize(zcdir);
v[11].iov_base = p = alloca((v[11].iov_len = kZipCdirHdrMinSize));
p = WRITE32LE(p, kZipCdirHdrMagic);
@ -3836,11 +3819,11 @@ static void StoreAsset(char *path, size_t pathlen, char *data, size_t datalen,
free(comp);
}
static void StoreFile(char *path) {
static void StoreFile(const char *path) {
char *p;
size_t plen, tlen;
struct stat st;
char *target = path;
size_t plen, tlen;
const char *target = path;
if (startswith(target, "./")) target += 2;
tlen = strlen(target);
if (!IsReasonablePath(target, tlen))
@ -3857,8 +3840,9 @@ static void StorePath(const char *dirpath) {
DIR *d;
char *path;
struct dirent *e;
if (!isdirectory(dirpath) && !endswith(dirpath, "/"))
if (!isdirectory(dirpath) && !endswith(dirpath, "/")) {
return StoreFile(dirpath);
}
if (!(d = opendir(dirpath))) FATALF("(cfg) error: can't open %`'s", dirpath);
while ((e = readdir(d))) {
if (strcmp(e->d_name, ".") == 0) continue;
@ -4137,10 +4121,9 @@ static int LuaGetUser(lua_State *L) {
OnlyCallDuringRequest(L, "GetUser");
if (url.user.p) {
LuaPushUrlView(L, &url.user);
} else if ((p = GetBasicAuthorization(&n))) {
} else if ((p = gc(GetBasicAuthorization(&n)))) {
if (!(q = memchr(p, ':', n))) q = p + n;
lua_pushlstring(L, p, q - p);
free(p);
} else {
lua_pushnil(L);
}
@ -4153,13 +4136,12 @@ static int LuaGetPass(lua_State *L) {
OnlyCallDuringRequest(L, "GetPass");
if (url.user.p) {
LuaPushUrlView(L, &url.pass);
} else if ((p = GetBasicAuthorization(&n))) {
} else if ((p = gc(GetBasicAuthorization(&n)))) {
if ((q = memchr(p, ':', n))) {
lua_pushlstring(L, q + 1, p + n - (q + 1));
} else {
lua_pushnil(L);
}
free(p);
} else {
lua_pushnil(L);
}
@ -4245,10 +4227,10 @@ static int LuaGetHeaders(lua_State *L) {
static int LuaSetHeader(lua_State *L) {
int h;
ssize_t rc;
char *eval;
char *p, *q;
const char *key, *val, *eval;
size_t i, keylen, vallen, evallen;
const char *key, *val;
size_t keylen, vallen, evallen;
OnlyCallDuringRequest(L, "SetHeader");
key = luaL_checklstring(L, 1, &keylen);
val = luaL_optlstring(L, 2, 0, &vallen);
@ -4365,7 +4347,7 @@ static int LuaSetCookie(lua_State *L) {
expires =
FormatUnixHttpDateTime(FreeLater(xmalloc(30)), lua_tonumber(L, -1));
} else {
expires = lua_tostring(L, -1);
expires = (void *)lua_tostring(L, -1);
if (!ParseHttpDateTime(expires, -1)) {
luaL_argerror(L, 3, "invalid data format in Expires");
__builtin_unreachable();
@ -4384,7 +4366,7 @@ static int LuaSetCookie(lua_State *L) {
if (lua_getfield(L, 3, "samesite") == LUA_TSTRING ||
lua_getfield(L, 3, "SameSite") == LUA_TSTRING) {
samesite = lua_tostring(L, -1); // also used in the Secure check
samesite = (void *)lua_tostring(L, -1); // also used in the Secure check
appends(&buf, "; SameSite=");
appends(&buf, samesite);
}
@ -4588,7 +4570,7 @@ static int LuaProgramBrand(lua_State *L) {
static int LuaProgramDirectory(lua_State *L) {
struct stat st;
char *path = luaL_checkstring(L, 1);
const char *path = luaL_checkstring(L, 1);
// check to raise a Lua error, to allow it to be handled
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
return luaL_argerror(L, 1, "not a directory");
@ -4637,7 +4619,7 @@ static int LuaProgramSslPresharedKey(lua_State *L) {
}
static int LuaProgramSslCiphersuite(lua_State *L) {
mbedtls_ssl_ciphersuite_t *suite;
const mbedtls_ssl_ciphersuite_t *suite;
OnlyCallFromInitLua(L, "ProgramSslCiphersuite");
if (!(suite = GetCipherSuite(luaL_checkstring(L, 1)))) {
luaL_argerror(L, 1, "unsupported or unknown ciphersuite");
@ -4741,7 +4723,7 @@ static int LuaGetZipPaths(lua_State *L) {
char *path;
uint8_t *zcf;
size_t i, n, pathlen, prefixlen;
char *prefix = luaL_optlstring(L, 1, "", &prefixlen);
const char *prefix = luaL_optlstring(L, 1, "", &prefixlen);
lua_newtable(L);
i = 0;
n = GetZipCdirRecords(zcdir);
@ -4977,13 +4959,13 @@ static int LuaProgramTokenBucket(lua_State *L) {
}
static const char *GetContentTypeExt(const char *path, size_t n) {
char *r, *e;
const char *r, *e;
int top;
lua_State *L = GL;
if ((r = FindContentType(path, n))) return r;
// extract the last .; use the entire path if none is present
if (e = strrchr(path, '.')) path = e + 1;
if ((e = strrchr(path, '.'))) path = e + 1;
top = lua_gettop(L);
lua_pushlightuserdata(L, (void *)&ctIdx); // push address as unique key
CHECK_EQ(lua_gettable(L, LUA_REGISTRYINDEX), LUA_TTABLE);
@ -5055,7 +5037,7 @@ static bool LuaRunAsset(const char *path, bool mandatory) {
if ((a = GetAsset(path, pathlen))) {
if ((code = FreeLater(LoadAsset(a, &codelen)))) {
lua_State *L = GL;
effectivepath.p = path;
effectivepath.p = (void *)path;
effectivepath.n = pathlen;
DEBUGF("(lua) LuaRunAsset(%`'s)", path);
status = luaL_loadbuffer(
@ -5420,7 +5402,6 @@ static void HandleCompletions(const char *p, linenoiseCompletions *c) {
static void LuaPrint(lua_State *L) {
int i, n;
char *b = 0;
const char *s;
n = lua_gettop(L);
if (n > 0) {
for (i = 1; i <= n; i++) {
@ -5529,6 +5510,7 @@ static void MemDestroy(void) {
Free(&cpm.outbuf);
FreeStrings(&stagedirs);
FreeStrings(&hidepaths);
Free(&cachedirective);
Free(&launchbrowser);
Free(&serverheader);
Free(&trustedips.p);
@ -5608,7 +5590,7 @@ static ssize_t SendString(const char *s) {
ssize_t rc;
struct iovec iov;
n = strlen(s);
iov.iov_base = s;
iov.iov_base = (void *)s;
iov.iov_len = n;
if (logmessages) {
LogMessage("sending", s, n);
@ -5776,7 +5758,6 @@ static void HandleReload(void) {
static void HandleHeartbeat(void) {
size_t i;
sigset_t mask;
UpdateCurrentDate(timespec_real());
Reindex();
getrusage(RUSAGE_SELF, &shared->server);
@ -6062,7 +6043,6 @@ static char *Route(const char *host, size_t hostlen, const char *path,
static char *RoutePath(const char *path, size_t pathlen) {
int m;
long r;
char *p;
struct Asset *a;
DEBUGF("(srvr) RoutePath(%`'.*s)", pathlen, path);
if ((a = GetAsset(path, pathlen))) {
@ -6166,7 +6146,6 @@ static bool IsNotModified(struct Asset *a) {
static char *ServeAsset(struct Asset *a, const char *path, size_t pathlen) {
char *p;
uint32_t crc;
const char *ct;
ct = GetContentType(a, path, pathlen);
if (IsNotModified(a)) {
@ -6274,7 +6253,7 @@ static bool TransmitResponse(char *p) {
iovlen = 1;
if (!MustNotIncludeMessageBody()) {
if (cpm.gzipped) {
iov[iovlen].iov_base = kGzipHeader;
iov[iovlen].iov_base = (void *)kGzipHeader;
iov[iovlen].iov_len = sizeof(kGzipHeader);
++iovlen;
}
@ -6438,10 +6417,10 @@ static bool IsSsl(unsigned char c) {
}
static void HandleMessages(void) {
char *p;
bool once;
ssize_t rc;
size_t got;
(void)once;
for (once = false;;) {
InitRequest();
startread = timespec_real();
@ -6607,14 +6586,14 @@ static int MemoryMonitor(void *arg, int tid) {
static struct termios oldterm;
static int tty;
sigset_t ss;
bool done, ok;
bool ok;
size_t intervals;
struct winsize ws;
unsigned char rez;
struct termios term;
char *b, *addr, title[128];
char *b, *addr;
struct MemoryInterval *mi, *mi2;
long i, j, k, n, x, y, pi, gen, pages;
long i, j, gen, pages;
int rc, id, color, color2, workers;
id = atomic_load_explicit(&shared->workers, memory_order_relaxed);
DEBUGF("(memv) started for pid %d on tid %d", getpid(), gettid());
@ -6689,7 +6668,7 @@ static int MemoryMonitor(void *arg, int tid) {
appendr(&b, 0);
appends(&b, "\e[H\e[1m");
for (pi = k = x = y = i = 0; i < intervals; ++i) {
for (i = 0; i < intervals; ++i) {
addr = (char *)((int64_t)((uint64_t)mi[i].x << 32) >> 16);
color = 0;
appendf(&b, "\e[0m%lx", addr);
@ -6934,8 +6913,6 @@ static int HandleConnection(size_t i) {
static void MakeExecutableModifiable(void) {
#ifdef __x86_64__
int ft;
size_t n;
extern char ape_rom_vaddr[] __attribute__((__weak__));
if (!(SUPPORT_VECTOR & (_HOSTMETAL | _HOSTWINDOWS | _HOSTXNU))) return;
if (IsWindows()) return; // TODO
if (IsOpenbsd()) return; // TODO
@ -7253,8 +7230,8 @@ static void TlsInit(void) {
}
mbedtls_ssl_set_bio(&ssl, &g_bio, TlsSend, 0, TlsRecv);
conf.disable_compression = confcli.disable_compression = true;
DCHECK_EQ(0, mbedtls_ssl_conf_alpn_protocols(&conf, kAlpn));
DCHECK_EQ(0, mbedtls_ssl_conf_alpn_protocols(&confcli, kAlpn));
DCHECK_EQ(0, mbedtls_ssl_conf_alpn_protocols(&conf, (void *)kAlpn));
DCHECK_EQ(0, mbedtls_ssl_conf_alpn_protocols(&confcli, (void *)kAlpn));
DCHECK_EQ(0, mbedtls_ssl_setup(&ssl, &conf));
DCHECK_EQ(0, mbedtls_ssl_setup(&sslcli, &confcli));
#endif