Skip to content

Commit

Permalink
add const type qualifier to argument err_msg
Browse files Browse the repository at this point in the history
Contents of argument err_msg is not modified
  • Loading branch information
wkliao committed Nov 26, 2024
1 parent 2d73262 commit 30834bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/drivers/common/error_mpi2nc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@

/*----< ncmpii_error_mpi2nc() -----------------------------------------------*/
/* translate MPI error codes to PnetCDF/netCDF error codes */
int ncmpii_error_mpi2nc(int mpi_errorcode, /* returned value from MPI call */
char *err_msg) /* extra error message */
int ncmpii_error_mpi2nc(int mpi_errorcode, /* returned value from MPI call */
const char *err_msg) /* extra error message */
{
int errorclass, errorStringLen;
char errorString[MPI_MAX_ERROR_STRING];
const char *dump_str = (err_msg == NULL) ? "" : err_msg;

/* check for specific error codes understood by PnetCDF */

Expand Down Expand Up @@ -65,14 +66,13 @@ int ncmpii_error_mpi2nc(int mpi_errorcode, /* returned value from MPI call */
*/

MPI_Error_string(mpi_errorcode, errorString, &errorStringLen);
if (err_msg == NULL) err_msg = "";
#ifdef PNETCDF_DEBUG
/* report the world rank */
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
printf("rank %d: MPI error (%s) : %s\n", rank, err_msg, errorString);
printf("rank %d: MPI error (%s) : %s\n", rank, dump_str, errorString);
#else
printf("MPI error (%s) : %s\n", err_msg, errorString);
printf("MPI error (%s) : %s\n", dump_str, errorString);
#endif

return NC_EFILE; /* other unknown file I/O error */
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ncmpii_create_imaptype(int ndims, const MPI_Offset *count,
MPI_Datatype *imaptype);

extern int
ncmpii_error_mpi2nc(int mpi_errorcode, char *msg);
ncmpii_error_mpi2nc(int mpi_errorcode, const char *msg);

extern int
ncmpii_error_posix2nc(char *err_msg);
Expand Down

0 comments on commit 30834bc

Please sign in to comment.