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

@ -63,7 +63,6 @@ void EnableCruiseControlForCool(void) {
* @see BENCH()
*/
void testlib_runallbenchmarks(void) {
int e;
__log_level = kLogWarn;
EnableCruiseControlForCool();
testlib_runtestcases(__bench_start, __bench_end, testlib_benchwarmup);

View file

@ -68,7 +68,8 @@ static void testlib_describecombo(struct ComboProduct *product,
static void testlib_callcombos(struct ComboProduct *product,
const struct TestFixture *combos,
testfn_t *test_start, testfn_t *test_end) {
const testfn_t *test_start,
const testfn_t *test_end) {
for (;;) {
testlib_describecombo(product, combos);
for (unsigned i = 0; i < product->n; ++i) {
@ -88,7 +89,7 @@ static void testlib_callcombos(struct ComboProduct *product,
* @see ape/ape.lds
* @see libc/testlib/testlib.h
*/
void testlib_runcombos(testfn_t *test_start, testfn_t *test_end,
void testlib_runcombos(const testfn_t *test_start, const testfn_t *test_end,
const struct TestFixture *combo_start,
const struct TestFixture *combo_end) {
struct ComboProduct *product;

View file

@ -151,6 +151,9 @@ COSMOPOLITAN_C_START_
__testlib_yield(); \
Core = __testlib_getcore(); \
Interrupts = __testlib_getinterrupts(); \
(void)Toto; \
(void)Core; \
(void)Interrupts; \
EXPR; \
Speculative = BENCHLOOPER(__startbench, __endbench, 32, (EXPR)); \
} while (++Tries < EZBENCH_TRIES && !Speculative); \

View file

@ -31,7 +31,7 @@ int testlib_countfixtures(const struct TestFixture *start,
* @see ape/ape.lds
* @see libc/testlib/testlib.h
*/
void testlib_runfixtures(testfn_t *test_start, testfn_t *test_end,
void testlib_runfixtures(const testfn_t *test_start, const testfn_t *test_end,
const struct TestFixture *fixture_start,
const struct TestFixture *fixture_end) {
unsigned i, count;

View file

@ -46,7 +46,6 @@ static dontasan dontubsan relegated uint64_t CountMappedBytes(void) {
}
static relegated void DieBecauseOfQuota(int rc, const char *message) {
int e = errno;
char hostname[32];
stpcpy(hostname, "unknown");
gethostname(hostname, sizeof(hostname));

View file

@ -40,7 +40,6 @@ const char *testlib_showerror_symbol;
void testlib_showerror(const char *file, int line, const char *func,
const char *method, const char *symbol, const char *code,
char *v1, char *v2) {
char *p;
char hostname[128];
__stpcpy(hostname, "unknown");
gethostname(hostname, sizeof(hostname));

View file

@ -388,10 +388,11 @@ void testlib_runalltests(void);
const char *testlib_strerror(void);
void testlib_runallbenchmarks(void);
bool testlib_memoryexists(const void *);
void testlib_runtestcases(testfn_t *, testfn_t *, testfn_t);
void testlib_runcombos(testfn_t *, testfn_t *, const struct TestFixture *,
const struct TestFixture *);
void testlib_runfixtures(testfn_t *, testfn_t *, const struct TestFixture *,
void testlib_runtestcases(const testfn_t *, const testfn_t *, testfn_t);
void testlib_runcombos(const testfn_t *, const testfn_t *,
const struct TestFixture *, const struct TestFixture *);
void testlib_runfixtures(const testfn_t *, const testfn_t *,
const struct TestFixture *,
const struct TestFixture *);
int testlib_countfixtures(const struct TestFixture *,
const struct TestFixture *);

View file

@ -166,8 +166,6 @@ static void SetLimit(int resource, uint64_t soft, uint64_t hard) {
* Generic test program main function.
*/
dontasan int main(int argc, char *argv[]) {
unsigned cpus;
const char *comdbg;
__log_level = kLogInfo;
GetOpts(argc, argv);
setenv("GDB", "", true);

View file

@ -101,7 +101,8 @@ static void TearDownTmpDir(void) {
/**
* Runs all test case functions in sorted order.
*/
void testlib_runtestcases(testfn_t *start, testfn_t *end, testfn_t warmup) {
void testlib_runtestcases(const testfn_t *start, const testfn_t *end,
testfn_t warmup) {
// getpid() calls are inserted to help visually see tests in traces
// which can be performed on Linux, FreeBSD, OpenBSD, and XNU:
//