Skip to content

Commit 30834bc

Browse files
committed
add const type qualifier to argument err_msg
Contents of argument err_msg is not modified
1 parent 2d73262 commit 30834bc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/drivers/common/error_mpi2nc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020

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

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

@@ -65,14 +66,13 @@ int ncmpii_error_mpi2nc(int mpi_errorcode, /* returned value from MPI call */
6566
*/
6667

6768
MPI_Error_string(mpi_errorcode, errorString, &errorStringLen);
68-
if (err_msg == NULL) err_msg = "";
6969
#ifdef PNETCDF_DEBUG
7070
/* report the world rank */
7171
int rank;
7272
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
73-
printf("rank %d: MPI error (%s) : %s\n", rank, err_msg, errorString);
73+
printf("rank %d: MPI error (%s) : %s\n", rank, dump_str, errorString);
7474
#else
75-
printf("MPI error (%s) : %s\n", err_msg, errorString);
75+
printf("MPI error (%s) : %s\n", dump_str, errorString);
7676
#endif
7777

7878
return NC_EFILE; /* other unknown file I/O error */

src/drivers/include/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ ncmpii_create_imaptype(int ndims, const MPI_Offset *count,
107107
MPI_Datatype *imaptype);
108108

109109
extern int
110-
ncmpii_error_mpi2nc(int mpi_errorcode, char *msg);
110+
ncmpii_error_mpi2nc(int mpi_errorcode, const char *msg);
111111

112112
extern int
113113
ncmpii_error_posix2nc(char *err_msg);

0 commit comments

Comments
 (0)