From e50d3809adad579bd1918d2c290346769763025c Mon Sep 17 00:00:00 2001 From: Mathieu Faverge <mathieu.faverge@inria.fr> Date: Tue, 30 Jan 2018 12:00:50 +0100 Subject: [PATCH] Silent warnign about memory leaks --- testing/testing_zgeadd.c | 5 ++++- testing/testing_zgels.c | 6 +++++- testing/testing_zgels_hqr.c | 6 +++++- testing/testing_zgels_systolic.c | 6 +++++- testing/testing_zgemm.c | 5 ++++- testing/testing_zgeqrf_qdwh.c | 2 ++ testing/testing_zgesv_incpiv.c | 5 ++++- testing/testing_zgesvd.c | 2 ++ testing/testing_zheevd.c | 6 +++++- testing/testing_zhemm.c | 5 ++++- testing/testing_zher2k.c | 4 +++- testing/testing_zherk.c | 4 +++- testing/testing_zpemv.c | 7 +++++-- testing/testing_zposv.c | 13 ++++++++----- testing/testing_zpotri.c | 5 ++++- testing/testing_zsymm.c | 5 ++++- testing/testing_zsyr2k.c | 5 ++++- testing/testing_zsyrk.c | 4 +++- testing/testing_ztrmm.c | 5 ++++- testing/testing_ztrsm.c | 5 ++++- 20 files changed, 82 insertions(+), 23 deletions(-) diff --git a/testing/testing_zgeadd.c b/testing/testing_zgeadd.c index cf65e1843..b4caefa8a 100644 --- a/testing/testing_zgeadd.c +++ b/testing/testing_zgeadd.c @@ -83,7 +83,10 @@ int testing_zgeadd(int argc, char **argv) MORSE_Complex64_t *Bfinal = (MORSE_Complex64_t *)malloc(LDBxN*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ((!A)||(!B)||(!Binit)||(!Bfinal)){ + if ( (!A) || (!B) || (!Binit) || (!Bfinal) ) + { + free(A); free(B); + free(Binit); free(Bfinal); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zgels.c b/testing/testing_zgels.c index 1d2f24832..4b52193e7 100644 --- a/testing/testing_zgels.c +++ b/testing/testing_zgels.c @@ -258,7 +258,11 @@ int testing_zgels(int argc, char **argv) MORSE_desc_t *T; /* Check if unable to allocate memory */ - if ((!A1)||(!A2)||(!B1)||(!B2)||(!Q)){ + if ( (!A1) || (!A2) || (!B1) || (!B2) || (!Q) ) + { + free(A1); free(A2); + free(B1); free(B2); + free(Q); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zgels_hqr.c b/testing/testing_zgels_hqr.c index 4f216e0d6..d3f8fde83 100644 --- a/testing/testing_zgels_hqr.c +++ b/testing/testing_zgels_hqr.c @@ -95,7 +95,11 @@ int testing_zgels_hqr(int argc, char **argv) MORSE_desc_t *TT = NULL; /* Check if unable to allocate memory */ - if ((!A1)||(!A2)||(!B1)||(!B2)||(!Q)){ + if ( (!A1) || (!A2) || (!B1) || (!B2) || (!Q) ) + { + free(A1); free(A2); + free(B1); free(B2); + free(Q); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zgels_systolic.c b/testing/testing_zgels_systolic.c index 85c89caeb..52e7e46d7 100644 --- a/testing/testing_zgels_systolic.c +++ b/testing/testing_zgels_systolic.c @@ -89,7 +89,11 @@ int testing_zgels_systolic(int argc, char **argv) MORSE_desc_t *TT = NULL; /* Check if unable to allocate memory */ - if ((!A1)||(!A2)||(!B1)||(!B2)||(!Q)){ + if ( (!A1) || (!A2) || (!B1) || (!B2) || (!Q) ) + { + free(A1); free(A2); + free(B1); free(B2); + free(Q); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zgemm.c b/testing/testing_zgemm.c index 562134b79..e10da200a 100644 --- a/testing/testing_zgemm.c +++ b/testing/testing_zgemm.c @@ -88,7 +88,10 @@ int testing_zgemm(int argc, char **argv) MORSE_Complex64_t *Cfinal = (MORSE_Complex64_t *)malloc(LDCxN*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ((!A)||(!B)||(!Cinit)||(!Cfinal)){ + if ( (!A) || (!B) || (!Cinit) || (!Cfinal) ) + { + free(A); free(B); + free(Cinit); free(Cfinal); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zgeqrf_qdwh.c b/testing/testing_zgeqrf_qdwh.c index cd03ec433..21bce4fa6 100644 --- a/testing/testing_zgeqrf_qdwh.c +++ b/testing/testing_zgeqrf_qdwh.c @@ -87,6 +87,8 @@ int testing_zgeqrf_qdwh(int argc, char **argv) /* Check if unable to allocate memory */ if ( (!A) || (!A1) || (!A2) || (!Q1) || (!Q2) ){ + free(A); free(A1); free(A2); + free(Q1); free(Q2); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zgesv_incpiv.c b/testing/testing_zgesv_incpiv.c index c89a97e2d..0b063dbc8 100644 --- a/testing/testing_zgesv_incpiv.c +++ b/testing/testing_zgesv_incpiv.c @@ -196,7 +196,10 @@ int testing_zgesv_incpiv(int argc, char **argv) int *IPIV; /* Check if unable to allocate memory */ - if ( (!A1) || (!A2)|| (!B1) || (!B2) ) { + if ( (!A1) || (!A2)|| (!B1) || (!B2) ) + { + free(A1); free(A2); + free(B1); free(B2); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zgesvd.c b/testing/testing_zgesvd.c index e83248e94..0bca121e3 100644 --- a/testing/testing_zgesvd.c +++ b/testing/testing_zgesvd.c @@ -100,6 +100,8 @@ int testing_zgesvd(int argc, char **argv) /* Check if unable to allocate memory */ if ( (!A1) || (!S1) || (!S2) || (!work) ) { + free(A1); free(work); + free(S1); free(S2); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zheevd.c b/testing/testing_zheevd.c index cdc66adf4..2466e5b79 100644 --- a/testing/testing_zheevd.c +++ b/testing/testing_zheevd.c @@ -72,7 +72,11 @@ int testing_zheevd(int argc, char **argv) MORSE_desc_t *T; /* Check if unable to allocate memory */ - if ( (!A2) || (!W1) || (!W2) ){ + if ( (!A2) || (!W1) || (!W2) || !(work) ) + { + free(A2); + free(W1); free(W2); + free(work); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zhemm.c b/testing/testing_zhemm.c index 53910f9e2..891b4314e 100644 --- a/testing/testing_zhemm.c +++ b/testing/testing_zhemm.c @@ -81,7 +81,10 @@ int testing_zhemm(int argc, char **argv) MORSE_Complex64_t *Cfinal = (MORSE_Complex64_t *)malloc(LDCxN*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ((!A)||(!B)||(!Cinit)||(!Cfinal)){ + if ( (!A) || (!B) || (!C) || (!Cinit) || (!Cfinal) ) + { + free(A); free(B); free(C); + free(Cinit); free(Cfinal); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zher2k.c b/testing/testing_zher2k.c index 7276353b1..d15366eb2 100644 --- a/testing/testing_zher2k.c +++ b/testing/testing_zher2k.c @@ -82,7 +82,9 @@ int testing_zher2k(int argc, char **argv) MORSE_Complex64_t *Cfinal = (MORSE_Complex64_t *)malloc(LDCxN*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ( (!A) || (!B) || (!Cinit) || (!Cfinal) ){ + if ( (!A) || (!B) || (!C) || (!Cinit) || (!Cfinal) ){ + free(A); free(B); free(C); + free(Cinit); free(Cfinal); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zherk.c b/testing/testing_zherk.c index a218be22f..21a5824c0 100644 --- a/testing/testing_zherk.c +++ b/testing/testing_zherk.c @@ -77,7 +77,9 @@ int testing_zherk(int argc, char **argv) MORSE_Complex64_t *Cfinal = (MORSE_Complex64_t *)malloc(LDCxN*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ( (!A) || (!Cinit) || (!Cfinal) ){ + if ( (!A) || (!C) || (!Cinit) || (!Cfinal) ){ + free(A); free(C); + free(Cinit); free(Cfinal); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zpemv.c b/testing/testing_zpemv.c index 401eea1ee..ef70a9236 100644 --- a/testing/testing_zpemv.c +++ b/testing/testing_zpemv.c @@ -134,9 +134,12 @@ int testing_zpemv(int argc, char **argv) LAPACKE_zlarnv_work(1, ISEED, 1, &beta0 ); /* Check if unable to allocate memory */ - if ( (!A) || (!X) || (!Y0) || (!work) ) { + if ( (!A) || (!A0) || (!X) || (!Y) || (!Y0) || (!work) ) { + free(A); free(A0); + free(X); free(Y); free(Y0); + free(work); printf("Out of Memory \n "); - exit(0); + return -2; } /* Initialize Data */ diff --git a/testing/testing_zposv.c b/testing/testing_zposv.c index 0b4906c4d..a129e6a59 100644 --- a/testing/testing_zposv.c +++ b/testing/testing_zposv.c @@ -189,13 +189,16 @@ int testing_zposv(int argc, char **argv) int info_solution, info_factorization; int trans1, trans2; - MORSE_Complex64_t *A1 = (MORSE_Complex64_t *)malloc(LDA*N*sizeof(MORSE_Complex64_t)); - MORSE_Complex64_t *A2 = (MORSE_Complex64_t *)malloc(LDA*N*sizeof(MORSE_Complex64_t)); - MORSE_Complex64_t *B1 = (MORSE_Complex64_t *)malloc(LDB*NRHS*sizeof(MORSE_Complex64_t)); - MORSE_Complex64_t *B2 = (MORSE_Complex64_t *)malloc(LDB*NRHS*sizeof(MORSE_Complex64_t)); + MORSE_Complex64_t *A1 = (MORSE_Complex64_t *)malloc(LDA*N*sizeof(MORSE_Complex64_t)); + MORSE_Complex64_t *A2 = (MORSE_Complex64_t *)malloc(LDA*N*sizeof(MORSE_Complex64_t)); + MORSE_Complex64_t *B1 = (MORSE_Complex64_t *)malloc(LDB*NRHS*sizeof(MORSE_Complex64_t)); + MORSE_Complex64_t *B2 = (MORSE_Complex64_t *)malloc(LDB*NRHS*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ((!A1)||(!A2)||(!B1)||(!B2)){ + if ( (!A1) || (!A2)|| (!B1) || (!B2) ) + { + free(A1); free(A2); + free(B1); free(B2); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zpotri.c b/testing/testing_zpotri.c index 2dff3ea05..6b5b1beeb 100644 --- a/testing/testing_zpotri.c +++ b/testing/testing_zpotri.c @@ -199,7 +199,10 @@ int testing_zpotri(int argc, char **argv) MORSE_Complex64_t *WORK = (MORSE_Complex64_t *)malloc(2*LDA*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ((!A1)||(!A2)){ + if ( (!A1) || (!A2) || (!work) ) + { + free(A1); free(A2); + free(work); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zsymm.c b/testing/testing_zsymm.c index 0e037c761..cecc6b838 100644 --- a/testing/testing_zsymm.c +++ b/testing/testing_zsymm.c @@ -81,7 +81,10 @@ int testing_zsymm(int argc, char **argv) MORSE_Complex64_t *Cfinal = (MORSE_Complex64_t *)malloc(LDCxN*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ((!A)||(!B)||(!Cinit)||(!Cfinal)){ + if ( (!A) || (!B) || (!C) || (!Cinit) || (!Cfinal) ) + { + free(A); free(B); free(C); + free(Cinit); free(Cfinal); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zsyr2k.c b/testing/testing_zsyr2k.c index cbd5a75d4..049e9c8fd 100644 --- a/testing/testing_zsyr2k.c +++ b/testing/testing_zsyr2k.c @@ -82,7 +82,10 @@ int testing_zsyr2k(int argc, char **argv) MORSE_Complex64_t *Cfinal = (MORSE_Complex64_t *)malloc(LDCxN*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ( (!A) || (!B) || (!Cinit) || (!Cfinal) ){ + if ( (!A) || (!B) || (!C) || (!Cinit) || (!Cfinal) ) + { + free(A); free(B); free(C); + free(Cinit); free(Cfinal); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_zsyrk.c b/testing/testing_zsyrk.c index ba58ac727..b942d294d 100644 --- a/testing/testing_zsyrk.c +++ b/testing/testing_zsyrk.c @@ -77,7 +77,9 @@ int testing_zsyrk(int argc, char **argv) MORSE_Complex64_t *Cfinal = (MORSE_Complex64_t *)malloc(LDCxN*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ( (!A) || (!Cinit) || (!Cfinal) ){ + if ( (!A) || (!C) || (!Cinit) || (!Cfinal) ){ + free(A); free(C); + free(Cinit); free(Cfinal); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_ztrmm.c b/testing/testing_ztrmm.c index 83214ef26..f663a8827 100644 --- a/testing/testing_ztrmm.c +++ b/testing/testing_ztrmm.c @@ -77,7 +77,10 @@ int testing_ztrmm(int argc, char **argv) MORSE_Complex64_t *Bfinal = (MORSE_Complex64_t *)malloc(LDBxN*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ( (!A) || (!B) || (!Binit) || (!Bfinal)){ + if ( (!A) || (!B) || (!Binit) || (!Bfinal) ) + { + free(A); free(B); + free(Binit); free(Bfinal); printf("Out of Memory \n "); return -2; } diff --git a/testing/testing_ztrsm.c b/testing/testing_ztrsm.c index 3514b78d9..65e5088d6 100644 --- a/testing/testing_ztrsm.c +++ b/testing/testing_ztrsm.c @@ -77,7 +77,10 @@ int testing_ztrsm(int argc, char **argv) MORSE_Complex64_t *Bfinal = (MORSE_Complex64_t *)malloc(LDBxN*sizeof(MORSE_Complex64_t)); /* Check if unable to allocate memory */ - if ( (!A) || (!B) || (!Binit) || (!Bfinal)){ + if ( (!A) || (!B) || (!Binit) || (!Bfinal) ) + { + free(A); free(B); + free(Binit); free(Bfinal); printf("Out of Memory \n "); return -2; } -- GitLab