Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4fc17a3f authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Fix bug reported by sonarcube

parent b89aec1c
Branches
Tags
No related merge requests found
...@@ -592,12 +592,14 @@ int readHB_aux_double(const char* filename, const char AuxType, double b[]) ...@@ -592,12 +592,14 @@ int readHB_aux_double(const char* filename, const char AuxType, double b[])
if (Nrhs <= 0) if (Nrhs <= 0)
{ {
fprintf(stderr, "Warn: Attempt to read auxillary vector(s) when none are present.\n"); fprintf(stderr, "Warn: Attempt to read auxillary vector(s) when none are present.\n");
fclose(in_file);
return 0; return 0;
} }
if (Rhstype[0] != 'F' ) if (Rhstype[0] != 'F' )
{ {
fprintf(stderr,"Warn: Attempt to read auxillary vector(s) which are not stored in Full form.\n"); fprintf(stderr,"Warn: Attempt to read auxillary vector(s) which are not stored in Full form.\n");
fprintf(stderr," Rhs must be specified as full. \n"); fprintf(stderr," Rhs must be specified as full. \n");
fclose(in_file);
return 0; return 0;
} }
...@@ -615,10 +617,12 @@ int readHB_aux_double(const char* filename, const char AuxType, double b[]) ...@@ -615,10 +617,12 @@ int readHB_aux_double(const char* filename, const char AuxType, double b[])
if ( AuxType == 'G' && Rhstype[1] != 'G' ) { if ( AuxType == 'G' && Rhstype[1] != 'G' ) {
fprintf(stderr, "Warn: Attempt to read auxillary Guess vector(s) when none are present.\n"); fprintf(stderr, "Warn: Attempt to read auxillary Guess vector(s) when none are present.\n");
fclose(in_file);
return 0; return 0;
} }
if ( AuxType == 'X' && Rhstype[2] != 'X' ) { if ( AuxType == 'X' && Rhstype[2] != 'X' ) {
fprintf(stderr, "Warn: Attempt to read auxillary eXact solution vector(s) when none are present.\n"); fprintf(stderr, "Warn: Attempt to read auxillary eXact solution vector(s) when none are present.\n");
fclose(in_file);
return 0; return 0;
} }
...@@ -1344,7 +1348,7 @@ int writeHB_mat_char(const char* filename, int M, int N, ...@@ -1344,7 +1348,7 @@ int writeHB_mat_char(const char* filename, int M, int N,
int Ptrperline, Ptrwidth, Indperline, Indwidth; int Ptrperline, Ptrwidth, Indperline, Indwidth;
int Rhsperline, Rhswidth, Rhsprec; int Rhsperline, Rhswidth, Rhsprec;
char Rhsflag; char Rhsflag;
int Valperline=0, Valwidth, Valprec; int Valperline=1, Valwidth, Valprec;
char Valflag; /* Indicates 'E','D', or 'F' float format */ char Valflag; /* Indicates 'E','D', or 'F' float format */
char pformat[16],iformat[16],vformat[19],rformat[19]; char pformat[16],iformat[16],vformat[19],rformat[19];
......
...@@ -141,6 +141,7 @@ readIJV( const char *dirname, ...@@ -141,6 +141,7 @@ readIJV( const char *dirname,
if (iafile == NULL) if (iafile == NULL)
{ {
fprintf(stderr,"readijv: Cannot open the ia file (%s)\n", filename); fprintf(stderr,"readijv: Cannot open the ia file (%s)\n", filename);
free(filename);
return PASTIX_ERR_BADPARAMETER; return PASTIX_ERR_BADPARAMETER;
} }
...@@ -150,6 +151,7 @@ readIJV( const char *dirname, ...@@ -150,6 +151,7 @@ readIJV( const char *dirname,
{ {
fprintf(stderr,"readijv: Cannot open the ja file (%s)\n", filename); fprintf(stderr,"readijv: Cannot open the ja file (%s)\n", filename);
fclose(iafile); fclose(iafile);
free(filename);
return PASTIX_ERR_BADPARAMETER; return PASTIX_ERR_BADPARAMETER;
} }
...@@ -160,6 +162,7 @@ readIJV( const char *dirname, ...@@ -160,6 +162,7 @@ readIJV( const char *dirname,
fprintf(stderr,"readijv: Cannot open the ra file (%s)\n", filename); fprintf(stderr,"readijv: Cannot open the ra file (%s)\n", filename);
fclose(iafile); fclose(iafile);
fclose(jafile); fclose(jafile);
free(filename);
return PASTIX_ERR_BADPARAMETER; return PASTIX_ERR_BADPARAMETER;
} }
...@@ -178,6 +181,10 @@ readIJV( const char *dirname, ...@@ -178,6 +181,10 @@ readIJV( const char *dirname,
( 1 != fscanf(rafile,"%le\n", &temp3)) ) ( 1 != fscanf(rafile,"%le\n", &temp3)) )
{ {
fprintf(stderr, "ERROR: reading matrix\n"); fprintf(stderr, "ERROR: reading matrix\n");
fclose(iafile);
fclose(jafile);
fclose(rafile);
free(filename);
return PASTIX_ERR_IO; return PASTIX_ERR_IO;
} }
*temprow = (pastix_int_t)temp1; *temprow = (pastix_int_t)temp1;
...@@ -187,6 +194,6 @@ readIJV( const char *dirname, ...@@ -187,6 +194,6 @@ readIJV( const char *dirname,
fclose(iafile); fclose(iafile);
fclose(jafile); fclose(jafile);
fclose(rafile); fclose(rafile);
free(filename);
return PASTIX_SUCCESS; return PASTIX_SUCCESS;
} }
...@@ -184,8 +184,7 @@ z_spmInfNorm( const pastix_spm_t *spm ) ...@@ -184,8 +184,7 @@ z_spmInfNorm( const pastix_spm_t *spm )
sumrow[row] += cabs( valptr[i] ); sumrow[row] += cabs( valptr[i] );
/* Add the symmetric/hermitian part */ /* Add the symmetric/hermitian part */
if ( ((spm->mtxtype == PastixHermitian) || if ( ( spm->mtxtype != PastixGeneral ) &&
(spm->mtxtype == PastixSymmetric)) &&
( row != col ) ) ( row != col ) )
{ {
sumrow[col] += cabs( valptr[i] ); sumrow[col] += cabs( valptr[i] );
...@@ -204,8 +203,7 @@ z_spmInfNorm( const pastix_spm_t *spm ) ...@@ -204,8 +203,7 @@ z_spmInfNorm( const pastix_spm_t *spm )
} }
/* Add the symmetric/hermitian part */ /* Add the symmetric/hermitian part */
if ( (spm->mtxtype == PastixHermitian) || if ( spm->mtxtype != PastixGeneral )
(spm->mtxtype == PastixSymmetric) )
{ {
for( row=0; row < spm->gN; row++ ) for( row=0; row < spm->gN; row++ )
{ {
...@@ -228,8 +226,7 @@ z_spmInfNorm( const pastix_spm_t *spm ) ...@@ -228,8 +226,7 @@ z_spmInfNorm( const pastix_spm_t *spm )
} }
/* Add the symmetric/hermitian part */ /* Add the symmetric/hermitian part */
if ( (spm->mtxtype == PastixHermitian) || if ( spm->mtxtype != PastixGeneral )
(spm->mtxtype == PastixSymmetric) )
{ {
for(i=0; i < spm->nnz; i++) for(i=0; i < spm->nnz; i++)
{ {
...@@ -300,8 +297,7 @@ z_spmOneNorm( const pastix_spm_t *spm ) ...@@ -300,8 +297,7 @@ z_spmOneNorm( const pastix_spm_t *spm )
} }
/* Add the symmetric/hermitian part */ /* Add the symmetric/hermitian part */
if ( (spm->mtxtype == PastixHermitian) || if ( spm->mtxtype != PastixGeneral )
(spm->mtxtype == PastixSymmetric) )
{ {
for( col=0; col < spm->gN; col++ ) for( col=0; col < spm->gN; col++ )
{ {
...@@ -325,8 +321,7 @@ z_spmOneNorm( const pastix_spm_t *spm ) ...@@ -325,8 +321,7 @@ z_spmOneNorm( const pastix_spm_t *spm )
sumcol[col] += cabs( valptr[i] ); sumcol[col] += cabs( valptr[i] );
/* Add the symmetric/hermitian part */ /* Add the symmetric/hermitian part */
if ( ((spm->mtxtype == PastixHermitian) || if ( ( spm->mtxtype != PastixGeneral ) &&
(spm->mtxtype == PastixSymmetric)) &&
( row != col ) ) ( row != col ) )
{ {
sumcol[row] += cabs( valptr[i] ); sumcol[row] += cabs( valptr[i] );
...@@ -342,8 +337,7 @@ z_spmOneNorm( const pastix_spm_t *spm ) ...@@ -342,8 +337,7 @@ z_spmOneNorm( const pastix_spm_t *spm )
} }
/* Add the symmetric/hermitian part */ /* Add the symmetric/hermitian part */
if ( (spm->mtxtype == PastixHermitian) || if ( spm->mtxtype != PastixGeneral )
(spm->mtxtype == PastixSymmetric) )
{ {
for(i=0; i < spm->nnz; i++) for(i=0; i < spm->nnz; i++)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment