From: Augustin Degomme Date: Sat, 2 Sep 2017 15:28:39 +0000 (+0200) Subject: avoid potential division by 0... But not sure 0 is right as an answer here X-Git-Tag: v3_17~171 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b98b530ed10d60d9c350bf4919896a0c50b649f3 avoid potential division by 0... But not sure 0 is right as an answer here --- diff --git a/src/smpi/colls/coll_tuned_topo.cpp b/src/smpi/colls/coll_tuned_topo.cpp index aa797a9884..db88a997bb 100644 --- a/src/smpi/colls/coll_tuned_topo.cpp +++ b/src/smpi/colls/coll_tuned_topo.cpp @@ -52,7 +52,10 @@ static int calculate_num_nodes_up_to_level( int fanout, int level ) { /* just use geometric progression formula for sum: a^0+a^1+...a^(n-1) = (a^n-1)/(a-1) */ - return ((pown(fanout,level) - 1)/(fanout - 1)); + if(fanout > 1) + return ((pown(fanout,level) - 1)/(fanout - 1)); + else + return 0; // is this right ? } /*