From: Arnaud Giersch Date: Fri, 16 Apr 2021 22:11:41 +0000 (+0200) Subject: A for-loop with 'num' modified in the body is too complex according to Sonar. X-Git-Tag: v3.28~455^2~18 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c6b98b47d12d799b9da4232012268f39ea424daa A for-loop with 'num' modified in the body is too complex according to Sonar. --- diff --git a/src/smpi/mpi/smpi_topo.cpp b/src/smpi/mpi/smpi_topo.cpp index 14e819fc26..5f28d6fc49 100644 --- a/src/smpi/mpi/smpi_topo.cpp +++ b/src/smpi/mpi/smpi_topo.cpp @@ -383,11 +383,13 @@ static int getfactors(int num, std::vector& factors) factors.push_back(2); } /* determine all occurrences of uneven prime numbers up to sqrt(num) */ - for (int d = 3; (num > 1) && (d * d < num); d += 2) { + int d = 3; + while ((num > 1) && (d * d < num)) { while((num % d) == 0) { num /= d; factors.push_back(d); } + d += 2; } /* as we looped only up to sqrt(num) one factor > sqrt(num) may be left over */ if(num != 1) {