From 0d4b43e53d5792b3707afd462b0c12e40a09f162 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Thu, 1 Mar 2018 17:01:22 +0100
Subject: [PATCH] Add explicit casts after malloc() in the cosmology section of
 the code.

---
 src/cosmology.c   | 10 ++++++----
 src/engine.c      |  6 ++++--
 src/parallel_io.c |  7 +++----
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/cosmology.c b/src/cosmology.c
index e330031a6c..53fa5a42d4 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 df55ac42ce..923d7d5464 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 aa786ca121..3b0eef23e7 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);
   }
-- 
GitLab