diff --git a/src/cosmology.c b/src/cosmology.c
index e330031a6c79d0fd3c3e0cab0764a1f6510e3f11..53fa5a42d42989375a253fb305cbe6880e1501b4 100644
--- a/src/cosmology.c
+++ b/src/cosmology.c
@@ -290,12 +290,14 @@ void cosmology_init_tables(struct cosmology *c) {
   const double a_begin = c->a_begin;
 
   /* Allocate memory for the interpolation tables */
-  c->drift_fac_interp_table = malloc(cosmology_table_length * sizeof(double));
+  c->drift_fac_interp_table =
+      (double *)malloc(cosmology_table_length * sizeof(double));
   c->grav_kick_fac_interp_table =
-      malloc(cosmology_table_length * sizeof(double));
+      (double *)malloc(cosmology_table_length * sizeof(double));
   c->hydro_kick_fac_interp_table =
-      malloc(cosmology_table_length * sizeof(double));
-  c->time_interp_table = malloc(cosmology_table_length * sizeof(double));
+      (double *)malloc(cosmology_table_length * sizeof(double));
+  c->time_interp_table =
+      (double *)malloc(cosmology_table_length * sizeof(double));
 
   /* Prepare a table of scale factors for the integral bounds */
   const double delta_a =
diff --git a/src/engine.c b/src/engine.c
index df55ac42ce90dc19b7d8ae7790d6d90b7dc22ced..923d7d5464bfb743300bd80c01d517e5df8ddcdc 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -5917,7 +5917,8 @@ void engine_struct_restore(struct engine *e, FILE *stream) {
   units_struct_restore(us, stream);
   e->snapshotUnits = us;
 
-  struct cosmology *cosmo = malloc(sizeof(struct cosmology));
+  struct cosmology *cosmo =
+      (struct cosmology *)malloc(sizeof(struct cosmology));
   cosmology_struct_restore(cosmo, stream);
   e->cosmology = cosmo;
 
@@ -5954,7 +5955,8 @@ void engine_struct_restore(struct engine *e, FILE *stream) {
   cooling_struct_restore(cooling_func, stream);
   e->cooling_func = cooling_func;
 
-  struct chemistry_data *chemistry = malloc(sizeof(struct chemistry_data));
+  struct chemistry_data *chemistry =
+      (struct chemistry_data *)malloc(sizeof(struct chemistry_data));
   chemistry_struct_restore(chemistry, stream);
   e->chemistry = chemistry;
 
diff --git a/src/parallel_io.c b/src/parallel_io.c
index aa786ca121c2cd4176ecc4d7396567ad566b2781..3b0eef23e7f96b25faaf933743b4fdb3bca46db5 100644
--- a/src/parallel_io.c
+++ b/src/parallel_io.c
@@ -931,10 +931,9 @@ void prepare_file(struct engine* e, const char* baseName, long long N_total[6],
 
   /* Print the gravity parameters */
   if (e->policy & engine_policy_cosmology) {
-    h_grp = H5Gcreate(h_file, "/Cosmology", H5P_DEFAULT, H5P_DEFAULT,
-                      H5P_DEFAULT);
-    if (h_grp < 0)
-        error("Error while creating cosmology group");
+    h_grp =
+        H5Gcreate(h_file, "/Cosmology", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+    if (h_grp < 0) error("Error while creating cosmology group");
     cosmology_write_model(h_grp, e->cosmology);
     H5Gclose(h_grp);
   }