diff --git a/src/header/bits_pthread/cbindgen.toml b/src/header/bits_pthread/cbindgen.toml
index 34956c001217eb3c5da4b818a367d2f244d386b4..4843655919835842230c8276ae1c05848fb299d7 100644
--- a/src/header/bits_pthread/cbindgen.toml
+++ b/src/header/bits_pthread/cbindgen.toml
@@ -17,8 +17,8 @@ after_includes = """
     void *arg; \
     void *prev; \
   } __relibc_internal_pthread_ll_entry = { \
-    .routine = (routine), \
-    .arg = (arg), \
+    .routine = (void (*)(void *))(routine), \
+    .arg = (void *)(arg), \
   }; \
   __relibc_internal_pthread_cleanup_push(&__relibc_internal_pthread_ll_entry);
 
diff --git a/src/header/signal/mod.rs b/src/header/signal/mod.rs
index a071ad7dafceee3e61d7d82bafd2f2237fddd26c..e56e67afb58cc486892c22489c7960a437b9b075 100644
--- a/src/header/signal/mod.rs
+++ b/src/header/signal/mod.rs
@@ -22,10 +22,10 @@ pub mod sys;
 
 type SigSet = BitSet<[c_ulong; 1]>;
 
-pub const SIG_DFL: usize = 0;
-pub const SIG_IGN: usize = 1;
-pub const SIG_ERR: isize = -1;
-pub const SIG_HOLD: isize = 2;
+pub(crate) const SIG_DFL: usize = 0;
+pub(crate) const SIG_IGN: usize = 1;
+pub(crate) const SIG_ERR: isize = -1;
+pub(crate) const SIG_HOLD: isize = 2;
 
 pub const SIG_BLOCK: c_int = 0;
 pub const SIG_UNBLOCK: c_int = 1;
diff --git a/tests/Makefile b/tests/Makefile
index b807168c14b25a352bd18539d22e773bc88d672a..c9bd1905d138bdb4b49b18c39508dde2cb3b9631 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -227,6 +227,8 @@ FLAGS=\
 	-fno-builtin \
 	-fno-stack-protector \
 	-Wall \
+	-Wextra \
+	-Werror \
 	-pedantic \
 	-g \
 	-I .
diff --git a/tests/ctype.c b/tests/ctype.c
index 049ac99a70a77174a3e9ad53dbaa6f992ed48e37..ffef3402f1313b369e71735d15f47c37ba7898a4 100644
--- a/tests/ctype.c
+++ b/tests/ctype.c
@@ -301,7 +301,7 @@ size_t num_test_cases = sizeof(test_cases) / sizeof(struct test_case);
 int main(void) {
     int retval = EXIT_SUCCESS;
 
-    for(int i = 0; i < num_test_cases; ++i) {
+    for(size_t i = 0; i < num_test_cases; ++i) {
         struct test_case tc = test_cases[i];
         CHECK_TEST(tc, isalnum, retval);
         CHECK_TEST(tc, isalpha, retval);
diff --git a/tests/errno.c b/tests/errno.c
index 41d8769103958b00a4f099b8bf243740e12c5a90..6f17bd3cfecec2cd9a444866d3db3524614eeb20 100644
--- a/tests/errno.c
+++ b/tests/errno.c
@@ -1,8 +1,11 @@
+#include <assert.h>
 #include <errno.h>
 #include <stdio.h>
 #include "test_helpers.h"
 
 int main(int argc, char **argv) {
+    assert(argc > 0);
+
     puts(argv[0]);
     puts(program_invocation_name);
     puts(program_invocation_short_name);
diff --git a/tests/futimens.c b/tests/futimens.c
index 4d25944434bbda7de492dceb2540c0df58b03141..feedaf0e3c2a7a208a818658808955d1a3d6e429 100644
--- a/tests/futimens.c
+++ b/tests/futimens.c
@@ -31,7 +31,7 @@ int check_mtime(char *path, int expected_sec, int expected_nsec, int err_gap) {
 }
 
 
-int main(int argc, char** argv) {
+int main(void) {
   char temp[] = "/tmp/stattest-XXXXXX";
   const char file[] = "/mkfifo_fifo";
   int len = sizeof(temp) + sizeof(int);
diff --git a/tests/grp/getgrgid_r.c b/tests/grp/getgrgid_r.c
index 5792848d72380c5dd6d27d21d79f5ade159d341d..ed2fea5dcc4ad7ffcd7b39185a562092f184cf9a 100644
--- a/tests/grp/getgrgid_r.c
+++ b/tests/grp/getgrgid_r.c
@@ -4,49 +4,39 @@
 #include <string.h>
 #include <grp.h>
 
-bool test_getgrgid(gid_t gid) {
-    struct group* out = getgrgid(gid);
+void test_getgrgid(gid_t gid) {
+    struct group *out = getgrgid(gid);
     
     if (out == NULL) {
-        printf("Did not find a group %d", gid);
-        return false;
+        printf("Did not find a group %d\n", gid);
+        return;
     }
     
     printf("getgrgid\n");
     
-    char* start = out->gr_name;
-    int len = strlen(out->gr_name);
-    
     printf("    %d = %s, GID: %d\n", gid, out->gr_name, out->gr_gid);
-    
-    return true;
 }
 
-bool test_getgrgid_r(gid_t gid) {
-    char* buf[100];
+void test_getgrgid_r(gid_t gid) {
+    char buf[100];
     
     struct group grp;
-    struct group* out = &grp;
-    struct group* tmp;
+    struct group *tmp;
     
-    int status = getgrgid_r(gid, out, buf, sizeof(buf), &tmp);
+    int status = getgrgid_r(gid, &grp, buf, sizeof(buf), &tmp);
     
-    if (out == NULL) {
-        printf("Did not find a group %d", gid);
-        return false;
+    if (tmp == NULL) {
+        const char *reason = status != 0 ? strerror(status) : "(not found)";
+        printf("Did not find a group %d: %s\n", gid, reason);
+        return;
     }
     
     printf("getgrgid_r\n");   
     
-    char* start = grp.gr_name;
-    int len = strlen(grp.gr_name);
-    
     printf("    %d = %s, GID: %d\n", gid, grp.gr_name, grp.gr_gid);
-    
-    return true;
 }
 
 int main(void) {
     test_getgrgid(1050);
     test_getgrgid_r(1050);
-}
\ No newline at end of file
+}
diff --git a/tests/grp/getgrnam_r.c b/tests/grp/getgrnam_r.c
index 2f0a3ac615d5514567542802c5300bd2b227d857..851b33461046570ce6dc408070a6c7bce84cf6c7 100644
--- a/tests/grp/getgrnam_r.c
+++ b/tests/grp/getgrnam_r.c
@@ -4,49 +4,39 @@
 #include <string.h>
 #include <grp.h>
 
-bool test_getgrnam(char* gr_name) {
+void test_getgrnam(const char *gr_name) {
     struct group* out = getgrnam(gr_name);
     
     if (out == NULL) {
         printf("Did not find a group '%s'", gr_name);
-        return false;
+        return;
     }
     
     printf("getgrnam\n");
 
-    char* start = out->gr_name;
-    int len = strlen(out->gr_name);
-    
     printf("    '%s' = %d\n", gr_name, out->gr_gid);
-    
-    return true;
 }
 
-bool test_getgrnam_r(char* gr_name) {
-    char* buf[100];
+void test_getgrnam_r(const char *gr_name) {
+    char buf[100];
     
     struct group grp;
     struct group* out = &grp;
-    struct group* tmp;
     
-    int status = getgrnam_r(gr_name, out, buf, sizeof(buf), &tmp);
+    int status = getgrnam_r(gr_name, &grp, buf, sizeof(buf), &out);
     
     if (out == NULL) {
-        printf("Did not find a group '%s'", gr_name);
-        return false;
+        const char *reason = (status != 0) ? strerror(status) : "(not found)";
+        printf("Did not find a group %s: %s\n", gr_name, reason);
+        return;
     }
     
     printf("getgrnam_r\n");   
     
-    char* start = grp.gr_name;
-    int len = strlen(grp.gr_name);
-
     printf("    '%s' = %d\n", gr_name, out->gr_gid);
-    
-    return true;
 }
 
 int main(void) {
     test_getgrnam("lcake");
     test_getgrnam_r("lcake");
-}
\ No newline at end of file
+}
diff --git a/tests/grp/gr_iter.c b/tests/grp/gr_iter.c
index dd7e59984feb35abcc3e48916516ef8be52f8482..bf3e2e509061ddee80f6dcd0aa71f7d4e77f21f8 100644
--- a/tests/grp/gr_iter.c
+++ b/tests/grp/gr_iter.c
@@ -2,9 +2,9 @@
 #include <grp.h>
 #include <string.h>
 
-int main(int argc, char** argv) {
-    printf("getgrent\n");
+int main(void) {
+    puts("getgrent\n");
     
     for (struct group* grp = getgrent(); grp != NULL; grp = getgrent())
         printf("    %s = %d\n", grp->gr_name, grp->gr_gid);
-}
\ No newline at end of file
+}
diff --git a/tests/libgen.c b/tests/libgen.c
index 0cdf8b8ade6ef4e6600c7a4580059b4db2010907..8cec95a78b424ae91bc516278dd0033c525906e0 100644
--- a/tests/libgen.c
+++ b/tests/libgen.c
@@ -111,7 +111,7 @@ int safe_strcmp(char *s1, char *s2) {
 int main(void) {
     int retval = EXIT_SUCCESS;
 
-    for(int i = 0; i < num_test_cases; ++i) {
+    for(size_t i = 0; i < num_test_cases; ++i) {
         struct test_case tc = test_cases[i];
         CHECK_TEST(tc, dirname, retval);
         CHECK_TEST(tc, basename, retval);
diff --git a/tests/pthread/cleanup.c b/tests/pthread/cleanup.c
index 446e946cf9605895d94c318e183074821d29aadb..194965ec982f441d99eab9bac28a39df74876bba 100644
--- a/tests/pthread/cleanup.c
+++ b/tests/pthread/cleanup.c
@@ -1,3 +1,4 @@
+#include <assert.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -10,45 +11,48 @@ const char *msg2 = "second";
 const char *msg3 = "third";
 
 void cleanup1(void *arg) {
-  printf("Running %s cleanup callback\n", (const char *)arg);
+    printf("Running %s cleanup callback\n", (const char *)arg);
 }
 void cleanup2(void *arg) {
-  fprintf(stderr, "Running %s cleanup callback, to stderr\n", (const char *)arg);
+    fprintf(stderr, "Running %s cleanup callback, to stderr\n", (const char *)arg);
 }
 void cleanup3(void *arg) {
-  printf("Running final (%s) callback\n", (const char *)arg);
+    printf("Running final (%s) callback\n", (const char *)arg);
 }
 
 void *routine(void *arg) {
-  puts("1");
-  pthread_cleanup_push(cleanup1, msg1);
-  puts("2");
-  pthread_cleanup_push(cleanup2, msg2);
-  puts("3");
-  pthread_cleanup_push(cleanup3, msg3);
-  puts("4");
-  pthread_cleanup_pop(true);
-  puts("5");
-  //exit(EXIT_SUCCESS);
-  pthread_exit(NULL);
-  puts("6");
-  pthread_cleanup_pop(true);
-  pthread_cleanup_pop(true);
+    assert(arg == NULL);
+
+    puts("1");
+    pthread_cleanup_push(cleanup1, msg1);
+    puts("2");
+    pthread_cleanup_push(cleanup2, msg2);
+    puts("3");
+    pthread_cleanup_push(cleanup3, msg3);
+    puts("4");
+    pthread_cleanup_pop(true);
+    puts("5");
+    //exit(EXIT_SUCCESS);
+    pthread_exit(NULL);
+    puts("6");
+    pthread_cleanup_pop(true);
+    pthread_cleanup_pop(true);
+    return NULL;
 }
 
 int main(void) {
-  int result;
+    int result;
 
-  puts("Main thread started");
-  pthread_t second_thread;
-  if ((result = pthread_create(&second_thread, NULL, routine, NULL)) != 0) {
-    fprintf(stderr, "thread creation failed: %s\n", strerror(result));
-    return EXIT_FAILURE;
-  }
-  if ((result = pthread_join(second_thread, NULL)) != 0) {
-    fprintf(stderr, "failed to join thread: %s\n", strerror(result));
-    return EXIT_FAILURE;
-  }
-  puts("Main thread about to exit");
-  return EXIT_SUCCESS;
+    puts("Main thread started");
+    pthread_t second_thread;
+    if ((result = pthread_create(&second_thread, NULL, routine, NULL)) != 0) {
+        fprintf(stderr, "thread creation failed: %s\n", strerror(result));
+        return EXIT_FAILURE;
+    }
+    if ((result = pthread_join(second_thread, NULL)) != 0) {
+        fprintf(stderr, "failed to join thread: %s\n", strerror(result));
+        return EXIT_FAILURE;
+    }
+    puts("Main thread about to exit");
+    return EXIT_SUCCESS;
 }
diff --git a/tests/pthread/extjoin.c b/tests/pthread/extjoin.c
index 78ab5b6a77a91eca22af9bc7ef312bfd6fae052e..05203e9fd603676bce16bf721c0657c1dcd6fb4c 100644
--- a/tests/pthread/extjoin.c
+++ b/tests/pthread/extjoin.c
@@ -8,60 +8,61 @@
 #include "common.h"
 
 struct arg2 {
-  int status;
-  pthread_t t1;
+    int status;
+    pthread_t t1;
 };
 
 void *routine1(void *arg) {
-  puts("Thread 1 spawned, waiting 1s.");
-  sleep(1);
-  puts("Thread 1 finished.");
-  return strdup("message from thread 1");
+    assert(arg == NULL);
+    puts("Thread 1 spawned, waiting 1s.");
+    sleep(1);
+    puts("Thread 1 finished.");
+    return strdup("message from thread 1");
 }
 void *routine2(void *arg_raw) {
-  struct arg2 *arg = arg_raw;
+    struct arg2 *arg = arg_raw;
 
-  puts("Thread 2 spawned, awaiting thread 1.");
+    puts("Thread 2 spawned, awaiting thread 1.");
 
-  void *retval_raw;
-  int status;
+    void *retval_raw;
+    int status;
 
-  if ((status = pthread_join(arg->t1, &retval_raw)) != 0) {
-    arg->status = fail(status, "t1 join from thread 2");
-    return NULL;
-  }
-  char *retval = retval_raw;
+    if ((status = pthread_join(arg->t1, &retval_raw)) != 0) {
+        arg->status = fail(status, "t1 join from thread 2");
+        return NULL;
+    }
+    char *retval = retval_raw;
 
-  assert(strcmp(retval, "message from thread 1") == 0);
+    assert(strcmp(retval, "message from thread 1") == 0);
 
-  free(retval);
+    free(retval);
 
-  return NULL;
+    return NULL;
 }
 
 int main(void) {
-  pthread_t t1;
-  pthread_t t2;
+    pthread_t t1;
+    pthread_t t2;
 
-  int status;
+    int status;
 
-  puts("Main thread.");
+    puts("Main thread.");
 
-  if ((status = pthread_create(&t1, NULL, routine1, NULL)) != 0) {
-    return fail(status, "t1 create");
-  }
+    if ((status = pthread_create(&t1, NULL, routine1, NULL)) != 0) {
+        return fail(status, "t1 create");
+    }
 
-  puts("Created thread 1.");
+    puts("Created thread 1.");
 
-  struct arg2 arg = { .status = 0, .t1 = t1 };
+    struct arg2 arg = { .status = 0, .t1 = t1 };
 
-  if ((status = pthread_create(&t2, NULL, routine2, &arg)) != 0) {
-    return fail(status, "t2 create");
-  }
+    if ((status = pthread_create(&t2, NULL, routine2, &arg)) != 0) {
+        return fail(status, "t2 create");
+    }
 
-  if ((status = pthread_join(t2, NULL)) != 0) {
-    return fail(status, "t2 join");
-  }
+    if ((status = pthread_join(t2, NULL)) != 0) {
+        return fail(status, "t2 join");
+    }
 
-  return EXIT_SUCCESS;
+    return EXIT_SUCCESS;
 }
diff --git a/tests/pthread/main.c b/tests/pthread/main.c
index 65c8a2d41c967993e9cdd7f5801fd04a6ef66386..fd9148076cdd24adf163676c6528c1f74c042d54 100644
--- a/tests/pthread/main.c
+++ b/tests/pthread/main.c
@@ -1,3 +1,4 @@
+#include <assert.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -8,26 +9,30 @@
 #include "common.h"
 
 void *thread_main(void *arg) {
-  puts("Thread main");
-  return NULL;
+    puts("Thread main");
+
+    assert(arg == NULL);
+
+    return NULL;
 }
 
 int main(void) {
-  int status;
+    int status;
 
-  puts("Start, sleeping 1 second");
-  sleep(1);
-  pthread_t thread;
-  void *arg = NULL;
-  if ((status = pthread_create(&thread, NULL, thread_main, arg)) != 0) {
-    return fail(status, "create thread");
-  }
-  puts("Started");
-  void *retval;
-  if ((status = pthread_join(thread, &retval)) != 0) {
-    return fail(status, "join thread");
-  }
-  puts("Joined");
+    puts("Start, sleeping 1 second");
+    sleep(1);
+    pthread_t thread;
+    void *arg = NULL;
+    if ((status = pthread_create(&thread, NULL, thread_main, arg)) != 0) {
+        return fail(status, "create thread");
+    }
+    puts("Started");
+    void *retval;
+    if ((status = pthread_join(thread, &retval)) != 0) {
+        return fail(status, "join thread");
+    }
+    assert(retval == NULL);
+    puts("Joined");
 
-  return EXIT_SUCCESS;
+    return EXIT_SUCCESS;
 }
diff --git a/tests/ptrace.c b/tests/ptrace.c
index bb918d1112e267530e57f54c5b40759bd60fc204..ef01252b452e3bcfe55d377824c92c9bb3655c85 100644
--- a/tests/ptrace.c
+++ b/tests/ptrace.c
@@ -10,12 +10,12 @@
 
 #ifdef __linux__
 
-const int SYS_write = 1;
+#define SYS_write 1
 
 #endif
 #ifdef __redox__
 
-const int SYS_write = 0x21000004;
+#define SYS_write 0x21000004
 
 #endif
 
diff --git a/tests/pwd.c b/tests/pwd.c
index 13761aae923417251326c17b5804057021068a9f..7d3942d930534255d53c20e9cb49e11b0962db60 100644
--- a/tests/pwd.c
+++ b/tests/pwd.c
@@ -85,7 +85,7 @@ int main(void) {
     errno = 0;
 
     struct passwd *entry = NULL;
-    for (int i = 1; entry = getpwent(); ++i) {
+    for (int i = 1; (entry = getpwent()); ++i) {
         int backup = errno;
         printf("--- getpwent #%d ---\n", i);
         if (backup != 0) {
diff --git a/tests/signal.c b/tests/signal.c
index b322201b8cd30ad92ccc2b5d56e27f78d1a33c8d..cdc300482163fff56976821f1d273120e60f3b5b 100644
--- a/tests/signal.c
+++ b/tests/signal.c
@@ -7,6 +7,7 @@
 #include "test_helpers.h"
 
 void handler(int sig) {
+    UNEXP_IF(signal, sig, != SIGUSR1);
     puts("Signal handler called!");
 }
 
diff --git a/tests/stdio/fread.c b/tests/stdio/fread.c
index 75eb7ff8f6dbb43f3cbe711b601f5a5c25f7e076..cc084d1cd453945382c5d23cba4ef9f664c7f798 100644
--- a/tests/stdio/fread.c
+++ b/tests/stdio/fread.c
@@ -10,9 +10,15 @@ int main(void) {
 
     char buf[33] = { 0 };
     for (int i = 1; i <= 32; ++i) {
-        if (fread(buf, 1, i, fp) < 0) {
-            perror("fread");
-            exit(EXIT_FAILURE);
+        size_t nread = fread(buf, 1, i, fp);
+        if (nread == 0) {
+            if (feof(fp)) {
+                fprintf(stderr, "early EOF\n");
+                return EXIT_FAILURE;
+            } else {
+                perror("fread");
+                return EXIT_FAILURE;
+            }
         }
         buf[i] = 0;
 
diff --git a/tests/stdio/freopen.c b/tests/stdio/freopen.c
index 3fb6069cbfdb65ed4fb56febb2c486d5bdf81553..f1415399bc5eb7abb3a8a98422c2c20021c50cfb 100644
--- a/tests/stdio/freopen.c
+++ b/tests/stdio/freopen.c
@@ -1,4 +1,5 @@
 #include <assert.h>
+#include <stddef.h>
 #include <stdio.h>
 #include <wchar.h>
 
@@ -32,7 +33,7 @@ int main(void) {
         &test_reopen_opens_file,
         &test_reopen_resets_orientation,
     };
-    for(int i=0; i<sizeof(tests)/sizeof(int(*)(void)); i++) {
+    for(size_t i = 0; i < sizeof(tests) / sizeof(int(*)(void)); i++) {
         printf("%d\n", (*tests[i])());
     }
 }
diff --git a/tests/stdio/getline.c b/tests/stdio/getline.c
index 299265fcf6f5b46fd2f267e3233dec3974ad3fcf..87a0fabca6d9d26ffe5cdb7684823d48b793ad24 100644
--- a/tests/stdio/getline.c
+++ b/tests/stdio/getline.c
@@ -66,6 +66,7 @@ void test_null_args() {
             free(lineptr);                           \
         stream = NULL;                               \
         errno = 0;                                   \
+        (void)n;                                     \
     } while (0);
 
         static size_t counter = 0;
diff --git a/tests/stdlib/alloc.c b/tests/stdlib/alloc.c
index f15149b5b0c96cf18db2d6a9d680775f8bed0207..dbddea02b8a3649133bc4afafb3b295b606ffa07 100644
--- a/tests/stdlib/alloc.c
+++ b/tests/stdlib/alloc.c
@@ -89,7 +89,7 @@ int main(void) {
     size_t nonpow2_mul_voidptr_size = 3*sizeof(void *);
     size_t pow2_mul_voidptr_size = 4*sizeof(void *);
     
-    int i;
+    size_t i;
     
     errno = 0;
     char * ptr_zerosize_malloc = (char *)malloc(zero_size);
diff --git a/tests/stdlib/qsort.c b/tests/stdlib/qsort.c
index 24c742d35e350c70a9fed0530c8b4edb980e8da4..0de6d141b5ea3ee3001d1c53e39c5c7d42fe8402 100644
--- a/tests/stdlib/qsort.c
+++ b/tests/stdlib/qsort.c
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stddef.h>
 #include <stdlib.h>
 
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
@@ -12,7 +13,7 @@ int cmpfunc (const void * a_ptr, const void * b_ptr) {
 }
 
 int main () {
-    int i;
+    size_t i;
 
     printf("Before: ");
     for(i = 0; i < ARRAY_SIZE(values); i++) {
diff --git a/tests/stdlib/strtod.c b/tests/stdlib/strtod.c
index 44fd371ec27ac2869ecf096238d63631bea377eb..8b0450259abfc1b4fd3f3c4a5a9d696679d623e1 100644
--- a/tests/stdlib/strtod.c
+++ b/tests/stdlib/strtod.c
@@ -1,3 +1,4 @@
+#include <stddef.h>
 #include <stdlib.h>
 #include <stdio.h>
 
@@ -73,7 +74,7 @@ int main(void) {
         "-NaN0.1e5", "-nan-37", "-nAn1.05", "-Nan foo bar baz",
 
     };
-    for (int i = 0; i < sizeof(inputs) / sizeof(char*); i += 1) {
+    for (size_t i = 0; i < sizeof(inputs) / sizeof(char*); i += 1) {
         d = strtod(inputs[i], &endptr);
         printf("d: %f Endptr: \"%s\"\n", d, endptr);
     }
diff --git a/tests/sys_epoll/epoll.c b/tests/sys_epoll/epoll.c
index a91fbb4060b7e94e4b64a3f4cdfacba3ef2156b4..197b6ac0289efe956268a2d670e87563ffa12fe5 100644
--- a/tests/sys_epoll/epoll.c
+++ b/tests/sys_epoll/epoll.c
@@ -5,6 +5,8 @@
 #include <unistd.h>
 #include <errno.h>
 
+#include "../test_helpers.h"
+
 int reader(int fd) {
     // Create an epoll file
     int epollfd = epoll_create1(EPOLL_CLOEXEC);
@@ -52,12 +54,12 @@ int reader(int fd) {
             if (events[n].data.fd == fd) {
                 // Read the current event count
                 int writer_i;
-                int count = read(fd, &writer_i, sizeof(writer_i));
-                if (count < 0) {
-                    perror("read");
-                    return 1;
-                } else if (count < sizeof(writer_i)) {
-                    fprintf(stderr, "read %d instead of %d\n", count, sizeof(writer_i));
+                ssize_t status = read(fd, &writer_i, sizeof(writer_i));
+                ERROR_IF(read, status, == -1);
+                size_t count = (size_t)status;
+
+                if (count < sizeof(writer_i)) {
+                    fprintf(stderr, "read %zu instead of %d\n", count, sizeof(writer_i));
                     return 1;
                 }
                 // Make sure the writer's event count matches our own
@@ -109,12 +111,12 @@ int writer(int fd) {
             // If the event is the writer file
             if (events[n].data.fd == fd) {
                 // Write the current event count
-                int count = write(fd, &i, sizeof(i));
-                if (count < 0) {
-                    perror("write");
-                    return 1;
-                } else if (count < sizeof(i)) {
-                    fprintf(stderr, "wrote %d instead of %d\n", count, sizeof(i));
+                ssize_t status = write(fd, &i, sizeof(i));
+                ERROR_IF(write, status, == -1);
+                size_t count = (size_t)status;
+
+                if (count < sizeof(i)) {
+                    fprintf(stderr, "wrote %zu instead of %d\n", count, sizeof(i));
                     return 1;
                 }
             } else {
@@ -128,7 +130,7 @@ int writer(int fd) {
     return 0;
 }
 
-int main(int argc, char **argv) {
+int main(void) {
     // Create a non-blocking pipe to use for epoll testing
     int pipefd[2];
     if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) < 0) {
diff --git a/tests/time/localtime.c b/tests/time/localtime.c
index fd7af735ce1365c07969fc9e585cf0360ec34cdd..9d1098fd40865620f3c5c5ac24b77d8ff5f6ae6e 100644
--- a/tests/time/localtime.c
+++ b/tests/time/localtime.c
@@ -1,3 +1,4 @@
+#include <stddef.h>
 #include <stdio.h>
 #include <time.h>
 
@@ -6,7 +7,7 @@
 int main(void) {
     int day = 60 * 60 * 24;
     time_t inputs[] = { -(day * 33), -day, -1, -500, 0, 1, 1531454950 };
-    for (int i = 0; i < (sizeof(inputs) / sizeof(time_t)); i += 1) {
+    for (size_t i = 0; i < (sizeof(inputs) / sizeof(time_t)); i += 1) {
         struct tm* t = localtime(&inputs[i]);
 
         printf(
@@ -24,8 +25,7 @@ int main(void) {
     char *ctime_r_result = ctime_r(&input, ctime_r_buffer);
     if (ctime_r_result == ctime_r_buffer) {
         fputs(ctime_r_result, stdout);
-    }
-    else {
+    } else {
         printf("Unexpected pointer from ctime_r: %p\n", ctime_r_result);
     }
 }
diff --git a/tests/tls.c b/tests/tls.c
index 0257427e5c2e89775bb6532f3ec2baeb1d754841..2be0006d3ea14ea40e0df9b3541b4b226f4d781f 100644
--- a/tests/tls.c
+++ b/tests/tls.c
@@ -3,7 +3,7 @@
 _Thread_local int tbss = 0;
 _Thread_local int tdata = 1;
 
-int main(int argc, char ** argv) {
+int main(void) {
     printf("%d == 0\n", tbss);
     printf("%d == 1\n", tdata);
     return 0;
diff --git a/tests/unistd/getopt.c b/tests/unistd/getopt.c
index ff41b517aa1d3798e5d7c78b4a4c96b89b9426ed..2505788a25a6648ada02f429508b2da9ed2a13be 100644
--- a/tests/unistd/getopt.c
+++ b/tests/unistd/getopt.c
@@ -60,7 +60,7 @@ int runner(int argc, char *argv[]) {
     return 0;
 }
 
-int main(int argc, const char *argv[]) {
+int main(void) {
     RUN("test", "-ao", "arg", "path", "path");
     RUN("test", "-a", "-o", "arg", "path", "path");
     RUN("test", "-o", "arg", "-a", "path", "path");
diff --git a/tests/unistd/getopt_long.c b/tests/unistd/getopt_long.c
index 9af233cf508ccff72194cfece56dd0660c4b816b..1efb0a4a1226d02becdd133cd2feef379dbaad90 100644
--- a/tests/unistd/getopt_long.c
+++ b/tests/unistd/getopt_long.c
@@ -55,7 +55,7 @@ void runner(int argc, char *argv[]) {
     }
 }
 
-int main(int argc, const char *argv[]) {
+int main(void) {
     RUN("test", "--test0", "-a");
     RUN("test", "--test1", "-a");
     RUN("test", "--test2", "-a");
diff --git a/tests/unistd/pipe.c b/tests/unistd/pipe.c
index 85e6db5abfe4858031557d55437fd7d2f9f0e750..9f4b79a62e845ef5bdfd8755d2b58a16ac95220f 100644
--- a/tests/unistd/pipe.c
+++ b/tests/unistd/pipe.c
@@ -26,11 +26,11 @@ int main(void) {
         UNEXP_IF(close, cr, != 0);
 
         // send 7 characters in the string, including end-of-string
-        int bytes = write(pip[1], outstring, strlen(outstring));
+        ssize_t bytes = write(pip[1], outstring, strlen(outstring));
         ERROR_IF(write, bytes, == -1);
 
         // check result
-        if (bytes != strlen(outstring)) {
+        if ((size_t)bytes != strlen(outstring)) {
             fprintf(stderr, "pipe write: %d != %ld\n", bytes, strlen(outstring));
             exit(EXIT_FAILURE);
         }
@@ -52,11 +52,11 @@ int main(void) {
         memset(instring, 0, sizeof(instring));
 
         // read from the pipe
-        int bytes = read(pip[0], instring, sizeof(instring) - 1);
+        ssize_t bytes = read(pip[0], instring, sizeof(instring) - 1);
         ERROR_IF(read, bytes, == -1);
 
         // check result
-        if (bytes != strlen(outstring)) {
+        if ((size_t)bytes != strlen(outstring)) {
             fprintf(stderr, "pipe read: %d != %ld\n", bytes, strlen(outstring));
             exit(EXIT_FAILURE);
         } else if (memcmp(instring, outstring, strlen(outstring)) != 0) {
diff --git a/tests/unistd/swab.c b/tests/unistd/swab.c
index d7927b66fa584260eba15be8255d20877c509a18..c883b0cb355452f84d285448eab3f3243ba88d15 100644
--- a/tests/unistd/swab.c
+++ b/tests/unistd/swab.c
@@ -1,15 +1,14 @@
 #include <stdio.h>
 #include <unistd.h>
 
-int main(int argc, char ** argv) {
-
+int main(void) {
     const char source[] = {0, 1, 2, 3, 4, 5, 6};
     char destination[] = {0, 0, 0, 0, 0, 0};
     const char flipped_source[] = {1, 0, 3, 2, 5, 4};
     const char first_two_source_bytes_flipped[] = {1, 0};
 
     swab(source, destination, /* nbytes */ -3);
-    for (int i = 0; i < sizeof(destination); ++i) {
+    for (size_t i = 0; i < sizeof(destination); ++i) {
         if (destination[i] != 0) {
             puts("If nbytes is negative destionation shouldn't be modified");
             return 1;
@@ -17,7 +16,7 @@ int main(int argc, char ** argv) {
     }
 
     swab(source, destination, /* nbytes */ 0);
-    for (int i = 0; i < sizeof(destination); ++i) {
+    for (size_t i = 0; i < sizeof(destination); ++i) {
         if (destination[i] != 0) {
             puts("If nbytes is zero destionation shouldn't be modified");
             return 1;
@@ -25,7 +24,7 @@ int main(int argc, char ** argv) {
     }
 
     swab(source, destination, /* nbytes */ 3);
-    for (int i = 0; i < sizeof(first_two_source_bytes_flipped); ++i) {
+    for (size_t i = 0; i < sizeof(first_two_source_bytes_flipped); ++i) {
         if (destination[i] != first_two_source_bytes_flipped[i]) {
             puts("copied bytes don't match expected values");
             return 1;
@@ -33,7 +32,7 @@ int main(int argc, char ** argv) {
     }
     // If nbytes is not even it's not specified what should happen to the
     // last byte so the third byte in destination is not checked.
-    for (int i = sizeof(first_two_source_bytes_flipped) + 1; i < sizeof(destination); ++i) {
+    for (size_t i = sizeof(first_two_source_bytes_flipped) + 1; i < sizeof(destination); ++i) {
         if (destination[i] != 0) {
             puts("swab modified too many bytes in destination");
             return 1;
@@ -41,7 +40,7 @@ int main(int argc, char ** argv) {
     }
 
     swab(source, destination, /* nbytes */ sizeof(destination));
-    for (int i = 0; i < sizeof(destination); ++i) {
+    for (size_t i = 0; i < sizeof(destination); ++i) {
         if (destination[i] != flipped_source[i]) {
             puts("copied bytes don't match expected values");
             return 1;
diff --git a/tests/wchar/fwide.c b/tests/wchar/fwide.c
index 6511e56778b0546e351002efa4a00479fa5dad8a..12eceb75a0ee6ce62d5d5925f493d72e4fd67cb4 100644
--- a/tests/wchar/fwide.c
+++ b/tests/wchar/fwide.c
@@ -53,7 +53,7 @@ int main() {
 		&test_manual_wchar_orientation,
 		&test_orientation_after_fprintf,
 	};
-	for(int i=0; i<sizeof(tests)/sizeof(int(*)(void)); i++) {
+	for(size_t i = 0; i < sizeof(tests) / sizeof(int(*)(void)); i++) {
 		printf("%d\n", (*tests[i])());
 	}
 }
diff --git a/tests/wctype/towlower.c b/tests/wctype/towlower.c
index fe92d71c963fc30bc9eb5bd5d6fb8ce49a662b11..93767c82c907503bc63c7475b52e490be771c298 100644
--- a/tests/wctype/towlower.c
+++ b/tests/wctype/towlower.c
@@ -1,3 +1,4 @@
+#include <stddef.h>
 #include <stdio.h>
 #include <wchar.h>
 #include <wctype.h>
@@ -5,7 +6,7 @@
 int main() {
     wchar_t *str = L"HaLf WiDe ChAr StRiNg!\n";
     fputws(str, stdout);
-    for (int i = 0; i < wcslen(str); i++) {
+    for (size_t i = 0; i < wcslen(str); i++) {
         putwchar(towctrans(str[i], wctrans("tolower")));
     }
     return 0;
diff --git a/tests/wctype/towupper.c b/tests/wctype/towupper.c
index 72404edd7d59ce059443d72f2f6fdcff8f23d236..a9bb4fbfe53d48213c99ad7aba2c65cfb223cc50 100644
--- a/tests/wctype/towupper.c
+++ b/tests/wctype/towupper.c
@@ -1,11 +1,12 @@
 #include <stdio.h>
+#include <stddef.h>
 #include <wchar.h>
 #include <wctype.h>
 
 int main() {
     wchar_t *str = L"HaLf WiDe ChAr StRiNg!\n";
     fputws(str, stdout);
-    for (int i = 0; i < wcslen(str); i++) {
+    for (size_t i = 0; i < wcslen(str); i++) {
         putwchar(towctrans(str[i], wctrans("toupper")));
     }
     return 0;