From e4df2b484ccbdeb2c8753d7b52317f1f16f6fa50 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Thu, 15 Nov 2018 21:42:46 +0100
Subject: [PATCH] Cleaner version of the proxy existence check in the task
 creation.

---
 src/engine_maketasks.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c
index 35d9a420bc..e545efca9e 100644
--- a/src/engine_maketasks.c
+++ b/src/engine_maketasks.c
@@ -868,13 +868,12 @@ void engine_make_self_gravity_tasks_mapper(void *map_data, int num_elements,
               const struct proxy *p = &e->proxies[proxy_id];
 
               /* Check whether the cell exists in the proxy */
-              int n = 0, err = 1;
+              int n = 0;
               for (; n < p->nr_cells_in; n++)
                 if (p->cells_in[n] == cj) {
-                  err = 0;
                   break;
                 }
-              if (err)
+              if (n == p->nr_cells_in)
                 error(
                     "Cell %d not found in the proxy but trying to construct "
                     "grav task!",
@@ -889,13 +888,12 @@ void engine_make_self_gravity_tasks_mapper(void *map_data, int num_elements,
               const struct proxy *p = &e->proxies[proxy_id];
 
               /* Check whether the cell exists in the proxy */
-              int n = 0, err = 1;
+              int n = 0;
               for (; n < p->nr_cells_in; n++)
                 if (p->cells_in[n] == ci) {
-                  err = 0;
                   break;
                 }
-              if (err)
+              if (n == p->nr_cells_in)
                 error(
                     "Cell %d not found in the proxy but trying to construct "
                     "grav task!",
-- 
GitLab