Skip to content

Commit fc81d0d

Browse files
author
Ralph H Castain
committed
Replace asprintf with opal_asprintf
Silence the flood of warnings from ORTE Signed-off-by: Ralph H Castain <rhc@open-mpi.org>
1 parent 80ee5c8 commit fc81d0d

File tree

83 files changed

+564
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+564
-480
lines changed

orte/mca/errmgr/base/errmgr_base_fns.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved.
1414
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
1515
* All rights reserved.
16-
* Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
16+
* Copyright (c) 2013-2018 Intel, Inc. All rights reserved.
1717
* Copyright (c) 2014 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
1919
* $COPYRIGHT$
@@ -52,6 +52,7 @@
5252
#include "opal/mca/base/base.h"
5353
#include "opal/util/os_dirpath.h"
5454
#include "opal/util/output.h"
55+
#include "opal/util/printf.h"
5556
#include "opal/util/basename.h"
5657
#include "opal/util/argv.h"
5758
#include "opal/mca/crs/crs.h"
@@ -109,7 +110,7 @@ void orte_errmgr_base_abort(int error_code, char *fmt, ...)
109110
va_start(arglist, fmt);
110111
if( NULL != fmt ) {
111112
char* buffer = NULL;
112-
vasprintf( &buffer, fmt, arglist );
113+
opal_vasprintf( &buffer, fmt, arglist );
113114
opal_output( 0, "%s", buffer );
114115
free( buffer );
115116
}
@@ -252,8 +253,8 @@ int orte_errmgr_base_update_app_context_for_cr_recovery(orte_job_t *jobdata,
252253

253254
orte_remove_attribute(&new_app_context->attributes, ORTE_APP_PRELOAD_BIN);
254255

255-
asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid);
256-
asprintf(&sload,
256+
opal_asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid);
257+
opal_asprintf(&sload,
257258
"%s:%s:%s:%s:%s:%s",
258259
location_str,
259260
global_snapshot_ref,
@@ -285,8 +286,8 @@ int orte_errmgr_base_update_app_context_for_cr_recovery(orte_job_t *jobdata,
285286
opal_argv_free(new_app_context->argv);
286287
new_app_context->argv = NULL;
287288

288-
asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid);
289-
asprintf(&sload,
289+
opal_asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid);
290+
opal_asprintf(&sload,
290291
"%s:%s:%s:%s:%s:%s",
291292
location_str,
292293
global_snapshot_ref,
@@ -312,7 +313,7 @@ int orte_errmgr_base_update_app_context_for_cr_recovery(orte_job_t *jobdata,
312313
free(tmp_str);
313314
tmp_str = NULL;
314315
}
315-
asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid);
316+
opal_asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid);
316317
opal_argv_append(&argc, &(new_app_context->argv), tmp_str);
317318

318319
cleanup:

orte/mca/errmgr/default_hnp/errmgr_default_hnp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static void hnp_abort(int error_code, char *fmt, ...)
151151
/* If there was a message, construct it */
152152
va_start(arglist, fmt);
153153
if (NULL != fmt) {
154-
vasprintf(&outmsg, fmt, arglist);
154+
opal_vasprintf(&outmsg, fmt, arglist);
155155
}
156156
va_end(arglist);
157157

orte/mca/errmgr/default_orted/errmgr_default_orted.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static void orted_abort(int error_code, char *fmt, ...)
150150
/* If there was a message, construct it */
151151
va_start(arglist, fmt);
152152
if (NULL != fmt) {
153-
vasprintf(&outmsg, fmt, arglist);
153+
opal_vasprintf(&outmsg, fmt, arglist);
154154
}
155155
va_end(arglist);
156156

orte/mca/ess/pmi/ess_pmi_module.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ static int rte_init(void)
227227
* MPI-3 required info key
228228
*/
229229
if (NULL == getenv(OPAL_MCA_PREFIX"orte_ess_num_procs")) {
230-
asprintf(&ev1, OPAL_MCA_PREFIX"orte_ess_num_procs=%d", orte_process_info.num_procs);
230+
opal_asprintf(&ev1, OPAL_MCA_PREFIX"orte_ess_num_procs=%d", orte_process_info.num_procs);
231231
putenv(ev1);
232232
added_num_procs = true;
233233
}
234234
if (NULL == getenv("OMPI_APP_CTX_NUM_PROCS")) {
235-
asprintf(&ev2, "OMPI_APP_CTX_NUM_PROCS=%d", orte_process_info.num_procs);
235+
opal_asprintf(&ev2, "OMPI_APP_CTX_NUM_PROCS=%d", orte_process_info.num_procs);
236236
putenv(ev2);
237237
added_app_ctx = true;
238238
}
@@ -279,7 +279,7 @@ static int rte_init(void)
279279
opal_output_verbose(2, orte_ess_base_framework.framework_output,
280280
"%s transport key %s",
281281
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), string_key);
282-
asprintf(&envar, OPAL_MCA_PREFIX"orte_precondition_transports=%s", string_key);
282+
opal_asprintf(&envar, OPAL_MCA_PREFIX"orte_precondition_transports=%s", string_key);
283283
putenv(envar);
284284
added_transport_keys = true;
285285
/* cannot free the envar as that messes up our environ */

orte/mca/ess/singleton/ess_singleton_module.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,14 @@ static int rte_init(void)
240240
*/
241241
if (NULL == getenv(OPAL_MCA_PREFIX"orte_ess_num_procs")) {
242242
char * num_procs;
243-
asprintf(&num_procs, "%d", orte_process_info.num_procs);
243+
opal_asprintf(&num_procs, "%d", orte_process_info.num_procs);
244244
opal_setenv(OPAL_MCA_PREFIX"orte_ess_num_procs", num_procs, true, &environ);
245245
free(num_procs);
246246
added_num_procs = true;
247247
}
248248
if (NULL == getenv("OMPI_APP_CTX_NUM_PROCS")) {
249249
char * num_procs;
250-
asprintf(&num_procs, "%d", orte_process_info.num_procs);
250+
opal_asprintf(&num_procs, "%d", orte_process_info.num_procs);
251251
opal_setenv("OMPI_APP_CTX_NUM_PROCS", num_procs, true, &environ);
252252
free(num_procs);
253253
added_app_ctx = true;
@@ -592,13 +592,13 @@ static int fork_hnp(void)
592592

593593
/* tell the daemon to report back its uri so we can connect to it */
594594
opal_argv_append(&argc, &argv, "--report-uri");
595-
asprintf(&param, "%d", p[1]);
595+
opal_asprintf(&param, "%d", p[1]);
596596
opal_argv_append(&argc, &argv, param);
597597
free(param);
598598

599599
/* give the daemon a pipe it can watch to tell when we have died */
600600
opal_argv_append(&argc, &argv, "--singleton-died-pipe");
601-
asprintf(&param, "%d", death_pipe[0]);
601+
opal_asprintf(&param, "%d", death_pipe[0]);
602602
opal_argv_append(&argc, &argv, param);
603603
free(param);
604604

orte/mca/filem/base/base.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* All rights reserved.
1212
* Copyright (c) 2012-2013 Los Alamos National Security, LLC.
1313
* All rights reserved
14+
* Copyright (c) 2018 Intel, Inc. All rights reserved.
1415
* $COPYRIGHT$
1516
*
1617
* Additional copyrights may follow
@@ -22,6 +23,7 @@
2223

2324
#include "orte_config.h"
2425

26+
#include "opal/util/printf.h"
2527
#include "orte/mca/rml/rml.h"
2628

2729
#include "orte/mca/filem/filem.h"

orte/mca/filem/base/filem_base_receive.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* All rights reserved.
1313
* Copyright (c) 2011-2012 Los Alamos National Security, LLC. All rights
1414
* reserved.
15-
* Copyright (c) 2016 Intel, Inc. All rights reserved.
15+
* Copyright (c) 2016-2018 Intel, Inc. All rights reserved.
1616
* $COPYRIGHT$
1717
*
1818
* Additional copyrights may follow
@@ -41,6 +41,7 @@
4141

4242
#include "orte/mca/mca.h"
4343
#include "opal/util/output.h"
44+
#include "opal/util/printf.h"
4445

4546
#include "opal/dss/dss.h"
4647
#include "orte/constants.h"
@@ -247,8 +248,10 @@ static void filem_base_process_get_remote_path_cmd(orte_process_name_t* sender,
247248
* Determine the absolute path of the file
248249
*/
249250
if (filename[0] != '/') { /* if it is not an absolute path already */
250-
getcwd(cwd, sizeof(cwd));
251-
asprintf(&tmp_name, "%s/%s", cwd, filename);
251+
if (NULL == getcwd(cwd, sizeof(cwd))) {
252+
return;
253+
}
254+
opal_asprintf(&tmp_name, "%s/%s", cwd, filename);
252255
}
253256
else {
254257
tmp_name = strdup(filename);

orte/mca/filem/raw/filem_raw_module.c

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2012-2013 Los Alamos National Security, LLC.
33
* All rights reserved
44
* Copyright (c) 2013 Cisco Systems, Inc. All rights reserved.
5-
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
5+
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
66
* Copyright (c) 2015-2017 Research Organization for Information Science
77
* and Technology (RIST). All rights reserved.
88
* $COPYRIGHT$
@@ -288,7 +288,7 @@ static int raw_preposition_files(orte_job_t *jdata,
288288
*/
289289
cptr = opal_basename(app->app);
290290
free(app->app);
291-
asprintf(&app->app, "./%s", cptr);
291+
opal_asprintf(&app->app, "./%s", cptr);
292292
free(app->argv[0]);
293293
app->argv[0] = strdup(app->app);
294294
fs->remote_target = strdup(app->app);
@@ -894,7 +894,7 @@ static int link_archive(orte_filem_raw_incoming_t *inbnd)
894894
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
895895
inbnd->fullpath));
896896

897-
asprintf(&cmd, "tar tf %s", inbnd->fullpath);
897+
opal_asprintf(&cmd, "tar tf %s", inbnd->fullpath);
898898
fp = popen(cmd, "r");
899899
free(cmd);
900900
if (NULL == fp) {
@@ -1145,25 +1145,41 @@ static void write_handler(int fd, short event, void *cbdata)
11451145
} else {
11461146
/* unarchive the file */
11471147
if (ORTE_FILEM_TYPE_TAR == sink->type) {
1148-
asprintf(&cmd, "tar xf %s", sink->file);
1148+
opal_asprintf(&cmd, "tar xf %s", sink->file);
11491149
} else if (ORTE_FILEM_TYPE_BZIP == sink->type) {
1150-
asprintf(&cmd, "tar xjf %s", sink->file);
1150+
opal_asprintf(&cmd, "tar xjf %s", sink->file);
11511151
} else if (ORTE_FILEM_TYPE_GZIP == sink->type) {
1152-
asprintf(&cmd, "tar xzf %s", sink->file);
1152+
opal_asprintf(&cmd, "tar xzf %s", sink->file);
11531153
} else {
11541154
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
11551155
send_complete(sink->file, ORTE_ERR_FILE_WRITE_FAILURE);
11561156
return;
11571157
}
1158-
getcwd(homedir, sizeof(homedir));
1158+
if (NULL == getcwd(homedir, sizeof(homedir))) {
1159+
ORTE_ERROR_LOG(ORTE_ERROR);
1160+
send_complete(sink->file, ORTE_ERR_FILE_WRITE_FAILURE);
1161+
return;
1162+
}
11591163
dirname = opal_dirname(sink->fullpath);
1160-
chdir(dirname);
1164+
if (0 != chdir(dirname)) {
1165+
ORTE_ERROR_LOG(ORTE_ERROR);
1166+
send_complete(sink->file, ORTE_ERR_FILE_WRITE_FAILURE);
1167+
return;
1168+
}
11611169
OPAL_OUTPUT_VERBOSE((1, orte_filem_base_framework.framework_output,
11621170
"%s write:handler unarchiving file %s with cmd: %s",
11631171
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
11641172
sink->file, cmd));
1165-
system(cmd);
1166-
chdir(homedir);
1173+
if (0 != system(cmd)) {
1174+
ORTE_ERROR_LOG(ORTE_ERROR);
1175+
send_complete(sink->file, ORTE_ERR_FILE_WRITE_FAILURE);
1176+
return;
1177+
}
1178+
if (0 != chdir(homedir)) {
1179+
ORTE_ERROR_LOG(ORTE_ERROR);
1180+
send_complete(sink->file, ORTE_ERR_FILE_WRITE_FAILURE);
1181+
return;
1182+
}
11671183
free(dirname);
11681184
free(cmd);
11691185
/* setup the link points */

orte/mca/iof/base/iof_base_setup.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
13-
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
13+
* Copyright (c) 2016-2018 Intel, Inc. All rights reserved.
1414
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1515
* Copyright (c) 2017 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
@@ -64,6 +64,7 @@
6464
#include "opal/util/os_dirpath.h"
6565
#include "opal/util/output.h"
6666
#include "opal/util/argv.h"
67+
#include "opal/util/printf.h"
6768

6869
#include "orte/mca/errmgr/errmgr.h"
6970
#include "orte/util/name_fns.h"
@@ -224,7 +225,7 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
224225
if (!orte_map_stddiag_to_stderr && !orte_map_stddiag_to_stdout ) {
225226
/* Set an environment variable that the new child process can use
226227
to get the fd of the pipe connected to the INTERNAL IOF tag. */
227-
asprintf(&str, "%d", opts->p_internal[1]);
228+
opal_asprintf(&str, "%d", opts->p_internal[1]);
228229
if (NULL != str) {
229230
opal_setenv("OPAL_OUTPUT_STDERR_FD", str, true, env);
230231
free(str);
@@ -318,11 +319,11 @@ int orte_iof_base_setup_output_files(const orte_process_name_t* dst_name,
318319

319320
/* construct the directory where the output files will go */
320321
if (usejobid) {
321-
asprintf(&outdir, "%s/%d/rank.%0*lu", dirname,
322+
opal_asprintf(&outdir, "%s/%d/rank.%0*lu", dirname,
322323
(int)ORTE_LOCAL_JOBID(proct->name.jobid),
323324
numdigs, (unsigned long)proct->name.vpid);
324325
} else {
325-
asprintf(&outdir, "%s/rank.%0*lu", dirname,
326+
opal_asprintf(&outdir, "%s/rank.%0*lu", dirname,
326327
numdigs, (unsigned long)proct->name.vpid);
327328
}
328329
/* ensure the directory exists */
@@ -333,7 +334,7 @@ int orte_iof_base_setup_output_files(const orte_process_name_t* dst_name,
333334
}
334335
if (NULL != proct->revstdout && NULL == proct->revstdout->sink) {
335336
/* setup the stdout sink */
336-
asprintf(&outfile, "%s/stdout", outdir);
337+
opal_asprintf(&outfile, "%s/stdout", outdir);
337338
fdout = open(outfile, O_CREAT|O_RDWR|O_TRUNC, 0644);
338339
free(outfile);
339340
if (fdout < 0) {
@@ -357,7 +358,7 @@ int orte_iof_base_setup_output_files(const orte_process_name_t* dst_name,
357358
proct->revstdout->sink->tag = ORTE_IOF_STDMERGE; // show that it is merged
358359
proct->revstderr->sink = proct->revstdout->sink;
359360
} else {
360-
asprintf(&outfile, "%s/stderr", outdir);
361+
opal_asprintf(&outfile, "%s/stderr", outdir);
361362
fdout = open(outfile, O_CREAT|O_RDWR|O_TRUNC, 0644);
362363
free(outfile);
363364
if (fdout < 0) {

0 commit comments

Comments
 (0)