@@ -53,7 +53,7 @@ check_vars(MPI_Comm comm,
5353 MPI_Offset * start ,
5454 MPI_Offset * count )
5555{
56- int id , j , r , nerrs = 0 , err , rank , * buf , rec_dim , dimids [3 ], nvars ;
56+ int id , j , r , nerrs = 0 , err , rank , * buf = NULL , rec_dim , dimids [3 ], nvars ;
5757 MPI_Offset nrecs ;
5858
5959 MPI_Comm_rank (comm , & rank );
@@ -111,7 +111,7 @@ check_vars(MPI_Comm comm,
111111 }
112112
113113err_out :
114- free (buf );
114+ if ( buf != NULL ) free (buf );
115115 return err ;
116116}
117117
@@ -186,7 +186,7 @@ check_vars(MPI_Comm comm,
186186}
187187#define WRITE_REC_VAR (id ) { \
188188 for (i=0; i<count[1] * count[2]; i++) \
189- buf[i] = rank + i + id * 10 + start[0]; \
189+ buf[i] = rank + i + id * 10 + (int) start[0]; \
190190 err = ncmpi_put_vara_int_all(ncid, varid[id], start, count, buf); \
191191 CHECK_ERR \
192192}
@@ -196,7 +196,7 @@ tst_fmt(char *filename,
196196 int cmode )
197197{
198198 int i , rank , nprocs , ncid , err , nerrs = 0 ;
199- int * buf , dimid [3 ], varid [16 ];
199+ int * buf = NULL , dimid [3 ], varid [16 ];
200200 MPI_Info info = MPI_INFO_NULL ;
201201 MPI_Offset start [3 ], count [3 ], increment ;
202202
@@ -379,9 +379,10 @@ tst_fmt(char *filename,
379379 exp_extent = 1024 * 5 ;
380380 CHECK_HEADER_SIZE
381381
382- err_out :
383382 err = ncmpi_close (ncid ); CHECK_ERR
384- free (buf );
383+
384+ err_out :
385+ if (buf != NULL ) free (buf );
385386 MPI_Info_free (& info );
386387
387388 return nerrs ;
0 commit comments