Skip to content

Commit 743e190

Browse files
committed
Use opal_asprintf instead of asprintf
A couple places where using asprintf and not paying attention to return values was causing warnings. Use opal_asprintf instead, which has known behavior with the return pointer on failure and so we can safely ignore return values. Signed-off-by: Brian Barrett <bbarrett@amazon.com>
1 parent 4fdae9f commit 743e190

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

ompi/mca/sharedfp/sm/sharedfp_sm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "ompi_config.h"
3030
#include "mpi.h"
31+
#include "opal/util/printf.h"
3132
#include "ompi/mca/sharedfp/sharedfp.h"
3233
#include "ompi/mca/sharedfp/base/base.h"
3334
#include "ompi/mca/sharedfp/sm/sharedfp_sm.h"
@@ -105,7 +106,7 @@ struct mca_sharedfp_base_module_1_0_0_t * mca_sharedfp_sm_component_file_query(o
105106
int comm_cid = -1;
106107
int pid = ompi_comm_rank (comm);
107108

108-
asprintf(&sm_filename, "%s/%s_cid-%d-%d.sm", ompi_process_info.job_session_dir,
109+
opal_asprintf(&sm_filename, "%s/%s_cid-%d-%d.sm", ompi_process_info.job_session_dir,
109110
filename_basename, comm_cid, pid);
110111
free(filename_basename);
111112

ompi/mca/sharedfp/sm/sharedfp_sm_file_open.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "sharedfp_sm.h"
3636

3737
#include "mpi.h"
38+
#include "opal/util/printf.h"
3839
#include "opal/util/output.h"
3940
#include "ompi/constants.h"
4041
#include "ompi/group/group.h"
@@ -120,8 +121,8 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
120121
return err;
121122
}
122123

123-
asprintf(&sm_filename, "%s/%s_cid-%d-%d.sm", ompi_process_info.job_session_dir,
124-
filename_basename, comm_cid, int_pid);
124+
opal_asprintf(&sm_filename, "%s/%s_cid-%d-%d.sm", ompi_process_info.job_session_dir,
125+
filename_basename, comm_cid, int_pid);
125126
/* open shared memory file, initialize to 0, map into memory */
126127
sm_fd = open(sm_filename, O_RDWR | O_CREAT,
127128
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);

ompi/tools/mpirun/main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "opal/util/os_dirpath.h"
2424
#include "opal/util/os_path.h"
2525
#include "opal/util/path.h"
26+
#include "opal/util/printf.h"
2627

2728
int main(int argc, char *argv[])
2829
{
@@ -35,12 +36,12 @@ int main(int argc, char *argv[])
3536
if (NULL != (evar = getenv("OPAL_PREFIX"))) {
3637

3738
#if OMPI_USING_INTERNAL_PRRTE
38-
(void)asprintf(&pvar, "PRTE_PREFIX=%s", evar);
39+
opal_asprintf(&pvar, "PRTE_PREFIX=%s", evar);
3940
putenv(pvar);
4041
#endif
4142

4243
#if OPAL_USING_INTERNAL_PMIX
43-
(void)asprintf(&pvar, "PMIX_PREFIX=%s", evar);
44+
opal_asprintf(&pvar, "PMIX_PREFIX=%s", evar);
4445
putenv(pvar);
4546
#endif
4647
}
@@ -51,7 +52,7 @@ int main(int argc, char *argv[])
5152
opal_argv_append_nosize(&pargs, argv[m]);
5253
/* Did the user specify a prefix, or want prefix by default? */
5354
if (0 == strcmp(argv[m], "--prefix")) {
54-
asprintf(&pfx, "%s%s", argv[m+1], "/bin");
55+
opal_asprintf(&pfx, "%s%s", argv[m+1], "/bin");
5556
}
5657
}
5758

0 commit comments

Comments
 (0)