From bacc34d26021704927d8e06e7d2ec198e418b93d Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Fri, 16 Mar 2018 00:12:28 +0100
Subject: [PATCH] Silents sonarqube bugs in many places

---
 compute/pzgebrd_ge2gb.c           |  6 +--
 compute/pzgelqf_param.c           |  1 -
 compute/pztradd.c                 |  1 -
 compute/pztrsm.c                  |  1 -
 compute/pzunmqr.c                 |  1 -
 compute/pzunmqrrh.c               |  1 -
 compute/zgesvd.c                  | 66 +++++++++++++------------------
 compute/zlange.c                  |  6 +--
 compute/zlanhe.c                  |  4 +-
 compute/zlansy.c                  |  4 +-
 compute/zlantr.c                  |  4 +-
 example/lapack_to_morse/step0.c   | 16 ++++----
 example/lapack_to_morse/step1.c   | 12 +++---
 example/lapack_to_morse/step2.c   | 14 +++----
 example/lapack_to_morse/step3.c   | 12 +++---
 example/lapack_to_morse/step4.c   | 14 +++----
 example/lapack_to_morse/step5.c   | 20 +++++-----
 example/lapack_to_morse/step6.c   | 23 ++++++-----
 example/lapack_to_morse/step7.c   | 23 ++++++-----
 example/out_of_core/out_of_core.c | 11 +++---
 20 files changed, 105 insertions(+), 135 deletions(-)

diff --git a/compute/pzgebrd_ge2gb.c b/compute/pzgebrd_ge2gb.c
index ea49d57ea..0d27a9c08 100644
--- a/compute/pzgebrd_ge2gb.c
+++ b/compute/pzgebrd_ge2gb.c
@@ -29,7 +29,6 @@ void morse_pzgebrd_ge2gb(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D,
 
     if (A->m >= A->n){
         for (k = 0; k < A->nt; k++) {
-            tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
             tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
 
             A1 = morse_desc_submatrix(A, k*A->mb,     k*A->nb, A->m-k*A->mb, tempkn);
@@ -47,7 +46,7 @@ void morse_pzgebrd_ge2gb(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D,
                            sequence, request);
 
             if (k+1 < A->nt){
-                tempkn = k+1 == A->nt-1 ? A->n-(k+1)*A->nb : A->nb;
+                tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
 
                 A1 = morse_desc_submatrix(A,     k*A->mb, (k+1)*A->nb, tempkm,           A->n-(k+1)*A->nb);
                 A2 = morse_desc_submatrix(A, (k+1)*A->mb, (k+1)*A->nb, A->m-(k+1)*A->mb, A->n-(k+1)*A->nb);
@@ -68,7 +67,6 @@ void morse_pzgebrd_ge2gb(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D,
     else{
         for (k = 0; k < A->mt; k++) {
             tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
-            tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
 
             A1 = morse_desc_submatrix(A,     k*A->mb, k*A->nb, tempkm,           A->n-k*A->nb);
             A2 = morse_desc_submatrix(A, (k+1)*A->mb, k*A->nb, A->m-(k+1)*A->mb, A->n-k*A->nb);
@@ -84,7 +82,7 @@ void morse_pzgebrd_ge2gb(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D,
                            sequence, request);
 
             if (k+1 < A->mt){
-                tempkm = k+1 == A->mt-1 ? A->m-(k+1)*A->mb : A->mb;
+                tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
 
                 A1 = morse_desc_submatrix(A, (k+1)*A->mb,     k*A->nb, A->m-(k+1)*A->mb, tempkn);
                 A2 = morse_desc_submatrix(A, (k+1)*A->mb, (k+1)*A->nb, A->m-(k+1)*A->mb, A->n-(k+1)*A->nb);
diff --git a/compute/pzgelqf_param.c b/compute/pzgelqf_param.c
index c6c5ceeaa..5acbf7c20 100644
--- a/compute/pzgelqf_param.c
+++ b/compute/pzgelqf_param.c
@@ -147,7 +147,6 @@ void morse_pzgelqf_param( const libhqr_tree_t *qrtree, MORSE_desc_t *A,
             p = qrtree->currpiv(qrtree, k, n);
 
             tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
-            temppn = p == A->nt-1 ? A->n-p*A->nb : A->nb;
 
             if (qrtree->gettype(qrtree, k, n) == 0) {
                 /* TS kernel */
diff --git a/compute/pztradd.c b/compute/pztradd.c
index 524136171..3db356b6e 100644
--- a/compute/pztradd.c
+++ b/compute/pztradd.c
@@ -172,7 +172,6 @@ void morse_pztradd(MORSE_enum uplo, MORSE_enum trans,
         else {
             for (m = 0; m < B->mt; m++) {
                 tempmm = m == B->mt-1 ? B->m-B->mb*m : B->nb;
-                ldam = BLKLDD(A, m);
                 ldbm = BLKLDD(B, m);
 
                 for (n = 0; n < B->nt; n++) {
diff --git a/compute/pztrsm.c b/compute/pztrsm.c
index a621ad29e..366d08bbc 100644
--- a/compute/pztrsm.c
+++ b/compute/pztrsm.c
@@ -193,7 +193,6 @@ void morse_pztrsm(MORSE_enum side, MORSE_enum uplo, MORSE_enum trans, MORSE_enum
                     }
                     RUNTIME_data_flush( sequence, A(B->mt-1-k, B->mt-1-k) );
                     for (m = k+1; m < B->mt; m++) {
-                        tempmm = m == B->mt-1 ? B->m-m*B->mb : B->mb;
                         ldbm = BLKLDD(B, B->mt-1-m);
                         for (n = 0; n < B->nt; n++) {
                             tempnn = n == B->nt-1 ? B->n-n*B->nb : B->nb;
diff --git a/compute/pzunmqr.c b/compute/pzunmqr.c
index c1897dcc1..d893bc3c1 100644
--- a/compute/pzunmqr.c
+++ b/compute/pzunmqr.c
@@ -245,7 +245,6 @@ void morse_pzunmqr(MORSE_enum side, MORSE_enum trans,
                 tempkn   = k == B->nt - 1 ? B->n - k * B->nb : B->nb;
                 tempkmin = k == minMT - 1 ? minM - k * A->nb : A->nb;
                 ldak = BLKLDD(A, k);
-                ldbk = BLKLDD(B, k);
                 for (n = B->nt-1; n > k; n--) {
                     tempnn = n == B->nt-1 ? B->n-n*B->nb : B->nb;
                     ldan = BLKLDD(A, n);
diff --git a/compute/pzunmqrrh.c b/compute/pzunmqrrh.c
index c4d6e3e34..af3fe2856 100644
--- a/compute/pzunmqrrh.c
+++ b/compute/pzunmqrrh.c
@@ -330,7 +330,6 @@ void morse_pzunmqrrh( MORSE_enum side, MORSE_enum trans,
                     tempMm   = M == A->mt-1 ? A->m-M*A->mb : A->mb;
                     tempkmin = chameleon_min(tempMm, tempkn);
                     ldaM = BLKLDD(A, M);
-                    ldbM = BLKLDD(B, M);
                     for (n = chameleon_min(M+BS, A->mt)-1; n > M; n--) {
                         ldan = BLKLDD(A, n);
                         tempnn = n == B->nt-1 ? B->n-n*B->nb : B->nb;
diff --git a/compute/zgesvd.c b/compute/zgesvd.c
index 235bda79b..be8895227 100644
--- a/compute/zgesvd.c
+++ b/compute/zgesvd.c
@@ -400,8 +400,8 @@ int MORSE_zgesvd_Tile_Async( MORSE_enum jobu, MORSE_enum jobvt,
 {
     MORSE_desc_t descA;
     MORSE_desc_t descT;
-    MORSE_desc_t descU;
-    MORSE_desc_t descVT;
+    MORSE_desc_t descUl, descUt;
+    MORSE_desc_t descVTl, descVTt;
     MORSE_desc_t descAB;
     MORSE_desc_t D, *Dptr = NULL;
     MORSE_desc_t *subA, *subT, *subUVT;
@@ -555,65 +555,61 @@ int MORSE_zgesvd_Tile_Async( MORSE_enum jobu, MORSE_enum jobvt,
 
     morse_desc_mat_free( &descAB );
 
-    /* Transform U and Vt into tile format */
-    if ( jobu != MorseNoVec ) {
-        //morse_zooplap2tile( descU, U, NB, NB, LDU, M, 0, 0, M, M, sequence, request, morse_desc_mat_free(&(descU)) );
-    }
-    if ( jobvt != MorseNoVec ) {
-        //morse_zooplap2tile( descVT, VT, NB, NB, LDVT, N, 0, 0, N, N, sequence, request, morse_desc_mat_free(&(descVT)) );
-    }
-
-    morse_sequence_wait( morse, sequence );
-
     subA = NULL;
     subT = NULL;
     subUVT = NULL;
+
     if ( jobu != MorseNoVec ) {
+        morse_zlap2tile( morse, &descUl, &descUt, MorseDescInout, MorseUpperLower,
+                         U, NB, NB, LDU, M, M, M, sequence, request );
+
         if ( M < N ){
-            subA   = morse_desc_submatrix(&descA, descA.mb, 0, descA.m-descA.mb, descA.n-descA.nb);
-            subUVT = morse_desc_submatrix(&descU, descU.mb, 0, descU.m-descU.mb, descU.n);
-            subT   = morse_desc_submatrix(&descT, descT.mb, 0, descT.m-descT.mb, descT.n-descT.nb);
+            subA   = morse_desc_submatrix(&descA,  descA.mb,  0, descA.m -descA.mb,  descA.n-descA.nb);
+            subUVT = morse_desc_submatrix(&descUt, descUt.mb, 0, descUt.m-descUt.mb, descUt.n);
+            subT   = morse_desc_submatrix(&descT,  descT.mb,  0, descT.m -descT.mb,  descT.n-descT.nb);
+
             morse_pzunmqr( MorseLeft, MorseNoTrans,
                            subA, subUVT, subT, Dptr,
                            sequence, request );
+
+            free(subA); free(subUVT); free(subT);
         }
         else {
             morse_pzunmqr( MorseLeft, MorseNoTrans,
-                           &descA, &descU, &descT, Dptr,
+                           &descA, &descUt, &descT, Dptr,
                            sequence, request );
         }
+
+        morse_ztile2lap( morse, &descUl, &descUt,
+                         MorseDescInout, MorseUpperLower, sequence, request );
     }
 
     if ( jobvt != MorseNoVec ) {
+        morse_zlap2tile( morse, &descVTl, &descVTt, MorseDescInout, MorseUpperLower,
+                         VT, NB, NB, LDVT, N, N, N, sequence, request );
+
         if ( M < N ){
             morse_pzunmlq( MorseRight, MorseNoTrans,
-                           &descA, &descVT, &descT, Dptr,
+                           &descA, &descVTt, &descT, Dptr,
                            sequence, request );
         }
         else {
-            subA   = morse_desc_submatrix(&descA,  0, descA.nb,  descA.m-descA.mb, descA.n -descA.nb);
-            subUVT = morse_desc_submatrix(&descVT, 0, descVT.nb, descVT.m,         descVT.n-descVT.nb);
-            subT   = morse_desc_submatrix(&descT,  0, descT.nb,  descT.m-descT.mb, descT.n -descT.nb);
+            subA   = morse_desc_submatrix(&descA,   0, descA.nb,   descA.m-descA.mb, descA.n  -descA.nb  );
+            subUVT = morse_desc_submatrix(&descVTt, 0, descVTt.nb, descVTt.m,        descVTt.n-descVTt.nb);
+            subT   = morse_desc_submatrix(&descT,   0, descT.nb,   descT.m-descT.mb, descT.n  -descT.nb  );
+
             morse_pzunmlq( MorseRight, MorseNoTrans,
                            subA, subUVT, subT, Dptr,
                            sequence, request );
+
+            free(subA); free(subUVT); free(subT);
         }
-    }
 
-    /* Transform U and VT into lapack layout */
-    if ( jobu != MorseNoVec ) {
-        //morse_zooptile2lap( descU,  U,  NB, NB, LDU,  M, sequence, request );
-    }
-    if ( jobvt != MorseNoVec ) {
-        //morse_zooptile2lap( descVT, VT, NB, NB, LDVT, N, sequence, request );
+        morse_ztile2lap( morse, &descVTl, &descVTt,
+                         MorseDescInout, MorseUpperLower, sequence, request );
     }
-
     morse_sequence_wait( morse, sequence );
 
-    if (subA) {
-        free(subA); free(subUVT); free(subT);
-    }
-
     /* Solve the bidiagonal SVD problem */
     /* On exit, U and VT are updated with bidiagonal matrix singular vectors */
 #if !defined(CHAMELEON_SIMULATION)
@@ -626,12 +622,6 @@ int MORSE_zgesvd_Tile_Async( MORSE_enum jobu, MORSE_enum jobvt,
     }
 #endif /* !defined(CHAMELEON_SIMULATION) */
 
-    if (jobu != MorseNoVec) {
-        morse_desc_mat_free( &descU );
-    }
-    if (jobvt != MorseNoVec) {
-        morse_desc_mat_free( &descVT );
-    }
     free(E);
     if ( Dptr ) {
         morse_desc_mat_free( Dptr );
diff --git a/compute/zlange.c b/compute/zlange.c
index e0d465847..a7b6ffaf3 100644
--- a/compute/zlange.c
+++ b/compute/zlange.c
@@ -83,7 +83,7 @@ double MORSE_zlange(MORSE_enum norm, int M, int N,
 {
     int NB;
     int status;
-    double value;
+    double value = -1.;
     MORSE_context_t *morse;
     MORSE_sequence_t *sequence = NULL;
     MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
@@ -125,7 +125,7 @@ double MORSE_zlange(MORSE_enum norm, int M, int N,
     }
 
     /* Set NT */
-    NB   = MORSE_NB;
+    NB = MORSE_NB;
 
     morse_sequence_create( morse, &sequence );
 
@@ -194,7 +194,7 @@ double MORSE_zlange_Tile(MORSE_enum norm, MORSE_desc_t *A )
     MORSE_sequence_t *sequence = NULL;
     MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
     int status;
-    double value;
+    double value = -1.;
 
     morse = morse_context_self();
     if (morse == NULL) {
diff --git a/compute/zlanhe.c b/compute/zlanhe.c
index 20d6d2873..fb2e7f300 100644
--- a/compute/zlanhe.c
+++ b/compute/zlanhe.c
@@ -83,7 +83,7 @@ double MORSE_zlanhe(MORSE_enum norm, MORSE_enum uplo, int N,
 {
     int NB;
     int status;
-    double value;
+    double value = -1.;
     MORSE_context_t *morse;
     MORSE_sequence_t *sequence = NULL;
     MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
@@ -198,7 +198,7 @@ double MORSE_zlanhe_Tile( MORSE_enum norm, MORSE_enum uplo, MORSE_desc_t *A )
     MORSE_sequence_t *sequence = NULL;
     MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
     int status;
-    double value;
+    double value = -1.;
 
     morse = morse_context_self();
     if (morse == NULL) {
diff --git a/compute/zlansy.c b/compute/zlansy.c
index 10a2d3557..673532d77 100644
--- a/compute/zlansy.c
+++ b/compute/zlansy.c
@@ -83,7 +83,7 @@ double MORSE_zlansy(MORSE_enum norm, MORSE_enum uplo, int N,
 {
     int NB;
     int status;
-    double value;
+    double value = -1.;
     MORSE_context_t *morse;
     MORSE_sequence_t *sequence = NULL;
     MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
@@ -198,7 +198,7 @@ double MORSE_zlansy_Tile( MORSE_enum norm, MORSE_enum uplo, MORSE_desc_t *A )
     MORSE_sequence_t *sequence = NULL;
     MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
     int status;
-    double value;
+    double value = -1.;
 
     morse = morse_context_self();
     if (morse == NULL) {
diff --git a/compute/zlantr.c b/compute/zlantr.c
index 42127a8b3..224faca65 100644
--- a/compute/zlantr.c
+++ b/compute/zlantr.c
@@ -95,7 +95,7 @@ double MORSE_zlantr(MORSE_enum norm, MORSE_enum uplo, MORSE_enum diag,
 {
     int NB;
     int status;
-    double value;
+    double value = -1.;
     MORSE_context_t *morse;
     MORSE_sequence_t *sequence = NULL;
     MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
@@ -220,7 +220,7 @@ double MORSE_zlantr_Tile(MORSE_enum norm, MORSE_enum uplo, MORSE_enum diag, MORS
     MORSE_sequence_t *sequence = NULL;
     MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
     int status;
-    double value;
+    double value = -1.;
 
     morse = morse_context_self();
     if (morse == NULL) {
diff --git a/example/lapack_to_morse/step0.c b/example/lapack_to_morse/step0.c
index 6879a1ef1..0ae46a070 100644
--- a/example/lapack_to_morse/step0.c
+++ b/example/lapack_to_morse/step0.c
@@ -36,7 +36,8 @@ int main(int argc, char *argv[]) {
     size_t NRHS; // number of RHS vectors
 
     /* declarations to time the program and evaluate performances */
-    double fmuls, fadds, flops, gflops, cpu_time;
+    double fmuls, fadds, flops, gflops, cpu_time, eps, res;
+    int hres;
 
     /* initialize some parameters with default values */
     int iparam[IPARAM_SIZEOF];
@@ -52,8 +53,6 @@ int main(int argc, char *argv[]) {
     fadds = (double)( FADDS_POTRF(N) + 2 * FADDS_TRSM(N,NRHS) );
     fmuls = (double)( FMULS_POTRF(N) + 2 * FMULS_TRSM(N,NRHS) );
     flops = 1e-9 * (fmuls + fadds);
-    gflops = 0.0;
-    cpu_time = 0.0;
 
     /* initialize the number of thread if not given by the user in argv
      * It makes sense only if this program is linked with pthread and
@@ -137,26 +136,27 @@ int main(int argc, char *argv[]) {
     /* compute A*X-B, store the result in B */
     cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans,
                 N, NRHS, N, 1.0, Acpy, N, X, N, -1.0, B, N);
-    double res = LAPACKE_dlange( LAPACK_COL_MAJOR, 'I', N, NRHS, B, N);
+    res = LAPACKE_dlange( LAPACK_COL_MAJOR, 'I', N, NRHS, B, N);
 
     /* check residual and print a message */
-    double    eps = LAPACKE_dlamch_work( 'e' );
+    eps = LAPACKE_dlamch_work( 'e' );
 
     /*
      * if hres = 0 then the test succeed
      * else the test failed
      */
-    int hres = 0;
     hres = ( res / N / eps / (anorm * xnorm + bnorm ) > 100.0 );
     printf( "   ||Ax-b||       ||A||       ||x||       ||b|| ||Ax-b||/N/eps/(||A||||x||+||b||)  RETURN\n");
-    if (hres)
+    if (hres) {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e FAILURE \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
-    else
+    }
+    else {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e SUCCESS \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
+    }
 
     /* deallocate data */
     free(A);
diff --git a/example/lapack_to_morse/step1.c b/example/lapack_to_morse/step1.c
index 6099a6f9a..025f6a534 100644
--- a/example/lapack_to_morse/step1.c
+++ b/example/lapack_to_morse/step1.c
@@ -38,7 +38,6 @@
  * The precision is: double
  */
 int main(int argc, char *argv[]) {
-
     size_t N;    // matrix order
     size_t NRHS; // number of RHS vectors
     int NCPU; // number of cores to use
@@ -66,8 +65,6 @@ int main(int argc, char *argv[]) {
     fadds = (double)( FADDS_POTRF(N) + 2 * FADDS_TRSM(N,NRHS) );
     fmuls = (double)( FMULS_POTRF(N) + 2 * FMULS_TRSM(N,NRHS) );
     flops = 1e-9 * (fmuls + fadds);
-    gflops = 0.0;
-    cpu_time = 0.0;
 
     /* initialize the number of thread if not given by the user in argv
      * It makes sense only if this program is linked with pthread and
@@ -88,7 +85,7 @@ int main(int argc, char *argv[]) {
     }
 
     /*
-     * allocate memory for our data using a C macro (see step1.h)
+     * Allocate memory for our data using a C macro (see step1.h)
      *     - matrix A                   : size N x N
      *     - set of RHS vectors B       : size N x NRHS
      *     - set of solutions vectors X : size N x NRHS
@@ -154,17 +151,18 @@ int main(int argc, char *argv[]) {
      * if hres = 0 then the test succeed
      * else the test failed
      */
-    hres = 0;
     hres = ( res / N / eps / (anorm * xnorm + bnorm ) > 100.0 );
     printf( "   ||Ax-b||       ||A||       ||x||       ||b|| ||Ax-b||/N/eps/(||A||||x||+||b||)  RETURN\n");
-    if (hres)
+    if (hres) {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e FAILURE \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
-    else
+    }
+    else {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e SUCCESS \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
+    }
 
     /* deallocate data */
     free(A);
diff --git a/example/lapack_to_morse/step2.c b/example/lapack_to_morse/step2.c
index fbb139499..e0195479c 100644
--- a/example/lapack_to_morse/step2.c
+++ b/example/lapack_to_morse/step2.c
@@ -29,8 +29,7 @@
  * The goal is also to show examples of calling MORSE tile interface.
  */
 int main(int argc, char *argv[]) {
-
-    size_t N;    // matrix order
+    size_t N; // matrix order
     int NB;   // number of rows and columns in tiles
     int NRHS; // number of RHS vectors
     int NCPU; // number of cores to use
@@ -61,8 +60,6 @@ int main(int argc, char *argv[]) {
     fadds = (double)( FADDS_POTRF(N) + 2 * FADDS_TRSM(N,NRHS) );
     fmuls = (double)( FMULS_POTRF(N) + 2 * FMULS_TRSM(N,NRHS) );
     flops = 1e-9 * (fmuls + fadds);
-    gflops = 0.0;
-    cpu_time = 0.0;
 
     /* initialize the number of thread if not given by the user in argv
      * It makes sense only if this program is linked with pthread and
@@ -76,7 +73,7 @@ int main(int argc, char *argv[]) {
     /* print informations to user */
     print_header( argv[0], iparam);
 
-     /* Initialize MORSE with main parameters */
+    /* Initialize MORSE with main parameters */
     if ( MORSE_Init( NCPU, NGPU ) != MORSE_SUCCESS ) {
         fprintf(stderr, "Error initializing MORSE library\n");
         return EXIT_FAILURE;
@@ -198,17 +195,18 @@ int main(int argc, char *argv[]) {
      * if hres = 0 then the test succeed
      * else the test failed
      */
-    hres = 0;
     hres = ( res / N / eps / (anorm * xnorm + bnorm ) > 100.0 );
     printf( "   ||Ax-b||       ||A||       ||x||       ||b|| ||Ax-b||/N/eps/(||A||||x||+||b||)  RETURN\n");
-    if (hres)
+    if (hres) {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e FAILURE \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
-    else
+    }
+    else {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e SUCCESS \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
+    }
 
     /* get back results in LAPACK format */
     MORSE_dTile_to_Lapack(descA,  A,    N);
diff --git a/example/lapack_to_morse/step3.c b/example/lapack_to_morse/step3.c
index fdad78747..eb312137b 100644
--- a/example/lapack_to_morse/step3.c
+++ b/example/lapack_to_morse/step3.c
@@ -27,7 +27,6 @@
  * During this step we do not use classical LAPACK matrices (1D array) anymore.
  */
 int main(int argc, char *argv[]) {
-
     size_t N; // matrix order
     int NB;   // number of rows and columns in tiles
     int NRHS; // number of RHS vectors
@@ -62,8 +61,6 @@ int main(int argc, char *argv[]) {
     fadds = (double)( FADDS_POTRF(N) + 2 * FADDS_TRSM(N,NRHS) );
     fmuls = (double)( FMULS_POTRF(N) + 2 * FMULS_TRSM(N,NRHS) );
     flops = 1e-9 * (fmuls + fadds);
-    gflops = 0.0;
-    cpu_time = 0.0;
 
     /* initialize the number of thread if not given by the user in argv
      * It makes sense only if this program is linked with pthread and
@@ -77,7 +74,7 @@ int main(int argc, char *argv[]) {
     /* print informations to user */
     print_header( argv[0], iparam);
 
-     /* Initialize MORSE with main parameters */
+    /* Initialize MORSE with main parameters */
     if ( MORSE_Init( NCPU, NGPU ) != MORSE_SUCCESS ) {
         fprintf(stderr, "Error initializing MORSE library\n");
         return EXIT_FAILURE;
@@ -181,17 +178,18 @@ int main(int argc, char *argv[]) {
      * if hres = 0 then the test succeed
      * else the test failed
      */
-    hres = 0;
     hres = ( res / N / eps / (anorm * xnorm + bnorm ) > 100.0 );
     printf( "   ||Ax-b||       ||A||       ||x||       ||b|| ||Ax-b||/N/eps/(||A||||x||+||b||)  RETURN\n");
-    if (hres)
+    if (hres) {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e FAILURE \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
-    else
+    }
+    else {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e SUCCESS \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
+    }
 
     /* free the matrix of tiles */
     deallocate_tile_matrix(matA, N, N, NB);
diff --git a/example/lapack_to_morse/step4.c b/example/lapack_to_morse/step4.c
index 6eafc33b1..32abb06f1 100644
--- a/example/lapack_to_morse/step4.c
+++ b/example/lapack_to_morse/step4.c
@@ -31,8 +31,7 @@
  * subsequent algorithms so that less synchronisations are done.
  */
 int main(int argc, char *argv[]) {
-
-    size_t N;    // matrix order
+    size_t N; // matrix order
     int NB;   // number of rows and columns in tiles
     int NRHS; // number of RHS vectors
     int NCPU; // number of cores to use
@@ -70,8 +69,6 @@ int main(int argc, char *argv[]) {
     fadds = (double)( FADDS_POTRF(N) + 2 * FADDS_TRSM(N,NRHS) );
     fmuls = (double)( FMULS_POTRF(N) + 2 * FMULS_TRSM(N,NRHS) );
     flops = 1e-9 * (fmuls + fadds);
-    gflops = 0.0;
-    cpu_time = 0.0;
 
     /* initialize the number of thread if not given by the user in argv
      * It makes sense only if this program is linked with pthread and
@@ -85,7 +82,7 @@ int main(int argc, char *argv[]) {
     /* print informations to user */
     print_header( argv[0], iparam);
 
-     /* Initialize MORSE with main parameters */
+    /* Initialize MORSE with main parameters */
     if ( MORSE_Init( NCPU, NGPU ) != MORSE_SUCCESS ) {
         fprintf(stderr, "Error initializing MORSE library\n");
         return EXIT_FAILURE;
@@ -179,17 +176,18 @@ int main(int argc, char *argv[]) {
      * if hres = 0 then the test succeed
      * else the test failed
      */
-    hres = 0;
     hres = ( res / N / eps / (anorm * xnorm + bnorm ) > 100.0 );
     printf( "   ||Ax-b||       ||A||       ||x||       ||b|| ||Ax-b||/N/eps/(||A||||x||+||b||)  RETURN\n");
-    if (hres)
+    if (hres) {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e FAILURE \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
-    else
+    }
+    else {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e SUCCESS \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
+    }
 
     /* deallocate A, B, X, Acpy and associated descriptors descA, ... */
     MORSE_Desc_Destroy( &descA );
diff --git a/example/lapack_to_morse/step5.c b/example/lapack_to_morse/step5.c
index 0b7c03a9b..a3ef2994d 100644
--- a/example/lapack_to_morse/step5.c
+++ b/example/lapack_to_morse/step5.c
@@ -31,8 +31,7 @@
  *  - number of right-hand sides
  */
 int main(int argc, char *argv[]) {
-
-    size_t N;    // matrix order
+    size_t N; // matrix order
     int NB;   // number of rows and columns in tiles
     int NRHS; // number of RHS vectors
     int NCPU; // number of cores to use
@@ -71,8 +70,6 @@ int main(int argc, char *argv[]) {
     fadds = (double)( FADDS_POTRF(N) + 2 * FADDS_TRSM(N,NRHS) );
     fmuls = (double)( FMULS_POTRF(N) + 2 * FMULS_TRSM(N,NRHS) );
     flops = 1e-9 * (fmuls + fadds);
-    gflops = 0.0;
-    cpu_time = 0.0;
 
     /* initialize the number of thread if not given by the user in argv
      * It makes sense only if this program is linked with pthread and
@@ -183,17 +180,18 @@ int main(int argc, char *argv[]) {
      * if hres = 0 then the test succeed
      * else the test failed
      */
-    hres = 0;
     hres = ( res / N / eps / (anorm * xnorm + bnorm ) > 100.0 );
     printf( "   ||Ax-b||       ||A||       ||x||       ||b|| ||Ax-b||/N/eps/(||A||||x||+||b||)  RETURN\n");
-    if (hres)
+    if (hres) {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e FAILURE \n",
-            res, anorm, xnorm, bnorm,
-            res / N / eps / (anorm * xnorm + bnorm ));
-    else
+                res, anorm, xnorm, bnorm,
+                res / N / eps / (anorm * xnorm + bnorm ));
+    }
+    else {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e SUCCESS \n",
-            res, anorm, xnorm, bnorm,
-            res / N / eps / (anorm * xnorm + bnorm ));
+                res, anorm, xnorm, bnorm,
+                res / N / eps / (anorm * xnorm + bnorm ));
+    }
 
     /* deallocate A, B, X, Acpy and associated descriptors descA, ... */
     MORSE_Desc_Destroy( &descA );
diff --git a/example/lapack_to_morse/step6.c b/example/lapack_to_morse/step6.c
index 49e02c1b0..339794233 100644
--- a/example/lapack_to_morse/step6.c
+++ b/example/lapack_to_morse/step6.c
@@ -29,8 +29,7 @@
  * --p= and --q=
  */
 int main(int argc, char *argv[]) {
-
-    size_t N;    // matrix order
+    size_t N; // matrix order
     int NB;   // number of rows and columns in tiles
     int NRHS; // number of RHS vectors
     int NCPU; // number of cores to use
@@ -72,8 +71,6 @@ int main(int argc, char *argv[]) {
     fadds = (double)( FADDS_POTRF(N) + 2 * FADDS_TRSM(N,NRHS) );
     fmuls = (double)( FMULS_POTRF(N) + 2 * FMULS_TRSM(N,NRHS) );
     flops = 1e-9 * (fmuls + fadds);
-    gflops = 0.0;
-    cpu_time = 0.0;
 
     /* initialize the number of thread if not given by the user in argv
      * It makes sense only if this program is linked with pthread and
@@ -181,8 +178,9 @@ int main(int argc, char *argv[]) {
 
     /* print informations to user */
     gflops = flops / cpu_time;
-    if ( MORSE_My_Mpi_Rank() == 0 )
+    if ( MORSE_My_Mpi_Rank() == 0 ) {
         printf( "%9.3f %9.2f\n", cpu_time, gflops);
+    }
     fflush( stdout );
 
     /************************************************************/
@@ -206,18 +204,19 @@ int main(int argc, char *argv[]) {
      * if hres = 0 then the test succeed
      * else the test failed
      */
-    hres = 0;
     hres = ( res / N / eps / (anorm * xnorm + bnorm ) > 100.0 );
     if ( MORSE_My_Mpi_Rank() == 0 ){
         printf( "   ||Ax-b||       ||A||       ||x||       ||b|| ||Ax-b||/N/eps/(||A||||x||+||b||)  RETURN\n");
-        if (hres)
+        if (hres) {
             printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e FAILURE \n",
-                res, anorm, xnorm, bnorm,
-                res / N / eps / (anorm * xnorm + bnorm ));
-        else
+                    res, anorm, xnorm, bnorm,
+                    res / N / eps / (anorm * xnorm + bnorm ));
+        }
+        else {
             printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e SUCCESS \n",
-                res, anorm, xnorm, bnorm,
-                res / N / eps / (anorm * xnorm + bnorm ));
+                    res, anorm, xnorm, bnorm,
+                    res / N / eps / (anorm * xnorm + bnorm ));
+        }
     }
 
     /* deallocate A, B, X, Acpy and associated descriptors descA, ... */
diff --git a/example/lapack_to_morse/step7.c b/example/lapack_to_morse/step7.c
index 4aa0b0001..2c5f40872 100644
--- a/example/lapack_to_morse/step7.c
+++ b/example/lapack_to_morse/step7.c
@@ -33,8 +33,7 @@
  * and therefore this approach is much more flexible.
  */
 int main(int argc, char *argv[]) {
-
-    size_t N;    // matrix order
+    size_t N; // matrix order
     int NB;   // number of rows and columns in tiles
     int NRHS; // number of RHS vectors
     int NCPU; // number of cores to use
@@ -76,8 +75,6 @@ int main(int argc, char *argv[]) {
     fadds = (double)( FADDS_POTRF(N) + 2 * FADDS_TRSM(N,NRHS) );
     fmuls = (double)( FMULS_POTRF(N) + 2 * FMULS_TRSM(N,NRHS) );
     flops = 1e-9 * (fmuls + fadds);
-    gflops = 0.0;
-    cpu_time = 0.0;
 
     /* initialize the number of thread if not given by the user in argv
      * It makes sense only if this program is linked with pthread and
@@ -189,8 +186,9 @@ int main(int argc, char *argv[]) {
 
     /* print informations to user */
     gflops = flops / cpu_time;
-    if ( MORSE_My_Mpi_Rank() == 0 )
+    if ( MORSE_My_Mpi_Rank() == 0 ) {
         printf( "%9.3f %9.2f\n", cpu_time, gflops);
+    }
     fflush( stdout );
 
     /************************************************************/
@@ -214,18 +212,19 @@ int main(int argc, char *argv[]) {
      * if hres = 0 then the test succeed
      * else the test failed
      */
-    hres = 0;
     hres = ( res / N / eps / (anorm * xnorm + bnorm ) > 100.0 );
     if ( MORSE_My_Mpi_Rank() == 0 ){
         printf( "   ||Ax-b||       ||A||       ||x||       ||b|| ||Ax-b||/N/eps/(||A||||x||+||b||)  RETURN\n");
-        if (hres)
+        if (hres) {
             printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e FAILURE \n",
-                res, anorm, xnorm, bnorm,
-                res / N / eps / (anorm * xnorm + bnorm ));
-        else
+                    res, anorm, xnorm, bnorm,
+                    res / N / eps / (anorm * xnorm + bnorm ));
+        }
+        else {
             printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e SUCCESS \n",
-                res, anorm, xnorm, bnorm,
-                res / N / eps / (anorm * xnorm + bnorm ));
+                    res, anorm, xnorm, bnorm,
+                    res / N / eps / (anorm * xnorm + bnorm ));
+        }
     }
 
     /* deallocate A, B, X, Acpy and associated descriptors descA, ... */
diff --git a/example/out_of_core/out_of_core.c b/example/out_of_core/out_of_core.c
index 0db7f3af7..90af9ca34 100644
--- a/example/out_of_core/out_of_core.c
+++ b/example/out_of_core/out_of_core.c
@@ -56,8 +56,6 @@ int main(int argc, char *argv[]) {
     fadds = (double)( FADDS_POTRF(N) + 2 * FADDS_TRSM(N,NRHS) );
     fmuls = (double)( FMULS_POTRF(N) + 2 * FMULS_TRSM(N,NRHS) );
     flops = 1e-9 * (fmuls + fadds);
-    gflops = 0.0;
-    cpu_time = 0.0;
 
     /* initialize the number of thread if not given by the user in argv */
     if ( iparam[IPARAM_THRDNBR] == -1 ) {
@@ -166,17 +164,18 @@ int main(int argc, char *argv[]) {
      * if hres = 0 then the test succeed
      * else the test failed
      */
-    hres = 0;
-    hres = ( res / N / eps / (anorm * xnorm + bnorm ) > 100.0 );
+    hres = ( (res / N / eps / (anorm * xnorm + bnorm )) > 100.0 );
     printf( "   ||Ax-b||       ||A||       ||x||       ||b|| ||Ax-b||/N/eps/(||A||||x||+||b||)  RETURN\n");
-    if (hres)
+    if (hres) {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e FAILURE \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
-    else
+    }
+    else {
         printf( "%8.5e %8.5e %8.5e %8.5e                       %8.5e SUCCESS \n",
             res, anorm, xnorm, bnorm,
             res / N / eps / (anorm * xnorm + bnorm ));
+    }
 
     /* free descriptors descA, descB, descX, descAC */
     MORSE_Desc_Destroy( &descA );
-- 
GitLab