diff --git a/src/single_io.c b/src/single_io.c
index d7afdd4a886ccde9701e7665f978e4e2ffa907aa..866d830ac59f2f7f6d7e84212f80e715ed066b6c 100644
--- a/src/single_io.c
+++ b/src/single_io.c
@@ -315,8 +315,9 @@ void writeArray(const struct engine* e, hid_t grp, char* fileName,
  * @todo Read snapshots distributed in more than one file.
  *
  */
-void read_ic_single(char* fileName, const struct unit_system* internal_units,
-                    double dim[3], struct part** parts, struct gpart** gparts,
+void read_ic_single(const char* fileName,
+                    const struct unit_system* internal_units, double dim[3],
+                    struct part** parts, struct gpart** gparts,
                     struct spart** sparts, size_t* Ngas, size_t* Ngparts,
                     size_t* Nstars, int* periodic, int* flag_entropy,
                     int with_hydro, int with_gravity, int with_stars,
diff --git a/src/single_io.h b/src/single_io.h
index 26b849716e3e018d9a10c5c5c513ad26c7ccb274..aa1a3b7de82e6f882b3a59064eb351e7c65c6aab 100644
--- a/src/single_io.h
+++ b/src/single_io.h
@@ -29,8 +29,9 @@
 #include "part.h"
 #include "units.h"
 
-void read_ic_single(char* fileName, const struct unit_system* internal_units,
-                    double dim[3], struct part** parts, struct gpart** gparts,
+void read_ic_single(const char* fileName,
+                    const struct unit_system* internal_units, double dim[3],
+                    struct part** parts, struct gpart** gparts,
                     struct spart** sparts, size_t* Ngas, size_t* Ndm,
                     size_t* Nstars, int* periodic, int* flag_entropy,
                     int with_hydro, int with_gravity, int with_stars,
diff --git a/tests/test125cells.c b/tests/test125cells.c
index a50b847308422cbf10f58c737811934979d21899..41023aec16d1a3619d58caf8fbb01f08285f0661 100644
--- a/tests/test125cells.c
+++ b/tests/test125cells.c
@@ -268,7 +268,7 @@ struct cell *make_cell(size_t n, const double offset[3], double size, double h,
 
   const size_t count = n * n * n;
   const double volume = size * size * size;
-  struct cell *cell = malloc(sizeof(struct cell));
+  struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
   bzero(cell, sizeof(struct cell));
 
   if (posix_memalign((void **)&cell->parts, part_align,
@@ -637,8 +637,8 @@ int main(int argc, char *argv[]) {
   main_cell = cells[62];
 
   /* Construct the real solution */
-  struct solution_part *solution =
-      malloc(main_cell->count * sizeof(struct solution_part));
+  struct solution_part *solution = (struct solution_part *)malloc(
+      main_cell->count * sizeof(struct solution_part));
   get_solution(main_cell, solution, rho, vel, press, size);
 
   ticks timings[27];
diff --git a/tests/test27cells.c b/tests/test27cells.c
index e60262df71f6dc455e944b82a337261a57bcc9bc..ccaaad8e8644ae72973c9b93eb0af44c77061113 100644
--- a/tests/test27cells.c
+++ b/tests/test27cells.c
@@ -98,7 +98,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
   const size_t count = n * n * n;
   const double volume = size * size * size;
   float h_max = 0.f;
-  struct cell *cell = malloc(sizeof(struct cell));
+  struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
   bzero(cell, sizeof(struct cell));
 
   if (posix_memalign((void **)&cell->parts, part_align,
@@ -502,7 +502,7 @@ int main(int argc, char *argv[]) {
 #if defined(TEST_DOSELF_SUBSET) || defined(TEST_DOPAIR_SUBSET)
     int *pid = NULL;
     int count = 0;
-    if ((pid = malloc(sizeof(int) * main_cell->count)) == NULL)
+    if ((pid = (int *)malloc(sizeof(int) * main_cell->count)) == NULL)
       error("Can't allocate memory for pid.");
     for (int k = 0; k < main_cell->count; k++)
       if (part_is_active(&main_cell->parts[k], &engine)) {
diff --git a/tests/testActivePair.c b/tests/testActivePair.c
index 0453f6d5896eaa53b0f44a567d353d7d8e8fb7df..4a70e341d0160193da595274f47e943c76390c15 100644
--- a/tests/testActivePair.c
+++ b/tests/testActivePair.c
@@ -59,7 +59,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
   const size_t count = n * n * n;
   const double volume = size * size * size;
   float h_max = 0.f;
-  struct cell *cell = malloc(sizeof(struct cell));
+  struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
   bzero(cell, sizeof(struct cell));
 
   if (posix_memalign((void **)&cell->parts, part_align,
diff --git a/tests/testDump.c b/tests/testDump.c
index fa68ef9869f2f3ac2ee790b9815e42f73976ac9f..f47a44256536d6ac1d9676c844f7081a6daa5ca4 100644
--- a/tests/testDump.c
+++ b/tests/testDump.c
@@ -38,7 +38,7 @@
 void dump_mapper(void *map_data, int num_elements, void *extra_data) {
   struct dump *d = (struct dump *)extra_data;
   size_t offset;
-  char *out_string = dump_get(d, 7, &offset);
+  char *out_string = (char *)dump_get(d, 7, &offset);
   char out_buff[8];
   /* modulo due to bug in gcc, should be removed */
   snprintf(out_buff, 8, "%06zi\n", (offset / 7) % 1000000);
diff --git a/tests/testFFT.c b/tests/testFFT.c
index 373b02ecff5231f98d36db4247dfb93fa079feb4..5661ec6d98652cd8cbf229f1f345663d422ae588 100644
--- a/tests/testFFT.c
+++ b/tests/testFFT.c
@@ -68,7 +68,8 @@ int main(int argc, char *argv[]) {
   gparts[0].mass = 1.f;
 
   /* Read the parameter file */
-  struct swift_params *params = malloc(sizeof(struct swift_params));
+  struct swift_params *params =
+      (struct swift_params *)malloc(sizeof(struct swift_params));
   parser_read_file("fft_params.yml", params);
 
   struct cosmology cosmo;
@@ -116,10 +117,10 @@ int main(int argc, char *argv[]) {
 
   /* Now check that we got the right answer */
   int nr_cells = space.nr_cells;
-  double *r = malloc(nr_cells * sizeof(double));
-  double *m = malloc(nr_cells * sizeof(double));
-  double *pot = malloc(nr_cells * sizeof(double));
-  double *pot_exact = malloc(nr_cells * sizeof(double));
+  double *r = (double *)malloc(nr_cells * sizeof(double));
+  double *m = (double *)malloc(nr_cells * sizeof(double));
+  double *pot = (double *)malloc(nr_cells * sizeof(double));
+  double *pot_exact = (double *)malloc(nr_cells * sizeof(double));
 
   FILE *file = fopen("potential.dat", "w");
   for (int i = 0; i < nr_cells; ++i) {
diff --git a/tests/testLogger.c b/tests/testLogger.c
index 9ec08607383fdb192b7ba994e4af506fde12fea9..b954b67ad6044ae5ec734706f7a1a4ff181541d8 100644
--- a/tests/testLogger.c
+++ b/tests/testLogger.c
@@ -63,7 +63,7 @@ void test_log_parts(struct dump *d) {
   /* Recover the last part from the dump. */
   bzero(&p, sizeof(struct part));
   size_t offset_old = offset;
-  int mask = logger_read_part(&p, &offset, d->data);
+  int mask = logger_read_part(&p, &offset, (const char *)d->data);
   printf(
       "Recovered part at offset %#016zx with mask %#04x: p.x[0]=%e, "
       "p.v[0]=%e.\n",
@@ -76,7 +76,7 @@ void test_log_parts(struct dump *d) {
   /* Recover the second part from the dump (only position). */
   bzero(&p, sizeof(struct part));
   offset_old = offset;
-  mask = logger_read_part(&p, &offset, d->data);
+  mask = logger_read_part(&p, &offset, (const char *)d->data);
   printf(
       "Recovered part at offset %#016zx with mask %#04x: p.x[0]=%e, "
       "p.v[0]=%e.\n",
@@ -89,7 +89,7 @@ void test_log_parts(struct dump *d) {
   /* Recover the first part from the dump. */
   bzero(&p, sizeof(struct part));
   offset_old = offset;
-  mask = logger_read_part(&p, &offset, d->data);
+  mask = logger_read_part(&p, &offset, (const char *)d->data);
   printf(
       "Recovered part at offset %#016zx with mask %#04x: p.x[0]=%e, "
       "p.v[0]=%e.\n",
@@ -131,7 +131,7 @@ void test_log_gparts(struct dump *d) {
   /* Recover the last part from the dump. */
   bzero(&p, sizeof(struct gpart));
   size_t offset_old = offset;
-  int mask = logger_read_gpart(&p, &offset, d->data);
+  int mask = logger_read_gpart(&p, &offset, (const char *)d->data);
   printf(
       "Recovered gpart at offset %#016zx with mask %#04x: p.x[0]=%e, "
       "p.v[0]=%e.\n",
@@ -144,7 +144,7 @@ void test_log_gparts(struct dump *d) {
   /* Recover the second part from the dump. */
   bzero(&p, sizeof(struct gpart));
   offset_old = offset;
-  mask = logger_read_gpart(&p, &offset, d->data);
+  mask = logger_read_gpart(&p, &offset, (const char *)d->data);
   printf(
       "Recovered gpart at offset %#016zx with mask %#04x: p.x[0]=%e, "
       "p.v[0]=%e.\n",
@@ -157,7 +157,7 @@ void test_log_gparts(struct dump *d) {
   /* Recover the first part from the dump. */
   bzero(&p, sizeof(struct gpart));
   offset_old = offset;
-  mask = logger_read_gpart(&p, &offset, d->data);
+  mask = logger_read_gpart(&p, &offset, (const char *)d->data);
   printf(
       "Recovered gpart at offset %#016zx with mask %#04x: p.x[0]=%e, "
       "p.v[0]=%e.\n",
@@ -189,7 +189,7 @@ void test_log_timestamps(struct dump *d) {
   /* Recover the three timestamps. */
   size_t offset_old = offset;
   t = 0;
-  int mask = logger_read_timestamp(&t, &offset, d->data);
+  int mask = logger_read_timestamp(&t, &offset, (const char *)d->data);
   printf("Recovered timestamp %020llu at offset %#016zx with mask %#04x.\n", t,
          offset_old, mask);
   if (t != 30) {
@@ -199,7 +199,7 @@ void test_log_timestamps(struct dump *d) {
 
   offset_old = offset;
   t = 0;
-  mask = logger_read_timestamp(&t, &offset, d->data);
+  mask = logger_read_timestamp(&t, &offset, (const char *)d->data);
   printf("Recovered timestamp %020llu at offset %#016zx with mask %#04x.\n", t,
          offset_old, mask);
   if (t != 20) {
@@ -209,7 +209,7 @@ void test_log_timestamps(struct dump *d) {
 
   offset_old = offset;
   t = 0;
-  mask = logger_read_timestamp(&t, &offset, d->data);
+  mask = logger_read_timestamp(&t, &offset, (const char *)d->data);
   printf("Recovered timestamp %020llu at offset %#016zx with mask %#04x.\n", t,
          offset_old, mask);
   if (t != 10) {
diff --git a/tests/testPeriodicBC.c b/tests/testPeriodicBC.c
index 385de9752f361f4f015eb64a466473324901030f..3e4cb5d3816ad706cd5f083912da7f453a2a0e5a 100644
--- a/tests/testPeriodicBC.c
+++ b/tests/testPeriodicBC.c
@@ -78,7 +78,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
                        enum velocity_types vel) {
   const size_t count = n * n * n;
   const double volume = size * size * size;
-  struct cell *cell = malloc(sizeof(struct cell));
+  struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
   bzero(cell, sizeof(struct cell));
 
   if (posix_memalign((void **)&cell->parts, part_align,
diff --git a/tests/testPotentialPair.c b/tests/testPotentialPair.c
index cdffaef469096085db87b68d315066b8c8e54e3e..1f7b0ab0c2577e3b2adc71ca8c121d275679b63d 100644
--- a/tests/testPotentialPair.c
+++ b/tests/testPotentialPair.c
@@ -150,8 +150,10 @@ int main(int argc, char *argv[]) {
   cj.ti_gravity_end_max = 8;
 
   /* Allocate multipoles */
-  ci.multipole = malloc(sizeof(struct gravity_tensors));
-  cj.multipole = malloc(sizeof(struct gravity_tensors));
+  ci.multipole =
+      (struct gravity_tensors *)malloc(sizeof(struct gravity_tensors));
+  cj.multipole =
+      (struct gravity_tensors *)malloc(sizeof(struct gravity_tensors));
   bzero(ci.multipole, sizeof(struct gravity_tensors));
   bzero(cj.multipole, sizeof(struct gravity_tensors));
 
diff --git a/tests/testSPHStep.c b/tests/testSPHStep.c
index cda1fb9ecb65d3a285ff37d281a74b2b3cf5fa43..63834d94b7696e160dd7ca487ab7e9f1e943abfb 100644
--- a/tests/testSPHStep.c
+++ b/tests/testSPHStep.c
@@ -27,7 +27,7 @@
  */
 struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) {
   size_t count = N * N * N;
-  struct cell *cell = malloc(sizeof(struct cell));
+  struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
   bzero(cell, sizeof(struct cell));
   struct part *part;
   struct xpart *xpart;
diff --git a/tests/testTimeIntegration.c b/tests/testTimeIntegration.c
index 49900572108a4948f867824da8f7d9608cb0d25a..2034c402a2d626a7b503613f6cade821ec438151 100644
--- a/tests/testTimeIntegration.c
+++ b/tests/testTimeIntegration.c
@@ -63,10 +63,10 @@ int main(int argc, char *argv[]) {
 
   /* Create a particle */
   struct part *parts = NULL;
-  parts = malloc(sizeof(struct part));
+  parts = (struct part *)malloc(sizeof(struct part));
   bzero(parts, sizeof(struct part));
   struct xpart *xparts = NULL;
-  xparts = malloc(sizeof(struct xpart));
+  xparts = (struct xpart *)malloc(sizeof(struct xpart));
   bzero(xparts, sizeof(struct xpart));
 
   /* Put the particle on the orbit */