From fc81d0d5195cc12a90f03679e5c22ffd9271fe33 Mon Sep 17 00:00:00 2001 From: Ralph H Castain Date: Sat, 6 Oct 2018 19:32:37 +0000 Subject: [PATCH] Replace asprintf with opal_asprintf Silence the flood of warnings from ORTE Signed-off-by: Ralph H Castain --- orte/mca/errmgr/base/errmgr_base_fns.c | 15 +- .../errmgr/default_hnp/errmgr_default_hnp.c | 2 +- .../default_orted/errmgr_default_orted.c | 2 +- orte/mca/ess/pmi/ess_pmi_module.c | 6 +- orte/mca/ess/singleton/ess_singleton_module.c | 8 +- orte/mca/filem/base/base.h | 2 + orte/mca/filem/base/filem_base_receive.c | 9 +- orte/mca/filem/raw/filem_raw_module.c | 36 +++- orte/mca/iof/base/iof_base_setup.c | 13 +- orte/mca/odls/base/odls_base_default_fns.c | 37 +++- orte/mca/odls/base/odls_base_frame.c | 5 +- orte/mca/oob/alps/oob_alps_component.c | 4 +- orte/mca/oob/base/base.h | 3 +- orte/mca/oob/base/oob_base_stubs.c | 5 +- orte/mca/oob/tcp/oob_tcp_component.c | 10 +- orte/mca/oob/tcp/oob_tcp_listener.c | 6 +- orte/mca/plm/alps/plm_alps_module.c | 12 +- orte/mca/plm/base/base.h | 1 + orte/mca/plm/base/plm_base_launch_support.c | 5 +- orte/mca/plm/rsh/plm_rsh.h | 3 +- orte/mca/plm/rsh/plm_rsh_component.c | 4 +- orte/mca/plm/rsh/plm_rsh_module.c | 20 +- orte/mca/plm/slurm/plm_slurm_module.c | 18 +- orte/mca/plm/tm/plm_tm_module.c | 8 +- orte/mca/ras/alps/ras_alps_component.c | 3 +- orte/mca/ras/alps/ras_alps_module.c | 10 +- orte/mca/ras/base/base.h | 4 +- orte/mca/ras/base/ras_base_allocate.c | 11 +- orte/mca/ras/simulator/ras_sim_module.c | 2 +- orte/mca/ras/slurm/ras_slurm_module.c | 18 +- orte/mca/regx/base/regx_base_default_fns.c | 21 +- orte/mca/regx/fwd/regx_fwd.c | 22 +- orte/mca/regx/reverse/regx_reverse.c | 22 +- orte/mca/rmaps/base/base.h | 1 + orte/mca/rmaps/base/rmaps_base_frame.c | 7 +- orte/mca/rmaps/base/rmaps_base_print_fns.c | 13 +- orte/mca/rtc/base/base.h | 3 +- orte/mca/rtc/hwloc/rtc_hwloc.c | 10 +- orte/mca/schizo/base/base.h | 3 +- orte/mca/schizo/ompi/schizo_ompi.c | 32 +-- .../schizo/singularity/schizo_singularity.c | 6 +- orte/mca/schizo/slurm/schizo_slurm.c | 4 +- orte/mca/snapc/base/base.h | 2 + orte/mca/snapc/base/snapc_base_fns.c | 4 +- orte/mca/snapc/full/snapc_full_app.c | 5 +- orte/mca/snapc/full/snapc_full_local.c | 11 +- orte/mca/sstore/base/base.h | 2 + orte/mca/sstore/base/sstore_base_fns.c | 27 +-- orte/mca/sstore/base/sstore_base_frame.c | 3 +- orte/mca/sstore/central/sstore_central_app.c | 3 +- .../sstore/central/sstore_central_global.c | 15 +- .../mca/sstore/central/sstore_central_local.c | 7 +- orte/mca/sstore/stage/sstore_stage_app.c | 3 +- orte/mca/sstore/stage/sstore_stage_global.c | 33 +-- orte/mca/sstore/stage/sstore_stage_local.c | 33 +-- orte/mca/state/base/base.h | 2 + orte/mca/state/base/state_base_fns.c | 6 +- orte/orted/orted_main.c | 4 +- orte/orted/orted_submit.c | 26 +-- orte/orted/pmix/pmix_server.c | 5 +- orte/orted/pmix/pmix_server_internal.h | 7 +- orte/orted/pmix/pmix_server_pub.c | 8 +- .../data_type_support/orte_dt_print_fns.c | 198 +++++++++--------- orte/runtime/orte_info_support.c | 9 +- orte/runtime/orte_mca_params.c | 3 +- orte/test/mpi/concurrent_spawn.c | 2 +- orte/test/mpi/hello_nodename.c | 8 +- orte/test/mpi/intercomm_create.c | 4 +- orte/test/mpi/read_write.c | 2 +- orte/test/mpi/ziatest.c | 3 +- orte/test/system/threads.c | 2 +- orte/tools/ompi-prun/prun.c | 22 +- orte/tools/orte-clean/orte-clean.c | 9 +- orte/tools/orte-info/orte-info.h | 2 + orte/tools/orte-info/output.c | 11 +- orte/tools/orte-info/param.c | 13 +- orte/tools/orte-info/version.c | 37 ++-- orte/tools/orte-ps/orte-ps.c | 7 +- orte/tools/orte-top/orte-top.c | 19 +- orte/util/name_fns.c | 36 ++-- orte/util/pre_condition_transports.c | 5 +- orte/util/session_dir.c | 15 +- orte/util/show_help.c | 5 +- 83 files changed, 564 insertions(+), 480 deletions(-) diff --git a/orte/mca/errmgr/base/errmgr_base_fns.c b/orte/mca/errmgr/base/errmgr_base_fns.c index 8ce8794f29..538c97de94 100644 --- a/orte/mca/errmgr/base/errmgr_base_fns.c +++ b/orte/mca/errmgr/base/errmgr_base_fns.c @@ -13,7 +13,7 @@ * Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved. * Copyright (c) 2011-2013 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -52,6 +52,7 @@ #include "opal/mca/base/base.h" #include "opal/util/os_dirpath.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal/util/basename.h" #include "opal/util/argv.h" #include "opal/mca/crs/crs.h" @@ -109,7 +110,7 @@ void orte_errmgr_base_abort(int error_code, char *fmt, ...) va_start(arglist, fmt); if( NULL != fmt ) { char* buffer = NULL; - vasprintf( &buffer, fmt, arglist ); + opal_vasprintf( &buffer, fmt, arglist ); opal_output( 0, "%s", buffer ); free( buffer ); } @@ -252,8 +253,8 @@ int orte_errmgr_base_update_app_context_for_cr_recovery(orte_job_t *jobdata, orte_remove_attribute(&new_app_context->attributes, ORTE_APP_PRELOAD_BIN); - asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid); - asprintf(&sload, + opal_asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid); + opal_asprintf(&sload, "%s:%s:%s:%s:%s:%s", location_str, global_snapshot_ref, @@ -285,8 +286,8 @@ int orte_errmgr_base_update_app_context_for_cr_recovery(orte_job_t *jobdata, opal_argv_free(new_app_context->argv); new_app_context->argv = NULL; - asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid); - asprintf(&sload, + opal_asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid); + opal_asprintf(&sload, "%s:%s:%s:%s:%s:%s", location_str, global_snapshot_ref, @@ -312,7 +313,7 @@ int orte_errmgr_base_update_app_context_for_cr_recovery(orte_job_t *jobdata, free(tmp_str); tmp_str = NULL; } - asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid); + opal_asprintf(&tmp_str, reference_fmt_str, vpid_snapshot->process_name.vpid); opal_argv_append(&argc, &(new_app_context->argv), tmp_str); cleanup: diff --git a/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c b/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c index 05a2a83713..c748d28067 100644 --- a/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c +++ b/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c @@ -151,7 +151,7 @@ static void hnp_abort(int error_code, char *fmt, ...) /* If there was a message, construct it */ va_start(arglist, fmt); if (NULL != fmt) { - vasprintf(&outmsg, fmt, arglist); + opal_vasprintf(&outmsg, fmt, arglist); } va_end(arglist); diff --git a/orte/mca/errmgr/default_orted/errmgr_default_orted.c b/orte/mca/errmgr/default_orted/errmgr_default_orted.c index 92cfc27e98..f423db57ef 100644 --- a/orte/mca/errmgr/default_orted/errmgr_default_orted.c +++ b/orte/mca/errmgr/default_orted/errmgr_default_orted.c @@ -150,7 +150,7 @@ static void orted_abort(int error_code, char *fmt, ...) /* If there was a message, construct it */ va_start(arglist, fmt); if (NULL != fmt) { - vasprintf(&outmsg, fmt, arglist); + opal_vasprintf(&outmsg, fmt, arglist); } va_end(arglist); diff --git a/orte/mca/ess/pmi/ess_pmi_module.c b/orte/mca/ess/pmi/ess_pmi_module.c index 39518749ab..21a99e6779 100644 --- a/orte/mca/ess/pmi/ess_pmi_module.c +++ b/orte/mca/ess/pmi/ess_pmi_module.c @@ -227,12 +227,12 @@ static int rte_init(void) * MPI-3 required info key */ if (NULL == getenv(OPAL_MCA_PREFIX"orte_ess_num_procs")) { - asprintf(&ev1, OPAL_MCA_PREFIX"orte_ess_num_procs=%d", orte_process_info.num_procs); + opal_asprintf(&ev1, OPAL_MCA_PREFIX"orte_ess_num_procs=%d", orte_process_info.num_procs); putenv(ev1); added_num_procs = true; } if (NULL == getenv("OMPI_APP_CTX_NUM_PROCS")) { - asprintf(&ev2, "OMPI_APP_CTX_NUM_PROCS=%d", orte_process_info.num_procs); + opal_asprintf(&ev2, "OMPI_APP_CTX_NUM_PROCS=%d", orte_process_info.num_procs); putenv(ev2); added_app_ctx = true; } @@ -279,7 +279,7 @@ static int rte_init(void) opal_output_verbose(2, orte_ess_base_framework.framework_output, "%s transport key %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), string_key); - asprintf(&envar, OPAL_MCA_PREFIX"orte_precondition_transports=%s", string_key); + opal_asprintf(&envar, OPAL_MCA_PREFIX"orte_precondition_transports=%s", string_key); putenv(envar); added_transport_keys = true; /* cannot free the envar as that messes up our environ */ diff --git a/orte/mca/ess/singleton/ess_singleton_module.c b/orte/mca/ess/singleton/ess_singleton_module.c index c35909484b..e2bffdb67f 100644 --- a/orte/mca/ess/singleton/ess_singleton_module.c +++ b/orte/mca/ess/singleton/ess_singleton_module.c @@ -240,14 +240,14 @@ static int rte_init(void) */ if (NULL == getenv(OPAL_MCA_PREFIX"orte_ess_num_procs")) { char * num_procs; - asprintf(&num_procs, "%d", orte_process_info.num_procs); + opal_asprintf(&num_procs, "%d", orte_process_info.num_procs); opal_setenv(OPAL_MCA_PREFIX"orte_ess_num_procs", num_procs, true, &environ); free(num_procs); added_num_procs = true; } if (NULL == getenv("OMPI_APP_CTX_NUM_PROCS")) { char * num_procs; - asprintf(&num_procs, "%d", orte_process_info.num_procs); + opal_asprintf(&num_procs, "%d", orte_process_info.num_procs); opal_setenv("OMPI_APP_CTX_NUM_PROCS", num_procs, true, &environ); free(num_procs); added_app_ctx = true; @@ -592,13 +592,13 @@ static int fork_hnp(void) /* tell the daemon to report back its uri so we can connect to it */ opal_argv_append(&argc, &argv, "--report-uri"); - asprintf(¶m, "%d", p[1]); + opal_asprintf(¶m, "%d", p[1]); opal_argv_append(&argc, &argv, param); free(param); /* give the daemon a pipe it can watch to tell when we have died */ opal_argv_append(&argc, &argv, "--singleton-died-pipe"); - asprintf(¶m, "%d", death_pipe[0]); + opal_asprintf(¶m, "%d", death_pipe[0]); opal_argv_append(&argc, &argv, param); free(param); diff --git a/orte/mca/filem/base/base.h b/orte/mca/filem/base/base.h index c990abec30..66f347825f 100644 --- a/orte/mca/filem/base/base.h +++ b/orte/mca/filem/base/base.h @@ -11,6 +11,7 @@ * All rights reserved. * Copyright (c) 2012-2013 Los Alamos National Security, LLC. * All rights reserved + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -22,6 +23,7 @@ #include "orte_config.h" +#include "opal/util/printf.h" #include "orte/mca/rml/rml.h" #include "orte/mca/filem/filem.h" diff --git a/orte/mca/filem/base/filem_base_receive.c b/orte/mca/filem/base/filem_base_receive.c index 88209af010..30c958d3e2 100644 --- a/orte/mca/filem/base/filem_base_receive.c +++ b/orte/mca/filem/base/filem_base_receive.c @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2011-2012 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2016 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -41,6 +41,7 @@ #include "orte/mca/mca.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal/dss/dss.h" #include "orte/constants.h" @@ -247,8 +248,10 @@ static void filem_base_process_get_remote_path_cmd(orte_process_name_t* sender, * Determine the absolute path of the file */ if (filename[0] != '/') { /* if it is not an absolute path already */ - getcwd(cwd, sizeof(cwd)); - asprintf(&tmp_name, "%s/%s", cwd, filename); + if (NULL == getcwd(cwd, sizeof(cwd))) { + return; + } + opal_asprintf(&tmp_name, "%s/%s", cwd, filename); } else { tmp_name = strdup(filename); diff --git a/orte/mca/filem/raw/filem_raw_module.c b/orte/mca/filem/raw/filem_raw_module.c index 90f7322b96..14359217d9 100644 --- a/orte/mca/filem/raw/filem_raw_module.c +++ b/orte/mca/filem/raw/filem_raw_module.c @@ -2,7 +2,7 @@ * Copyright (c) 2012-2013 Los Alamos National Security, LLC. * All rights reserved * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -288,7 +288,7 @@ static int raw_preposition_files(orte_job_t *jdata, */ cptr = opal_basename(app->app); free(app->app); - asprintf(&app->app, "./%s", cptr); + opal_asprintf(&app->app, "./%s", cptr); free(app->argv[0]); app->argv[0] = strdup(app->app); fs->remote_target = strdup(app->app); @@ -894,7 +894,7 @@ static int link_archive(orte_filem_raw_incoming_t *inbnd) ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), inbnd->fullpath)); - asprintf(&cmd, "tar tf %s", inbnd->fullpath); + opal_asprintf(&cmd, "tar tf %s", inbnd->fullpath); fp = popen(cmd, "r"); free(cmd); if (NULL == fp) { @@ -1145,25 +1145,41 @@ static void write_handler(int fd, short event, void *cbdata) } else { /* unarchive the file */ if (ORTE_FILEM_TYPE_TAR == sink->type) { - asprintf(&cmd, "tar xf %s", sink->file); + opal_asprintf(&cmd, "tar xf %s", sink->file); } else if (ORTE_FILEM_TYPE_BZIP == sink->type) { - asprintf(&cmd, "tar xjf %s", sink->file); + opal_asprintf(&cmd, "tar xjf %s", sink->file); } else if (ORTE_FILEM_TYPE_GZIP == sink->type) { - asprintf(&cmd, "tar xzf %s", sink->file); + opal_asprintf(&cmd, "tar xzf %s", sink->file); } else { ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); send_complete(sink->file, ORTE_ERR_FILE_WRITE_FAILURE); return; } - getcwd(homedir, sizeof(homedir)); + if (NULL == getcwd(homedir, sizeof(homedir))) { + ORTE_ERROR_LOG(ORTE_ERROR); + send_complete(sink->file, ORTE_ERR_FILE_WRITE_FAILURE); + return; + } dirname = opal_dirname(sink->fullpath); - chdir(dirname); + if (0 != chdir(dirname)) { + ORTE_ERROR_LOG(ORTE_ERROR); + send_complete(sink->file, ORTE_ERR_FILE_WRITE_FAILURE); + return; + } OPAL_OUTPUT_VERBOSE((1, orte_filem_base_framework.framework_output, "%s write:handler unarchiving file %s with cmd: %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), sink->file, cmd)); - system(cmd); - chdir(homedir); + if (0 != system(cmd)) { + ORTE_ERROR_LOG(ORTE_ERROR); + send_complete(sink->file, ORTE_ERR_FILE_WRITE_FAILURE); + return; + } + if (0 != chdir(homedir)) { + ORTE_ERROR_LOG(ORTE_ERROR); + send_complete(sink->file, ORTE_ERR_FILE_WRITE_FAILURE); + return; + } free(dirname); free(cmd); /* setup the link points */ diff --git a/orte/mca/iof/base/iof_base_setup.c b/orte/mca/iof/base/iof_base_setup.c index 01fda216c9..1c3616078f 100644 --- a/orte/mca/iof/base/iof_base_setup.c +++ b/orte/mca/iof/base/iof_base_setup.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -64,6 +64,7 @@ #include "opal/util/os_dirpath.h" #include "opal/util/output.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "orte/mca/errmgr/errmgr.h" #include "orte/util/name_fns.h" @@ -224,7 +225,7 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env) if (!orte_map_stddiag_to_stderr && !orte_map_stddiag_to_stdout ) { /* Set an environment variable that the new child process can use to get the fd of the pipe connected to the INTERNAL IOF tag. */ - asprintf(&str, "%d", opts->p_internal[1]); + opal_asprintf(&str, "%d", opts->p_internal[1]); if (NULL != str) { opal_setenv("OPAL_OUTPUT_STDERR_FD", str, true, env); free(str); @@ -318,11 +319,11 @@ int orte_iof_base_setup_output_files(const orte_process_name_t* dst_name, /* construct the directory where the output files will go */ if (usejobid) { - asprintf(&outdir, "%s/%d/rank.%0*lu", dirname, + opal_asprintf(&outdir, "%s/%d/rank.%0*lu", dirname, (int)ORTE_LOCAL_JOBID(proct->name.jobid), numdigs, (unsigned long)proct->name.vpid); } else { - asprintf(&outdir, "%s/rank.%0*lu", dirname, + opal_asprintf(&outdir, "%s/rank.%0*lu", dirname, numdigs, (unsigned long)proct->name.vpid); } /* ensure the directory exists */ @@ -333,7 +334,7 @@ int orte_iof_base_setup_output_files(const orte_process_name_t* dst_name, } if (NULL != proct->revstdout && NULL == proct->revstdout->sink) { /* setup the stdout sink */ - asprintf(&outfile, "%s/stdout", outdir); + opal_asprintf(&outfile, "%s/stdout", outdir); fdout = open(outfile, O_CREAT|O_RDWR|O_TRUNC, 0644); free(outfile); if (fdout < 0) { @@ -357,7 +358,7 @@ int orte_iof_base_setup_output_files(const orte_process_name_t* dst_name, proct->revstdout->sink->tag = ORTE_IOF_STDMERGE; // show that it is merged proct->revstderr->sink = proct->revstdout->sink; } else { - asprintf(&outfile, "%s/stderr", outdir); + opal_asprintf(&outfile, "%s/stderr", outdir); fdout = open(outfile, O_CREAT|O_RDWR|O_TRUNC, 0644); free(outfile); if (fdout < 0) { diff --git a/orte/mca/odls/base/odls_base_default_fns.c b/orte/mca/odls/base/odls_base_default_fns.c index 60f1a033e1..75d524ae43 100644 --- a/orte/mca/odls/base/odls_base_default_fns.c +++ b/orte/mca/odls/base/odls_base_default_fns.c @@ -51,6 +51,7 @@ #include "opal/util/os_dirpath.h" #include "opal/util/os_path.h" #include "opal/util/path.h" +#include "opal/util/printf.h" #include "opal/util/sys_limits.h" #include "opal/dss/dss.h" #include "opal/mca/hwloc/hwloc-internal.h" @@ -436,7 +437,7 @@ int orte_odls_base_default_get_add_procs_data(opal_buffer_t *buffer, kv = OBJ_NEW(opal_value_t); kv->key = strdup(OPAL_PMIX_ALLOC_NETWORK_ID); kv->type = OPAL_STRING; - asprintf(&kv->data.string, "%s.net", ORTE_JOBID_PRINT(jdata->jobid)); + opal_asprintf(&kv->data.string, "%s.net", ORTE_JOBID_PRINT(jdata->jobid)); opal_list_append(&ilist, &kv->super); /* ask for security keys */ kv = OBJ_NEW(opal_value_t); @@ -881,7 +882,9 @@ static int setup_path(orte_app_context_t *app, char **wdir) * again not match getcwd! This is beyond our control - we are only * ensuring they start out matching. */ - getcwd(dir, sizeof(dir)); + if (NULL == getcwd(dir, sizeof(dir))) { + return ORTE_ERR_OUT_OF_RESOURCE; + } *wdir = strdup(dir); opal_setenv("PWD", dir, true, &app->env); /* update the initial wdir value too */ @@ -1007,7 +1010,7 @@ void orte_odls_base_spawn_proc(int fd, short sd, void *cbdata) cd->argv = opal_argv_copy(orte_odls_globals.xtermcmd); /* insert the rank into the correct place as a window title */ free(cd->argv[2]); - asprintf(&cd->argv[2], "Rank %s", ORTE_VPID_PRINT(child->name.vpid)); + opal_asprintf(&cd->argv[2], "Rank %s", ORTE_VPID_PRINT(child->name.vpid)); /* add in the argv from the app */ for (i=0; NULL != app->argv[i]; i++) { opal_argv_append_nosize(&cd->argv, app->argv[i]); @@ -1053,7 +1056,7 @@ void orte_odls_base_spawn_proc(int fd, short sd, void *cbdata) /* if we are indexing the argv by rank, do so now */ if (cd->index_argv && !ORTE_FLAG_TEST(jobdat, ORTE_JOB_FLAG_DEBUGGER_DAEMON)) { char *param; - asprintf(¶m, "%s-%d", cd->argv[0], (int)child->name.vpid); + opal_asprintf(¶m, "%s-%d", cd->argv[0], (int)child->name.vpid); free(cd->argv[0]); cd->argv[0] = param; } @@ -1116,7 +1119,10 @@ void orte_odls_base_default_launch_local(int fd, short sd, void *cbdata) * bouncing around as we execute various apps, but we will always return * to this place as our default directory */ - getcwd(basedir, sizeof(basedir)); + if (NULL == getcwd(basedir, sizeof(basedir))) { + ORTE_ACTIVATE_JOB_STATE(NULL, ORTE_JOB_STATE_FAILED_TO_LAUNCH); + goto ERROR_OUT; + } /* find the jobdat for this job */ if (NULL == (jobdat = orte_get_job_data_object(job))) { ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND); @@ -1304,9 +1310,9 @@ void orte_odls_base_default_launch_local(int fd, short sd, void *cbdata) if (NULL != mpiexec_pathenv) { argvptr = NULL; if (pathenv != NULL) { - asprintf(&full_search, "%s:%s", mpiexec_pathenv, pathenv); + opal_asprintf(&full_search, "%s:%s", mpiexec_pathenv, pathenv); } else { - asprintf(&full_search, "%s", mpiexec_pathenv); + opal_asprintf(&full_search, "%s", mpiexec_pathenv); } opal_setenv("PATH", full_search, true, &argvptr); free(full_search); @@ -1364,7 +1370,10 @@ void orte_odls_base_default_launch_local(int fd, short sd, void *cbdata) * each app was located relative to the prior app, instead of relative * to their current location */ - chdir(basedir); + if (0 != chdir(basedir)) { + ORTE_ACTIVATE_PROC_STATE(&child->name, ORTE_PROC_STATE_FAILED_TO_LAUNCH); + goto GETOUT; + } /* okay, now let's launch all the local procs for this app using the provided fork_local fn */ for (idx=0; idx < orte_local_children->size; idx++) { @@ -1490,7 +1499,9 @@ void orte_odls_base_default_launch_local(int fd, short sd, void *cbdata) ERROR_OUT: /* ensure we reset our working directory back to our default location */ - chdir(basedir); + if (0 != chdir(basedir)) { + ORTE_ERROR_LOG(ORTE_ERROR); + } /* release the event */ OBJ_RELEASE(caddy); } @@ -2066,7 +2077,9 @@ int orte_odls_base_default_restart_proc(orte_proc_t *child, * bouncing around as we execute this app, but we will always return * to this place as our default directory */ - getcwd(basedir, sizeof(basedir)); + if (NULL == getcwd(basedir, sizeof(basedir))) { + return ORTE_ERR_OUT_OF_RESOURCE; + } /* find this child's jobdat */ if (NULL == (jobdat = orte_get_job_data_object(child->name.jobid))) { @@ -2168,7 +2181,9 @@ int orte_odls_base_default_restart_proc(orte_proc_t *child, * each app was located relative to the prior app, instead of relative * to their current location */ - chdir(basedir); + if (0 != chdir(basedir)) { + ORTE_ERROR_LOG(ORTE_ERROR); + } return rc; } diff --git a/orte/mca/odls/base/odls_base_frame.c b/orte/mca/odls/base/odls_base_frame.c index f4beb709b1..8114210c2b 100644 --- a/orte/mca/odls/base/odls_base_frame.c +++ b/orte/mca/odls/base/odls_base_frame.c @@ -15,7 +15,7 @@ * All rights reserved. * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2017 Intel, Inc. All rights reserved. + * Copyright (c) 2017-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -37,6 +37,7 @@ #include "opal/util/output.h" #include "opal/util/path.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "orte/mca/errmgr/errmgr.h" #include "orte/mca/ess/ess.h" @@ -179,7 +180,7 @@ void orte_odls_base_start_threads(orte_job_t *jdata) orte_odls_globals.ev_bases = (opal_event_base_t**)malloc(orte_odls_globals.num_threads * sizeof(opal_event_base_t*)); for (i=0; i < orte_odls_globals.num_threads; i++) { - asprintf(&tmp, "ORTE-ODLS-%d", i); + opal_asprintf(&tmp, "ORTE-ODLS-%d", i); orte_odls_globals.ev_bases[i] = opal_progress_thread_init(tmp); opal_argv_append_nosize(&orte_odls_globals.ev_threads, tmp); free(tmp); diff --git a/orte/mca/oob/alps/oob_alps_component.c b/orte/mca/oob/alps/oob_alps_component.c index ea622cf7df..48c6c0f923 100644 --- a/orte/mca/oob/alps/oob_alps_component.c +++ b/orte/mca/oob/alps/oob_alps_component.c @@ -14,7 +14,7 @@ * All rights reserved. * Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014 NVIDIA Corporation. All rights reserved. * $COPYRIGHT$ * @@ -202,7 +202,7 @@ static char* component_get_addr(void) gethostname(hn, sizeof(hn)); - asprintf(&cptr, "gni://%s:%d", hn, getpid()); + opal_asprintf(&cptr, "gni://%s:%d", hn, getpid()); opal_output_verbose(10, orte_oob_base_framework.framework_output, "%s oob:alps: component_get_addr invoked - %s", diff --git a/orte/mca/oob/base/base.h b/orte/mca/oob/base/base.h index 7dfe4b0adf..830a05ad33 100644 --- a/orte/mca/oob/base/base.h +++ b/orte/mca/oob/base/base.h @@ -11,7 +11,7 @@ * All rights reserved. * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2017 Intel, Inc. All rights reserved. + * Copyright (c) 2017-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -41,6 +41,7 @@ #include "opal/class/opal_bitmap.h" #include "opal/class/opal_hash_table.h" #include "opal/class/opal_list.h" +#include "opal/util/printf.h" #include "opal/util/timings.h" #include "opal/mca/event/event.h" diff --git a/orte/mca/oob/base/oob_base_stubs.c b/orte/mca/oob/base/oob_base_stubs.c index 3addceb657..03da3c815e 100644 --- a/orte/mca/oob/base/oob_base_stubs.c +++ b/orte/mca/oob/base/oob_base_stubs.c @@ -2,7 +2,7 @@ /* * Copyright (c) 2012-2014 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -17,6 +17,7 @@ #include "opal/util/output.h" #include "opal/mca/pmix/pmix.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "orte/mca/errmgr/errmgr.h" #include "orte/mca/state/state.h" @@ -263,7 +264,7 @@ void orte_oob_base_get_addr(char **uri) continue; } /* add new value to final one */ - asprintf(&tmp, "%s;%s", final, turi); + opal_asprintf(&tmp, "%s;%s", final, turi); free(turi); free(final); final = tmp; diff --git a/orte/mca/oob/tcp/oob_tcp_component.c b/orte/mca/oob/tcp/oob_tcp_component.c index 2843ce9cd3..d7e1f5f9b2 100644 --- a/orte/mca/oob/tcp/oob_tcp_component.c +++ b/orte/mca/oob/tcp/oob_tcp_component.c @@ -14,7 +14,7 @@ * reserved. * Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014 NVIDIA Corporation. All rights reserved. * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -680,7 +680,7 @@ static int component_startup(void) opal_pointer_array_add(&mca_oob_tcp_component.ev_bases, orte_oob_base.ev_base); } else { for (i=0; i < orte_oob_base.num_threads; i++) { - asprintf(&tmp, "OOB-TCP-%d", i); + opal_asprintf(&tmp, "OOB-TCP-%d", i); evb = opal_progress_thread_init(tmp); opal_pointer_array_add(&mca_oob_tcp_component.ev_bases, evb); opal_argv_append_nosize(&mca_oob_tcp_component.ev_threads, tmp); @@ -779,7 +779,7 @@ static char* component_get_addr(void) NULL != mca_oob_tcp_component.ipv4conns) { tmp = opal_argv_join(mca_oob_tcp_component.ipv4conns, ','); tp = opal_argv_join(mca_oob_tcp_component.ipv4ports, ','); - asprintf(&cptr, "tcp://%s:%s", tmp, tp); + opal_asprintf(&cptr, "tcp://%s:%s", tmp, tp); free(tmp); free(tp); } @@ -803,9 +803,9 @@ static char* component_get_addr(void) tp = opal_argv_join(mca_oob_tcp_component.ipv6ports, ','); if (NULL == cptr) { /* no ipv4 stuff */ - asprintf(&cptr, "tcp6://[%s]:%s", tmp, tp); + opal_asprintf(&cptr, "tcp6://[%s]:%s", tmp, tp); } else { - asprintf(&tmp2, "%s;tcp6://[%s]:%s", cptr, tmp, tp); + opal_asprintf(&tmp2, "%s;tcp6://[%s]:%s", cptr, tmp, tp); free(cptr); cptr = tmp2; } diff --git a/orte/mca/oob/tcp/oob_tcp_listener.c b/orte/mca/oob/tcp/oob_tcp_listener.c index e97103c07f..3ff3fde457 100644 --- a/orte/mca/oob/tcp/oob_tcp_listener.c +++ b/orte/mca/oob/tcp/oob_tcp_listener.c @@ -13,7 +13,7 @@ * All rights reserved. * Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -394,7 +394,7 @@ static int create_listen(void) } opal_list_append(&mca_oob_tcp_component.listeners, &conn->item); /* and to our ports */ - asprintf(&tconn, "%d", ntohs(((struct sockaddr_in*) &inaddr)->sin_port)); + opal_asprintf(&tconn, "%d", ntohs(((struct sockaddr_in*) &inaddr)->sin_port)); opal_argv_append_nosize(&mca_oob_tcp_component.ipv4ports, tconn); free(tconn); if (OOB_TCP_DEBUG_CONNECT <= opal_output_get_verbosity(orte_oob_base_framework.framework_output)) { @@ -635,7 +635,7 @@ static int create_listen6(void) conn->port = ntohs(((struct sockaddr_in6*) &inaddr)->sin6_port); opal_list_append(&mca_oob_tcp_component.listeners, &conn->item); /* and to our ports */ - asprintf(&tconn, "%d", ntohs(((struct sockaddr_in6*) &inaddr)->sin6_port)); + opal_asprintf(&tconn, "%d", ntohs(((struct sockaddr_in6*) &inaddr)->sin6_port)); opal_argv_append_nosize(&mca_oob_tcp_component.ipv6ports, tconn); free(tconn); if (OOB_TCP_DEBUG_CONNECT <= opal_output_get_verbosity(orte_oob_base_framework.framework_output)) { diff --git a/orte/mca/plm/alps/plm_alps_module.c b/orte/mca/plm/alps/plm_alps_module.c index 860409eca9..b6483ce820 100644 --- a/orte/mca/plm/alps/plm_alps_module.c +++ b/orte/mca/plm/alps/plm_alps_module.c @@ -13,7 +13,7 @@ * Copyright (c) 2006-2011 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -273,7 +273,7 @@ static void launch_daemons(int fd, short args, void *cbdata) /* number of processors needed */ opal_argv_append(&argc, &argv, "-n"); - asprintf(&tmp, "%lu", (unsigned long) map->num_new_daemons); + opal_asprintf(&tmp, "%lu", (unsigned long) map->num_new_daemons); opal_argv_append(&argc, &argv, tmp); free(tmp); opal_argv_append(&argc, &argv, "-N"); @@ -601,9 +601,9 @@ static int plm_alps_start_proc(int argc, char **argv, char **env, /* Reset PATH */ oldenv = getenv("PATH"); if (NULL != oldenv) { - asprintf(&newenv, "%s/%s:%s", prefix, bin_base, oldenv); + opal_asprintf(&newenv, "%s/%s:%s", prefix, bin_base, oldenv); } else { - asprintf(&newenv, "%s/%s", prefix, bin_base); + opal_asprintf(&newenv, "%s/%s", prefix, bin_base); } opal_setenv("PATH", newenv, true, &env); if (mca_plm_alps_component.debug) { @@ -614,9 +614,9 @@ static int plm_alps_start_proc(int argc, char **argv, char **env, /* Reset LD_LIBRARY_PATH */ oldenv = getenv("LD_LIBRARY_PATH"); if (NULL != oldenv) { - asprintf(&newenv, "%s/%s:%s", prefix, lib_base, oldenv); + opal_asprintf(&newenv, "%s/%s:%s", prefix, lib_base, oldenv); } else { - asprintf(&newenv, "%s/%s", prefix, lib_base); + opal_asprintf(&newenv, "%s/%s", prefix, lib_base); } opal_setenv("LD_LIBRARY_PATH", newenv, true, &env); if (mca_plm_alps_component.debug) { diff --git a/orte/mca/plm/base/base.h b/orte/mca/plm/base/base.h index b0d2faea1a..47e5e7abcc 100644 --- a/orte/mca/plm/base/base.h +++ b/orte/mca/plm/base/base.h @@ -30,6 +30,7 @@ #include "orte/mca/mca.h" #include "opal/class/opal_list.h" +#include "opal/util/printf.h" #include "orte/mca/plm/plm.h" diff --git a/orte/mca/plm/base/plm_base_launch_support.c b/orte/mca/plm/base/plm_base_launch_support.c index 5c851da5bf..413f960827 100644 --- a/orte/mca/plm/base/plm_base_launch_support.c +++ b/orte/mca/plm/base/plm_base_launch_support.c @@ -39,6 +39,7 @@ #include "opal/hash_string.h" #include "opal/util/argv.h" #include "opal/util/opal_environ.h" +#include "opal/util/printf.h" #include "opal/class/opal_pointer_array.h" #include "opal/dss/dss.h" #include "opal/mca/hwloc/hwloc-internal.h" @@ -1510,7 +1511,7 @@ int orte_plm_base_orted_append_basic_args(int *argc, char ***argv, } opal_argv_append(argc, argv, "-"OPAL_MCA_CMD_LINE_ID); opal_argv_append(argc, argv, "ess_base_num_procs"); - asprintf(¶m, "%lu", num_procs); + opal_asprintf(¶m, "%lu", num_procs); opal_argv_append(argc, argv, param); free(param); @@ -1547,7 +1548,7 @@ int orte_plm_base_orted_append_basic_args(int *argc, char ***argv, /* if requested, pass our port */ if (orte_fwd_mpirun_port) { - asprintf(¶m, "%d", orte_process_info.my_port); + opal_asprintf(¶m, "%d", orte_process_info.my_port); opal_argv_append(argc, argv, "-"OPAL_MCA_CMD_LINE_ID); opal_argv_append(argc, argv, "oob_tcp_static_ipv4_ports"); opal_argv_append(argc, argv, param); diff --git a/orte/mca/plm/rsh/plm_rsh.h b/orte/mca/plm/rsh/plm_rsh.h index c523b99c55..7cad6d1221 100644 --- a/orte/mca/plm/rsh/plm_rsh.h +++ b/orte/mca/plm/rsh/plm_rsh.h @@ -13,7 +13,7 @@ * reserved. * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2011 IBM Corporation. All rights reserved. - * Copyright (c) 2015 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -39,6 +39,7 @@ #include "orte/mca/mca.h" #include "orte/mca/plm/plm.h" +#include "orte/mca/plm/base/base.h" BEGIN_C_DECLS diff --git a/orte/mca/plm/rsh/plm_rsh_component.c b/orte/mca/plm/rsh/plm_rsh_component.c index bb87725bef..d9c19c527d 100644 --- a/orte/mca/plm/rsh/plm_rsh_component.c +++ b/orte/mca/plm/rsh/plm_rsh_component.c @@ -17,7 +17,7 @@ * reserved. * Copyright (c) 2009-2016 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 IBM Corporation. All rights reserved. - * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -280,7 +280,7 @@ static int rsh_component_query(mca_base_module_t **module, int *priority) NULL != getenv("SGE_ROOT") && NULL != getenv("ARC") && NULL != getenv("PE_HOSTFILE") && NULL != getenv("JOB_ID")) { /* setup the search path for qrsh */ - asprintf(&tmp, "%s/bin/%s", getenv("SGE_ROOT"), getenv("ARC")); + opal_asprintf(&tmp, "%s/bin/%s", getenv("SGE_ROOT"), getenv("ARC")); /* see if the agent is available */ if (ORTE_SUCCESS != rsh_launch_agent_lookup("qrsh", tmp)) { /* can't be SGE */ diff --git a/orte/mca/plm/rsh/plm_rsh_module.c b/orte/mca/plm/rsh/plm_rsh_module.c index 7e34de9ecf..d913dab6de 100644 --- a/orte/mca/plm/rsh/plm_rsh_module.c +++ b/orte/mca/plm/rsh/plm_rsh_module.c @@ -194,7 +194,7 @@ static int rsh_init(void) /* we were selected, so setup the launch agent */ if (mca_plm_rsh_component.using_qrsh) { /* perform base setup for qrsh */ - asprintf(&tmp, "%s/bin/%s", getenv("SGE_ROOT"), getenv("ARC")); + opal_asprintf(&tmp, "%s/bin/%s", getenv("SGE_ROOT"), getenv("ARC")); if (ORTE_SUCCESS != (rc = launch_agent_setup("qrsh", tmp))) { ORTE_ERROR_LOG(rc); free(tmp); @@ -454,12 +454,12 @@ static int setup_launch(int *argcptr, char ***argvptr, param = opal_basename(opal_install_dirs.libdir); if (NULL != mca_plm_rsh_component.pass_libpath) { if (NULL != prefix_dir) { - asprintf(&lib_base, "%s:%s/%s", mca_plm_rsh_component.pass_libpath, prefix_dir, param); + opal_asprintf(&lib_base, "%s:%s/%s", mca_plm_rsh_component.pass_libpath, prefix_dir, param); } else { - asprintf(&lib_base, "%s:%s", mca_plm_rsh_component.pass_libpath, param); + opal_asprintf(&lib_base, "%s:%s", mca_plm_rsh_component.pass_libpath, param); } } else if (NULL != prefix_dir) { - asprintf(&lib_base, "%s/%s", prefix_dir, param); + opal_asprintf(&lib_base, "%s/%s", prefix_dir, param); } free(param); @@ -473,13 +473,13 @@ static int setup_launch(int *argcptr, char ***argvptr, */ value = opal_basename(opal_install_dirs.bindir); - asprintf(&bin_base, "%s/%s", prefix_dir, value); + opal_asprintf(&bin_base, "%s/%s", prefix_dir, value); free(value); if (NULL != orted_cmd) { if (0 == strcmp(orted_cmd, "orted")) { /* if the cmd is our standard one, then add the prefix */ - (void)asprintf(&full_orted_cmd, "%s/%s", bin_base, orted_cmd); + opal_asprintf(&full_orted_cmd, "%s/%s", bin_base, orted_cmd); } else { /* someone specified something different, so don't prefix it */ full_orted_cmd = strdup(orted_cmd); @@ -499,7 +499,7 @@ static int setup_launch(int *argcptr, char ***argvptr, * assemble the cmd with the orted_cmd at the end. Otherwise, * we have to insert the orted_prefix in the right place */ - (void)asprintf (&final_cmd, + opal_asprintf (&final_cmd, "%s%s%s PATH=%s%s$PATH ; export PATH ; " "LD_LIBRARY_PATH=%s%s$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH ; " "DYLD_LIBRARY_PATH=%s%s$DYLD_LIBRARY_PATH ; export DYLD_LIBRARY_PATH ; " @@ -529,7 +529,7 @@ static int setup_launch(int *argcptr, char ***argvptr, * assemble the cmd with the orted_cmd at the end. Otherwise, * we have to insert the orted_prefix in the right place */ - (void)asprintf (&final_cmd, + opal_asprintf (&final_cmd, "%s%s%s set path = ( %s $path ) ; " "if ( $?LD_LIBRARY_PATH == 1 ) " "set OMPI_have_llp ; " @@ -581,7 +581,7 @@ static int setup_launch(int *argcptr, char ***argvptr, } } else { /* no prefix directory, so just aggregate the result */ - (void)asprintf(&final_cmd, "%s %s", + opal_asprintf(&final_cmd, "%s %s", (orted_prefix != NULL ? orted_prefix : ""), (full_orted_cmd != NULL ? full_orted_cmd : "")); if (NULL != full_orted_cmd) { @@ -1245,7 +1245,7 @@ static void launch_daemons(int fd, short args, void *cbdata) free(argv[node_name_index1]); username = NULL; if (orte_get_attribute(&node->attributes, ORTE_NODE_USERNAME, (void**)&username, OPAL_STRING)) { - (void)asprintf (&argv[node_name_index1], "%s@%s", + opal_asprintf (&argv[node_name_index1], "%s@%s", username, node->name); free(username); } else { diff --git a/orte/mca/plm/slurm/plm_slurm_module.c b/orte/mca/plm/slurm/plm_slurm_module.c index 568d2c4026..20cd74b975 100644 --- a/orte/mca/plm/slurm/plm_slurm_module.c +++ b/orte/mca/plm/slurm/plm_slurm_module.c @@ -12,7 +12,7 @@ * Copyright (c) 2006-2018 Cisco Systems, Inc. All rights reserved * Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -249,7 +249,7 @@ static void launch_daemons(int fd, short args, void *cbdata) } /* need integer value for command line parameter */ - asprintf(&jobid_string, "%lu", (unsigned long) daemons->jobid); + opal_asprintf(&jobid_string, "%lu", (unsigned long) daemons->jobid); /* * start building argv array @@ -333,17 +333,17 @@ static void launch_daemons(int fd, short args, void *cbdata) * require any further arguments */ if (map->num_new_daemons < orte_num_allocated_nodes) { - asprintf(&tmp, "--nodes=%lu", (unsigned long)map->num_new_daemons); + opal_asprintf(&tmp, "--nodes=%lu", (unsigned long)map->num_new_daemons); opal_argv_append(&argc, &argv, tmp); free(tmp); - asprintf(&tmp, "--nodelist=%s", nodelist_flat); + opal_asprintf(&tmp, "--nodelist=%s", nodelist_flat); opal_argv_append(&argc, &argv, tmp); free(tmp); } /* tell srun how many tasks to run */ - asprintf(&tmp, "--ntasks=%lu", (unsigned long)map->num_new_daemons); + opal_asprintf(&tmp, "--ntasks=%lu", (unsigned long)map->num_new_daemons); opal_argv_append(&argc, &argv, tmp); free(tmp); @@ -637,9 +637,9 @@ static int plm_slurm_start_proc(int argc, char **argv, char **env, /* Reset PATH */ oldenv = getenv("PATH"); if (NULL != oldenv) { - asprintf(&newenv, "%s/%s:%s", prefix, bin_base, oldenv); + opal_asprintf(&newenv, "%s/%s:%s", prefix, bin_base, oldenv); } else { - asprintf(&newenv, "%s/%s", prefix, bin_base); + opal_asprintf(&newenv, "%s/%s", prefix, bin_base); } opal_setenv("PATH", newenv, true, &env); OPAL_OUTPUT_VERBOSE((1, orte_plm_base_framework.framework_output, @@ -651,9 +651,9 @@ static int plm_slurm_start_proc(int argc, char **argv, char **env, /* Reset LD_LIBRARY_PATH */ oldenv = getenv("LD_LIBRARY_PATH"); if (NULL != oldenv) { - asprintf(&newenv, "%s/%s:%s", prefix, lib_base, oldenv); + opal_asprintf(&newenv, "%s/%s:%s", prefix, lib_base, oldenv); } else { - asprintf(&newenv, "%s/%s", prefix, lib_base); + opal_asprintf(&newenv, "%s/%s", prefix, lib_base); } opal_setenv("LD_LIBRARY_PATH", newenv, true, &env); OPAL_OUTPUT_VERBOSE((1, orte_plm_base_framework.framework_output, diff --git a/orte/mca/plm/tm/plm_tm_module.c b/orte/mca/plm/tm/plm_tm_module.c index c3ec16d8a6..a16ec3a5ac 100644 --- a/orte/mca/plm/tm/plm_tm_module.c +++ b/orte/mca/plm/tm/plm_tm_module.c @@ -12,7 +12,7 @@ * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007-2012 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -298,7 +298,7 @@ static void launch_daemons(int fd, short args, void *cbdata) /* add our umask -- see big note in orted.c */ current_umask = umask(0); umask(current_umask); - (void)asprintf(&var, "0%o", current_umask); + opal_asprintf(&var, "0%o", current_umask); opal_setenv("ORTE_DAEMON_UMASK_VALUE", var, true, &env); free(var); @@ -316,7 +316,7 @@ static void launch_daemons(int fd, short args, void *cbdata) for (i = 0; NULL != env && NULL != env[i]; ++i) { /* Reset PATH */ if (0 == strncmp("PATH=", env[i], 5)) { - (void)asprintf(&newenv, "%s/%s:%s", + opal_asprintf(&newenv, "%s/%s:%s", prefix_dir, bin_base, env[i] + 5); OPAL_OUTPUT_VERBOSE((1, orte_plm_base_framework.framework_output, "%s plm:tm: resetting PATH: %s", @@ -328,7 +328,7 @@ static void launch_daemons(int fd, short args, void *cbdata) /* Reset LD_LIBRARY_PATH */ else if (0 == strncmp("LD_LIBRARY_PATH=", env[i], 16)) { - (void)asprintf(&newenv, "%s/%s:%s", + opal_asprintf(&newenv, "%s/%s:%s", prefix_dir, lib_base, env[i] + 16); OPAL_OUTPUT_VERBOSE((1, orte_plm_base_framework.framework_output, "%s plm:tm: resetting LD_LIBRARY_PATH: %s", diff --git a/orte/mca/ras/alps/ras_alps_component.c b/orte/mca/ras/alps/ras_alps_component.c index 2bf719c80e..37f9f15b59 100644 --- a/orte/mca/ras/alps/ras_alps_component.c +++ b/orte/mca/ras/alps/ras_alps_component.c @@ -13,6 +13,7 @@ * Copyright (c) 2008 UT-Battelle, LLC * Copyright (c) 2011-2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -111,7 +112,7 @@ get_res_id(void) return 0; } - ret = asprintf (&apstat_cmd, "%s -r", ras_alps_apstat_cmd); + ret = opal_asprintf (&apstat_cmd, "%s -r", ras_alps_apstat_cmd); if (0 > ret) { return 0; } diff --git a/orte/mca/ras/alps/ras_alps_module.c b/orte/mca/ras/alps/ras_alps_module.c index a8273dfd3c..c1a7cd487d 100644 --- a/orte/mca/ras/alps/ras_alps_module.c +++ b/orte/mca/ras/alps/ras_alps_module.c @@ -13,7 +13,7 @@ * Copyright (c) 2008 UT-Battelle, LLC. All rights reserved. * Copyright (c) 2011-2014 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -144,7 +144,7 @@ parser_ini(char **val_if_found, FILE *fp, const char *var_name) return ORTE_ERR_FILE_OPEN_FAILURE; } /* Success! */ - asprintf(val_if_found, "%s/appinfo", cpq); + opal_asprintf(val_if_found, "%s/appinfo", cpq); if (NULL == val_if_found) { free(alps_config_str); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); @@ -211,7 +211,7 @@ parser_separated_columns(char **val_if_found, FILE *fp, const char *var_name) return ORTE_ERR_FILE_OPEN_FAILURE; } /* Success! */ - asprintf(val_if_found, "%s/appinfo", cpq); + opal_asprintf(val_if_found, "%s/appinfo", cpq); if (NULL == val_if_found) { free(alps_config_str); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); @@ -508,7 +508,7 @@ orte_ras_alps_read_appinfo_file(opal_list_t *nodes, char *filename, opal_output_verbose(5, orte_ras_base_framework.framework_output, "ras:alps:read_appinfo: got NID %d", apSlots[ix].nid); - asprintf( &hostname, "%d", apSlots[ix].nid ); + opal_asprintf( &hostname, "%d", apSlots[ix].nid ); if (NULL == hostname) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); return ORTE_ERR_OUT_OF_RESOURCE; @@ -555,7 +555,7 @@ orte_ras_alps_read_appinfo_file(opal_list_t *nodes, char *filename, opal_output_verbose(5, orte_ras_base_framework.framework_output, "ras:alps:read_appinfo(modern): processing NID %d with %d slots", apNodes[ix].nid, apNodes[ix].numPEs); - asprintf( &hostname, "%d", apNodes[ix].nid ); + opal_asprintf( &hostname, "%d", apNodes[ix].nid ); if (NULL == hostname) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); return ORTE_ERR_OUT_OF_RESOURCE; diff --git a/orte/mca/ras/base/base.h b/orte/mca/ras/base/base.h index f9b1bc868b..7ad61346e1 100644 --- a/orte/mca/ras/base/base.h +++ b/orte/mca/ras/base/base.h @@ -11,7 +11,7 @@ * All rights reserved. * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2016 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,6 +29,8 @@ */ #include "orte_config.h" +#include "opal/util/printf.h" + #include "orte/mca/ras/ras.h" /* * Global functions for MCA overall collective open and close diff --git a/orte/mca/ras/base/ras_base_allocate.c b/orte/mca/ras/base/ras_base_allocate.c index e7b988adbb..ac71b17090 100644 --- a/orte/mca/ras/base/ras_base_allocate.c +++ b/orte/mca/ras/base/ras_base_allocate.c @@ -32,6 +32,7 @@ #include "opal/mca/base/base.h" #include "opal/class/opal_list.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal/dss/dss.h" #include "opal/util/argv.h" #include "opal/mca/if/if.h" @@ -61,9 +62,9 @@ void orte_ras_base_display_alloc(void) orte_node_t *alloc; if (orte_xml_output) { - asprintf(&tmp, "\n"); + opal_asprintf(&tmp, "\n"); } else { - asprintf(&tmp, "\n====================== ALLOCATED NODES ======================\n"); + opal_asprintf(&tmp, "\n====================== ALLOCATED NODES ======================\n"); } if (orte_hnp_is_allocated) { istart = 0; @@ -76,11 +77,11 @@ void orte_ras_base_display_alloc(void) } if (orte_xml_output) { /* need to create the output in XML format */ - asprintf(&tmp2, "\t\n", + opal_asprintf(&tmp2, "\t\n", (NULL == alloc->name) ? "UNKNOWN" : alloc->name, (int)alloc->slots, (int)alloc->slots_max, (int)alloc->slots_inuse); } else { - asprintf(&tmp2, "\t%s: flags=0x%02x slots=%d max_slots=%d slots_inuse=%d state=%s\n", + opal_asprintf(&tmp2, "\t%s: flags=0x%02x slots=%d max_slots=%d slots_inuse=%d state=%s\n", (NULL == alloc->name) ? "UNKNOWN" : alloc->name, alloc->flags, (int)alloc->slots, (int)alloc->slots_max, (int)alloc->slots_inuse, orte_node_state_to_str(alloc->state)); @@ -88,7 +89,7 @@ void orte_ras_base_display_alloc(void) if (NULL == tmp) { tmp = tmp2; } else { - asprintf(&tmp3, "%s%s", tmp, tmp2); + opal_asprintf(&tmp3, "%s%s", tmp, tmp2); free(tmp); free(tmp2); tmp = tmp3; diff --git a/orte/mca/ras/simulator/ras_sim_module.c b/orte/mca/ras/simulator/ras_sim_module.c index f12a3b4275..5badc9278f 100644 --- a/orte/mca/ras/simulator/ras_sim_module.c +++ b/orte/mca/ras/simulator/ras_sim_module.c @@ -249,7 +249,7 @@ static int allocate(orte_job_t *jdata, opal_list_t *nodes) for (i=0; i < num_nodes; i++) { node = OBJ_NEW(orte_node_t); - asprintf(&node->name, "%s%0*d", prefix, dig, i); + opal_asprintf(&node->name, "%s%0*d", prefix, dig, i); node->state = ORTE_NODE_STATE_UP; node->slots_inuse = 0; if (NULL == max_slot_cnt || NULL == max_slot_cnt[n]) { diff --git a/orte/mca/ras/slurm/ras_slurm_module.c b/orte/mca/ras/slurm/ras_slurm_module.c index 474d6e292d..dcb4b5478b 100644 --- a/orte/mca/ras/slurm/ras_slurm_module.c +++ b/orte/mca/ras/slurm/ras_slurm_module.c @@ -13,7 +13,7 @@ * Copyright (c) 2011-2017 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2013-2014 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. @@ -257,7 +257,7 @@ static int orte_ras_slurm_allocate(orte_job_t *jdata, opal_list_t *nodes) /* save this value in the global job ident string for * later use in any error reporting */ - orte_job_ident = strdup(slurm_jobid); + orte_job_ident = strdup(slurm_jobid); } slurm_node_str = getenv("SLURM_NODELIST"); @@ -1017,7 +1017,7 @@ static int dyn_allocate(orte_job_t *jdata) opal_argv_append_nosize(&cmd, "allocate"); /* add the jobid */ orte_util_convert_jobid_to_string(&jstring, jdata->jobid); - asprintf(&tmp, "jobid=%s", jstring); + opal_asprintf(&tmp, "jobid=%s", jstring); opal_argv_append_nosize(&cmd, tmp); free(tmp); free(jstring); @@ -1036,7 +1036,7 @@ static int dyn_allocate(orte_job_t *jdata) #endif /* pass the timeout */ - asprintf(&tmp, "timeout=%d", mca_ras_slurm_component.timeout); + opal_asprintf(&tmp, "timeout=%d", mca_ras_slurm_component.timeout); opal_argv_append_nosize(&cmd, tmp); free(tmp); @@ -1047,16 +1047,16 @@ static int dyn_allocate(orte_job_t *jdata) continue; } /* add the app id, preceded by a colon separator */ - asprintf(&tmp, ": app=%d", (int)app->idx); + opal_asprintf(&tmp, ": app=%d", (int)app->idx); opal_argv_append_nosize(&cmd, tmp); free(tmp); /* add the number of process "slots" we need */ - asprintf(&tmp, "np=%d", app->num_procs); + opal_asprintf(&tmp, "np=%d", app->num_procs); opal_argv_append_nosize(&cmd, tmp); free(tmp); /* if we were given a minimum number of nodes, pass it along */ if (orte_get_attribute(&app->attributes, ORTE_APP_MIN_NODES, (void**)&i64ptr, OPAL_INT64)) { - asprintf(&tmp, "N=%ld", (long int)i64); + opal_asprintf(&tmp, "N=%ld", (long int)i64); opal_argv_append_nosize(&cmd, tmp); free(tmp); } @@ -1065,7 +1065,7 @@ static int dyn_allocate(orte_job_t *jdata) */ node_list = get_node_list(app); if (NULL != node_list) { - asprintf(&tmp, "node_list=%s", node_list); + opal_asprintf(&tmp, "node_list=%s", node_list); opal_argv_append_nosize(&cmd, tmp); free(node_list); free(tmp); @@ -1192,7 +1192,7 @@ static int read_ip_port(char *filename, char **ip, uint16_t *port) memset(line, 0, ORTE_SLURM_DYN_MAX_SIZE); while (NULL != fgets(line, ORTE_SLURM_DYN_MAX_SIZE, fp) && - (!found_ip || !found_port)) { + (!found_ip || !found_port)) { if (0 == strlen(line)) { continue; } diff --git a/orte/mca/regx/base/regx_base_default_fns.c b/orte/mca/regx/base/regx_base_default_fns.c index 6b70f78cad..54684a01e2 100644 --- a/orte/mca/regx/base/regx_base_default_fns.c +++ b/orte/mca/regx/base/regx_base_default_fns.c @@ -22,6 +22,7 @@ #include "opal/util/argv.h" #include "opal/util/basename.h" #include "opal/util/opal_environ.h" +#include "opal/util/printf.h" #include "orte/runtime/orte_globals.h" #include "orte/util/name_fns.h" @@ -365,9 +366,9 @@ int orte_regx_base_encode_nodemap(opal_buffer_t *buffer) while (NULL != (item = opal_list_remove_first(&slots))) { rng = (orte_regex_range_t*)item; if (NULL == tmp) { - asprintf(&tmp, "%d[%d]", rng->cnt, rng->slots); + opal_asprintf(&tmp, "%d[%d]", rng->cnt, rng->slots); } else { - asprintf(&tmp2, "%s,%d[%d]", tmp, rng->cnt, rng->slots); + opal_asprintf(&tmp2, "%s,%d[%d]", tmp, rng->cnt, rng->slots); free(tmp); tmp = tmp2; } @@ -391,9 +392,9 @@ int orte_regx_base_encode_nodemap(opal_buffer_t *buffer) while (NULL != (item = opal_list_remove_first(&flags))) { rng = (orte_regex_range_t*)item; if (NULL == tmp) { - asprintf(&tmp, "%d[%d]", rng->cnt, rng->slots); + opal_asprintf(&tmp, "%d[%d]", rng->cnt, rng->slots); } else { - asprintf(&tmp2, "%s,%d[%d]", tmp, rng->cnt, rng->slots); + opal_asprintf(&tmp2, "%s,%d[%d]", tmp, rng->cnt, rng->slots); free(tmp); tmp = tmp2; } @@ -440,9 +441,9 @@ int orte_regx_base_encode_nodemap(opal_buffer_t *buffer) ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), (NULL == rng->t) ? "NULL" : rng->t->sig, rng->cnt); if (NULL == tmp) { - asprintf(&tmp, "%d", rng->cnt); + opal_asprintf(&tmp, "%d", rng->cnt); } else { - asprintf(&tmp2, "%s,%d", tmp, rng->cnt); + opal_asprintf(&tmp2, "%s,%d", tmp, rng->cnt); free(tmp); tmp = tmp2; } @@ -845,17 +846,17 @@ int orte_regx_base_generate_ppn(orte_job_t *jdata, char **ppn) OPAL_LIST_FOREACH(prng, &prk[n], orte_nidmap_regex_t) { if (1 < prng->cnt) { if (NULL == ptmp) { - asprintf(&ptmp, "%u(%u)", prng->nprocs, prng->cnt); + opal_asprintf(&ptmp, "%u(%u)", prng->nprocs, prng->cnt); } else { - asprintf(&tmp2, "%s,%u(%u)", ptmp, prng->nprocs, prng->cnt); + opal_asprintf(&tmp2, "%s,%u(%u)", ptmp, prng->nprocs, prng->cnt); free(ptmp); ptmp = tmp2; } } else { if (NULL == ptmp) { - asprintf(&ptmp, "%u", prng->nprocs); + opal_asprintf(&ptmp, "%u", prng->nprocs); } else { - asprintf(&tmp2, "%s,%u", ptmp, prng->nprocs); + opal_asprintf(&tmp2, "%s,%u", ptmp, prng->nprocs); free(ptmp); ptmp = tmp2; } diff --git a/orte/mca/regx/fwd/regx_fwd.c b/orte/mca/regx/fwd/regx_fwd.c index 893b96e0ae..68a2652e94 100644 --- a/orte/mca/regx/fwd/regx_fwd.c +++ b/orte/mca/regx/fwd/regx_fwd.c @@ -239,7 +239,7 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) if (0 == opal_list_get_size(&ndreg->ranges)) { if (NULL != ndreg->prefix) { /* solitary node */ - asprintf(&tmp, "%s", ndreg->prefix); + opal_asprintf(&tmp, "%s", ndreg->prefix); opal_argv_append_nosize(®exargs, tmp); free(tmp); } @@ -248,17 +248,17 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) } /* start the regex for this nodeid with the prefix */ if (NULL != ndreg->prefix) { - asprintf(&tmp, "%s[%d:", ndreg->prefix, ndreg->num_digits); + opal_asprintf(&tmp, "%s[%d:", ndreg->prefix, ndreg->num_digits); } else { - asprintf(&tmp, "[%d:", ndreg->num_digits); + opal_asprintf(&tmp, "[%d:", ndreg->num_digits); } /* add the ranges */ while (NULL != (itm2 = opal_list_remove_first(&ndreg->ranges))) { range = (orte_regex_range_t*)itm2; if (1 == range->cnt) { - asprintf(&tmp2, "%s%u,", tmp, range->vpid); + opal_asprintf(&tmp2, "%s%u,", tmp, range->vpid); } else { - asprintf(&tmp2, "%s%u-%u,", tmp, range->vpid, range->vpid + range->cnt - 1); + opal_asprintf(&tmp2, "%s%u-%u,", tmp, range->vpid, range->vpid + range->cnt - 1); } free(tmp); tmp = tmp2; @@ -268,7 +268,7 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) tmp[strlen(tmp)-1] = ']'; if (NULL != ndreg->suffix) { /* add in the suffix, if provided */ - asprintf(&tmp2, "%s%s", tmp, ndreg->suffix); + opal_asprintf(&tmp2, "%s%s", tmp, ndreg->suffix); free(tmp); tmp = tmp2; } @@ -289,17 +289,17 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) rng = (orte_regex_range_t*)item; if (1 < rng->cnt) { if (NULL == tmp) { - asprintf(&tmp, "%u(%u)", rng->vpid, rng->cnt); + opal_asprintf(&tmp, "%u(%u)", rng->vpid, rng->cnt); } else { - asprintf(&tmp2, "%s,%u(%u)", tmp, rng->vpid, rng->cnt); + opal_asprintf(&tmp2, "%s,%u(%u)", tmp, rng->vpid, rng->cnt); free(tmp); tmp = tmp2; } } else { if (NULL == tmp) { - asprintf(&tmp, "%u", rng->vpid); + opal_asprintf(&tmp, "%u", rng->vpid); } else { - asprintf(&tmp2, "%s,%u", tmp, rng->vpid); + opal_asprintf(&tmp2, "%s,%u", tmp, rng->vpid); free(tmp); tmp = tmp2; } @@ -309,7 +309,7 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) OPAL_LIST_DESTRUCT(&dvpids); /* now concatenate the results into one string */ - asprintf(&tmp2, "%s@%s", nodenames, tmp); + opal_asprintf(&tmp2, "%s@%s", nodenames, tmp); free(nodenames); free(tmp); *regex = tmp2; diff --git a/orte/mca/regx/reverse/regx_reverse.c b/orte/mca/regx/reverse/regx_reverse.c index b94a9be353..c444effc0f 100644 --- a/orte/mca/regx/reverse/regx_reverse.c +++ b/orte/mca/regx/reverse/regx_reverse.c @@ -253,7 +253,7 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) if (0 == opal_list_get_size(&ndreg->ranges)) { if (NULL != ndreg->prefix) { /* solitary node */ - asprintf(&tmp, "%s", ndreg->prefix); + opal_asprintf(&tmp, "%s", ndreg->prefix); opal_argv_append_nosize(®exargs, tmp); free(tmp); } @@ -262,17 +262,17 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) } /* start the regex for this nodeid with the prefix */ if (NULL != ndreg->prefix) { - asprintf(&tmp, "%s[%d:", ndreg->prefix, ndreg->num_digits); + opal_asprintf(&tmp, "%s[%d:", ndreg->prefix, ndreg->num_digits); } else { - asprintf(&tmp, "[%d:", ndreg->num_digits); + opal_asprintf(&tmp, "[%d:", ndreg->num_digits); } /* add the ranges */ while (NULL != (itm2 = opal_list_remove_first(&ndreg->ranges))) { range = (orte_regex_range_t*)itm2; if (1 == range->cnt) { - asprintf(&tmp2, "%s%u,", tmp, range->vpid); + opal_asprintf(&tmp2, "%s%u,", tmp, range->vpid); } else { - asprintf(&tmp2, "%s%u-%u,", tmp, range->vpid, range->vpid + range->cnt - 1); + opal_asprintf(&tmp2, "%s%u-%u,", tmp, range->vpid, range->vpid + range->cnt - 1); } free(tmp); tmp = tmp2; @@ -282,7 +282,7 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) tmp[strlen(tmp)-1] = ']'; if (NULL != ndreg->suffix) { /* add in the suffix, if provided */ - asprintf(&tmp2, "%s%s", tmp, ndreg->suffix); + opal_asprintf(&tmp2, "%s%s", tmp, ndreg->suffix); free(tmp); tmp = tmp2; } @@ -303,17 +303,17 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) rng = (orte_regex_range_t*)item; if (1 < rng->cnt) { if (NULL == tmp) { - asprintf(&tmp, "%u(%u)", rng->vpid, rng->cnt); + opal_asprintf(&tmp, "%u(%u)", rng->vpid, rng->cnt); } else { - asprintf(&tmp2, "%s,%u(%u)", tmp, rng->vpid, rng->cnt); + opal_asprintf(&tmp2, "%s,%u(%u)", tmp, rng->vpid, rng->cnt); free(tmp); tmp = tmp2; } } else { if (NULL == tmp) { - asprintf(&tmp, "%u", rng->vpid); + opal_asprintf(&tmp, "%u", rng->vpid); } else { - asprintf(&tmp2, "%s,%u", tmp, rng->vpid); + opal_asprintf(&tmp2, "%s,%u", tmp, rng->vpid); free(tmp); tmp = tmp2; } @@ -323,7 +323,7 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) OPAL_LIST_DESTRUCT(&dvpids); /* now concatenate the results into one string */ - asprintf(&tmp2, "%s@%s", nodenames, tmp); + opal_asprintf(&tmp2, "%s@%s", nodenames, tmp); free(nodenames); free(tmp); *regex = tmp2; diff --git a/orte/mca/rmaps/base/base.h b/orte/mca/rmaps/base/base.h index fa0915993e..88996ae570 100644 --- a/orte/mca/rmaps/base/base.h +++ b/orte/mca/rmaps/base/base.h @@ -33,6 +33,7 @@ #include "orte/types.h" #include "opal/class/opal_list.h" +#include "opal/util/printf.h" #include "orte/mca/mca.h" #include "orte/runtime/orte_globals.h" diff --git a/orte/mca/rmaps/base/rmaps_base_frame.c b/orte/mca/rmaps/base/rmaps_base_frame.c index 7f15e075bc..2b8bdeb4dd 100644 --- a/orte/mca/rmaps/base/rmaps_base_frame.c +++ b/orte/mca/rmaps/base/rmaps_base_frame.c @@ -30,6 +30,7 @@ #include "orte/mca/mca.h" #include "opal/util/argv.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal/mca/base/base.h" #include "orte/runtime/orte_globals.h" @@ -283,7 +284,7 @@ static int orte_rmaps_base_open(mca_base_open_flag_t flags) "rmaps_base_mapping_policy=ppr:"); /* if the mapping policy is NULL, then we can proceed */ if (NULL == rmaps_base_mapping_policy) { - asprintf(&rmaps_base_mapping_policy, "ppr:%s", orte_rmaps_base.ppr); + opal_asprintf(&rmaps_base_mapping_policy, "ppr:%s", orte_rmaps_base.ppr); } else { return ORTE_ERR_SILENT; } @@ -453,7 +454,7 @@ static int orte_rmaps_base_open(mca_base_open_flag_t flags) ORTE_SET_MAPPING_POLICY(orte_rmaps_base.mapping, ORTE_MAPPING_PPR); ORTE_SET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping, ORTE_MAPPING_GIVEN); /* define the ppr */ - asprintf(&orte_rmaps_base.ppr, "%d:node", orte_rmaps_base_n_pernode); + opal_asprintf(&orte_rmaps_base.ppr, "%d:node", orte_rmaps_base_n_pernode); } } @@ -464,7 +465,7 @@ static int orte_rmaps_base_open(mca_base_open_flag_t flags) ORTE_SET_MAPPING_POLICY(orte_rmaps_base.mapping, ORTE_MAPPING_PPR); ORTE_SET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping, ORTE_MAPPING_GIVEN); /* define the ppr */ - asprintf(&orte_rmaps_base.ppr, "%d:socket", orte_rmaps_base_n_persocket); + opal_asprintf(&orte_rmaps_base.ppr, "%d:socket", orte_rmaps_base_n_persocket); } } diff --git a/orte/mca/rmaps/base/rmaps_base_print_fns.c b/orte/mca/rmaps/base/rmaps_base_print_fns.c index 1c6a15466e..7899ebe342 100644 --- a/orte/mca/rmaps/base/rmaps_base_print_fns.c +++ b/orte/mca/rmaps/base/rmaps_base_print_fns.c @@ -10,6 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -166,26 +167,26 @@ char* orte_rmaps_base_print_mapping(orte_mapping_policy_t mapping) } } if (0 != strcmp(map, "PPR") && (ORTE_MAPPING_PPR & ORTE_GET_MAPPING_DIRECTIVE(mapping))) { - asprintf(&mymap, "%s[PPR]:", map); + opal_asprintf(&mymap, "%s[PPR]:", map); } else { - asprintf(&mymap, "%s:", map); + opal_asprintf(&mymap, "%s:", map); } if (ORTE_MAPPING_NO_USE_LOCAL & ORTE_GET_MAPPING_DIRECTIVE(mapping)) { - asprintf(&tmp, "%sNO_USE_LOCAL,", mymap); + opal_asprintf(&tmp, "%sNO_USE_LOCAL,", mymap); free(mymap); mymap = tmp; } if (ORTE_MAPPING_NO_OVERSUBSCRIBE & ORTE_GET_MAPPING_DIRECTIVE(mapping)) { - asprintf(&tmp, "%sNOOVERSUBSCRIBE,", mymap); + opal_asprintf(&tmp, "%sNOOVERSUBSCRIBE,", mymap); free(mymap); mymap = tmp; } else if (ORTE_MAPPING_SUBSCRIBE_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(mapping)) { - asprintf(&tmp, "%sOVERSUBSCRIBE,", mymap); + opal_asprintf(&tmp, "%sOVERSUBSCRIBE,", mymap); free(mymap); mymap = tmp; } if (ORTE_MAPPING_SPAN & ORTE_GET_MAPPING_DIRECTIVE(mapping)) { - asprintf(&tmp, "%sSPAN,", mymap); + opal_asprintf(&tmp, "%sSPAN,", mymap); free(mymap); mymap = tmp; } diff --git a/orte/mca/rtc/base/base.h b/orte/mca/rtc/base/base.h index f37224c27f..0b482cee8c 100644 --- a/orte/mca/rtc/base/base.h +++ b/orte/mca/rtc/base/base.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -20,6 +20,7 @@ #include "orte/types.h" #include "opal/class/opal_list.h" +#include "opal/util/printf.h" #include "orte/mca/mca.h" #include "orte/mca/rtc/rtc.h" diff --git a/orte/mca/rtc/hwloc/rtc_hwloc.c b/orte/mca/rtc/hwloc/rtc_hwloc.c index 0751c4f38f..04ed3d0afe 100644 --- a/orte/mca/rtc/hwloc/rtc_hwloc.c +++ b/orte/mca/rtc/hwloc/rtc_hwloc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017-2018 Cisco Systems, Inc. All rights reserved * Copyright (c) 2017 Inria. All rights reserved. * $COPYRIGHT$ @@ -135,7 +135,7 @@ static int init(void) } /* create the shmem file in our session dir so it * will automatically get cleaned up */ - asprintf(&shmemfile, "%s/hwloc.sm", orte_process_info.jobfam_session_dir); + opal_asprintf(&shmemfile, "%s/hwloc.sm", orte_process_info.jobfam_session_dir); /* let's make sure we have enough space for the backing file */ if (OPAL_SUCCESS != (rc = enough_space(shmemfile, shmemsize, &amount_space_avail, @@ -303,7 +303,7 @@ static void set(orte_job_t *jobdat, } else { char *tmp; (void)hwloc_bitmap_list_asprintf(&tmp, sum->available); - asprintf(&msg, "hwloc_set_cpubind returned \"%s\" for bitmap \"%s\"", + opal_asprintf(&msg, "hwloc_set_cpubind returned \"%s\" for bitmap \"%s\"", opal_strerror(rc), tmp); free(tmp); } @@ -335,7 +335,7 @@ static void set(orte_job_t *jobdat, cpuset = hwloc_bitmap_alloc(); if (0 != (rc = hwloc_bitmap_list_sscanf(cpuset, cpu_bitmap))) { /* See comment above about "This may be a small memory leak" */ - asprintf(&msg, "hwloc_bitmap_sscanf returned \"%s\" for the string \"%s\"", + opal_asprintf(&msg, "hwloc_bitmap_sscanf returned \"%s\" for the string \"%s\"", opal_strerror(rc), cpu_bitmap); if (NULL == msg) { msg = "failed to convert bitmap list to hwloc bitmap"; @@ -370,7 +370,7 @@ static void set(orte_job_t *jobdat, } else if (errno == EXDEV) { msg = "hwloc indicates cpu binding cannot be enforced"; } else { - asprintf(&msg, "hwloc_set_cpubind returned \"%s\" for bitmap \"%s\"", + opal_asprintf(&msg, "hwloc_set_cpubind returned \"%s\" for bitmap \"%s\"", opal_strerror(rc), cpu_bitmap); } if (OPAL_BINDING_REQUIRED(jobdat->map->binding)) { diff --git a/orte/mca/schizo/base/base.h b/orte/mca/schizo/base/base.h index 8f5ab569ee..498d07d346 100644 --- a/orte/mca/schizo/base/base.h +++ b/orte/mca/schizo/base/base.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -20,6 +20,7 @@ #include "orte/types.h" #include "opal/class/opal_list.h" +#include "opal/util/printf.h" #include "orte/mca/mca.h" #include "orte/runtime/orte_globals.h" diff --git a/orte/mca/schizo/ompi/schizo_ompi.c b/orte/mca/schizo/ompi/schizo_ompi.c index c6f5e008fe..161045f701 100644 --- a/orte/mca/schizo/ompi/schizo_ompi.c +++ b/orte/mca/schizo/ompi/schizo_ompi.c @@ -786,7 +786,7 @@ static int parse_env(char *path, /* If the user specified --path, store it in the user's app environment via the OMPI_exec_path variable. */ if (NULL != path) { - asprintf(&value, "OMPI_exec_path=%s", path); + opal_asprintf(&value, "OMPI_exec_path=%s", path); opal_argv_append_nosize(dstenv, value); /* save it for any comm_spawn'd apps */ opal_argv_append_nosize(&orte_forwarded_envars, value); @@ -880,14 +880,14 @@ static int setup_fork(orte_job_t *jdata, /* Reset PATH */ if (0 == strncmp("PATH=", app->env[i], 5)) { - asprintf(&newenv, "%s/bin:%s", param, app->env[i] + 5); + opal_asprintf(&newenv, "%s/bin:%s", param, app->env[i] + 5); opal_setenv("PATH", newenv, true, &app->env); free(newenv); } /* Reset LD_LIBRARY_PATH */ else if (0 == strncmp("LD_LIBRARY_PATH=", app->env[i], 16)) { - asprintf(&newenv, "%s/lib:%s", param, app->env[i] + 16); + opal_asprintf(&newenv, "%s/lib:%s", param, app->env[i] + 16); opal_setenv("LD_LIBRARY_PATH", newenv, true, &app->env); free(newenv); } @@ -914,7 +914,7 @@ static int setup_fork(orte_job_t *jdata, } /* set the app_context number into the environment */ - asprintf(¶m, "%ld", (long)app->idx); + opal_asprintf(¶m, "%ld", (long)app->idx); opal_setenv("OMPI_MCA_orte_app_num", param, true, &app->env); free(param); @@ -926,12 +926,12 @@ static int setup_fork(orte_job_t *jdata, * AND YES - THIS BREAKS THE ABSTRACTION BARRIER TO SOME EXTENT. * We know - just live with it */ - asprintf(¶m, "%ld", (long)jdata->total_slots_alloc); + opal_asprintf(¶m, "%ld", (long)jdata->total_slots_alloc); opal_setenv("OMPI_UNIVERSE_SIZE", param, true, &app->env); free(param); /* pass the number of nodes involved in this job */ - asprintf(¶m, "%ld", (long)(jdata->map->num_nodes)); + opal_asprintf(¶m, "%ld", (long)(jdata->map->num_nodes)); opal_setenv("OMPI_MCA_orte_num_nodes", param, true, &app->env); free(param); @@ -993,7 +993,7 @@ static int setup_fork(orte_job_t *jdata, */ opal_unsetenv("OMPI_MCA_orte_ess_name", &app->env); - asprintf(¶m, "%ld", (long)jdata->num_procs); + opal_asprintf(¶m, "%ld", (long)jdata->num_procs); opal_setenv("OMPI_MCA_orte_ess_num_procs", param, true, &app->env); /* although the num_procs is the comm_world size, users @@ -1014,7 +1014,7 @@ static int setup_fork(orte_job_t *jdata, * AND YES - THIS BREAKS THE ABSTRACTION BARRIER TO SOME EXTENT. * We know - just live with it */ - asprintf(¶m, "%ld", (long)jdata->num_local_procs); + opal_asprintf(¶m, "%ld", (long)jdata->num_local_procs); opal_setenv("OMPI_COMM_WORLD_LOCAL_SIZE", param, true, &app->env); free(param); @@ -1028,7 +1028,7 @@ static int setup_fork(orte_job_t *jdata, * so we pass them as envars to avoid introducing further * ORTE calls in the MPI layer */ - asprintf(&num_app_ctx, "%lu", (unsigned long)jdata->num_apps); + opal_asprintf(&num_app_ctx, "%lu", (unsigned long)jdata->num_apps); /* build some common envars we need to pass for MPI-3 compatibility */ nps = NULL; @@ -1074,7 +1074,7 @@ static int setup_fork(orte_job_t *jdata, /* we have the var - prepend it */ param = saveptr; ++param; // move past where the '=' sign was - (void)asprintf(&p2, "%s%c%s", attr->data.envar.value, + opal_asprintf(&p2, "%s%c%s", attr->data.envar.value, attr->data.envar.separator, param); *saveptr = '='; // restore the current envar setting opal_setenv(attr->data.envar.envar, p2, true, &app->env); @@ -1099,7 +1099,7 @@ static int setup_fork(orte_job_t *jdata, /* we have the var - prepend it */ param = saveptr; ++param; // move past where the '=' sign was - (void)asprintf(&p2, "%s%c%s", param, attr->data.envar.separator, + opal_asprintf(&p2, "%s%c%s", param, attr->data.envar.separator, attr->data.envar.value); *saveptr = '='; // restore the current envar setting opal_setenv(attr->data.envar.envar, p2, true, &app->env); @@ -1135,7 +1135,7 @@ static int setup_fork(orte_job_t *jdata, /* we have the var - prepend it */ param = saveptr; ++param; // move past where the '=' sign was - (void)asprintf(&p2, "%s%c%s", attr->data.envar.value, + opal_asprintf(&p2, "%s%c%s", attr->data.envar.value, attr->data.envar.separator, param); *saveptr = '='; // restore the current envar setting opal_setenv(attr->data.envar.envar, p2, true, &app->env); @@ -1160,7 +1160,7 @@ static int setup_fork(orte_job_t *jdata, /* we have the var - prepend it */ param = saveptr; ++param; // move past where the '=' sign was - (void)asprintf(&p2, "%s%c%s", param, attr->data.envar.separator, + opal_asprintf(&p2, "%s%c%s", param, attr->data.envar.separator, attr->data.envar.value); *saveptr = '='; // restore the current envar setting opal_setenv(attr->data.envar.envar, p2, true, &app->env); @@ -1252,7 +1252,7 @@ static int setup_child(orte_job_t *jdata, rc = ORTE_ERR_VALUE_OUT_OF_BOUNDS; return rc; } - asprintf(&value, "%lu", (unsigned long) child->local_rank); + opal_asprintf(&value, "%lu", (unsigned long) child->local_rank); opal_setenv("OMPI_COMM_WORLD_LOCAL_RANK", value, true, env); free(value); @@ -1268,7 +1268,7 @@ static int setup_child(orte_job_t *jdata, rc = ORTE_ERR_VALUE_OUT_OF_BOUNDS; return rc; } - asprintf(&value, "%lu", (unsigned long) child->node_rank); + opal_asprintf(&value, "%lu", (unsigned long) child->node_rank); opal_setenv("OMPI_COMM_WORLD_NODE_RANK", value, true, env); /* set an mca param for it too */ opal_setenv("OMPI_MCA_orte_ess_node_rank", value, true, env); @@ -1289,7 +1289,7 @@ static int setup_child(orte_job_t *jdata, * an initial start, but procs would like to know if they are being * restarted so they can take appropriate action */ - asprintf(&value, "%d", nrestarts); + opal_asprintf(&value, "%d", nrestarts); opal_setenv("OMPI_MCA_orte_num_restarts", value, true, env); free(value); } diff --git a/orte/mca/schizo/singularity/schizo_singularity.c b/orte/mca/schizo/singularity/schizo_singularity.c index 7ec8d56b80..38b73b3fff 100644 --- a/orte/mca/schizo/singularity/schizo_singularity.c +++ b/orte/mca/schizo/singularity/schizo_singularity.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -68,7 +68,7 @@ static int setup_fork(orte_job_t *jdata, orte_app_context_t *app) /* Make sure we prepend the path Singularity was called by incase that * path is not defined on the nodes */ if (0 < strlen(OPAL_SINGULARITY_PATH)) { - if (0 > asprintf(&pth, "%s/singularity", OPAL_SINGULARITY_PATH) ) { + if (0 > opal_asprintf(&pth, "%s/singularity", OPAL_SINGULARITY_PATH) ) { /* Something bad happened, let's move on */ return ORTE_ERR_TAKE_NEXT_OPTION; } @@ -87,7 +87,7 @@ static int setup_fork(orte_job_t *jdata, orte_app_context_t *app) /* add to PATH */ if (0 == strncmp("PATH=", app->env[i], 5)) { t2 = opal_dirname(pth); - if (0 < asprintf(&newenv, "%s:%s", t2, app->env[i] + 5) ) { + if (0 < opal_asprintf(&newenv, "%s:%s", t2, app->env[i] + 5) ) { opal_setenv("PATH", newenv, true, &app->env); free(newenv); } diff --git a/orte/mca/schizo/slurm/schizo_slurm.c b/orte/mca/schizo/slurm/schizo_slurm.c index 1038f69044..92b27bb6b3 100644 --- a/orte/mca/schizo/slurm/schizo_slurm.c +++ b/orte/mca/schizo/slurm/schizo_slurm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * $COPYRIGHT$ * @@ -145,7 +145,7 @@ static int get_remaining_time(uint32_t *timeleft) if (NULL == (jobid = getenv("SLURM_JOBID"))) { return ORTE_ERR_TAKE_NEXT_OPTION; } - if (0 > asprintf(&cmd, "squeue -h -j %s -o %%L", jobid)) { + if (0 > opal_asprintf(&cmd, "squeue -h -j %s -o %%L", jobid)) { return ORTE_ERR_OUT_OF_RESOURCE; } fp = popen(cmd, "r"); diff --git a/orte/mca/snapc/base/base.h b/orte/mca/snapc/base/base.h index cfdf07164a..1e0723f354 100644 --- a/orte/mca/snapc/base/base.h +++ b/orte/mca/snapc/base/base.h @@ -12,6 +12,7 @@ * Copyright (c) 2007 Evergrid, Inc. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved. * + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -24,6 +25,7 @@ #include "orte_config.h" #include "orte/types.h" +#include "opal/util/printf.h" #include "orte/mca/snapc/snapc.h" diff --git a/orte/mca/snapc/base/snapc_base_fns.c b/orte/mca/snapc/base/snapc_base_fns.c index 2aae5f775e..a7a0f98ec7 100644 --- a/orte/mca/snapc/base/snapc_base_fns.c +++ b/orte/mca/snapc/base/snapc_base_fns.c @@ -9,7 +9,7 @@ * All rights reserved. * Copyright (c) 2007 Evergrid, Inc. All rights reserved. * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -836,7 +836,7 @@ int orte_snapc_ckpt_state_str(char ** state_str, int state) *state_str = strdup("Error"); break; default: - asprintf(state_str, "Unknown %d", state); + opal_asprintf(state_str, "Unknown %d", state); break; } diff --git a/orte/mca/snapc/full/snapc_full_app.c b/orte/mca/snapc/full/snapc_full_app.c index 3a436bc81d..e021e227b6 100644 --- a/orte/mca/snapc/full/snapc_full_app.c +++ b/orte/mca/snapc/full/snapc_full_app.c @@ -7,6 +7,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -736,10 +737,10 @@ static int app_define_pipe_names(void) app_comm_pipe_w = NULL; } - asprintf(&app_comm_pipe_r, "%s/%s.%d_%d", + opal_asprintf(&app_comm_pipe_r, "%s/%s.%d_%d", opal_cr_pipe_dir, OPAL_CR_NAMED_PROG_R, (int)getpid(), current_unique_id); - asprintf(&app_comm_pipe_w, "%s/%s.%d_%d", + opal_asprintf(&app_comm_pipe_w, "%s/%s.%d_%d", opal_cr_pipe_dir, OPAL_CR_NAMED_PROG_W, (int)getpid(), current_unique_id); diff --git a/orte/mca/snapc/full/snapc_full_local.c b/orte/mca/snapc/full/snapc_full_local.c index 0596fc1d9d..e8f6b58839 100644 --- a/orte/mca/snapc/full/snapc_full_local.c +++ b/orte/mca/snapc/full/snapc_full_local.c @@ -9,6 +9,7 @@ * All rights reserved. * Copyright (c) 2007 Evergrid, Inc. All rights reserved. * + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -1278,13 +1279,13 @@ static int local_define_pipe_names(orte_snapc_full_app_snapshot_t *vpid_snapshot vpid_snapshot->comm_pipe_w = NULL; } - asprintf(&(vpid_snapshot->comm_pipe_w), + opal_asprintf(&(vpid_snapshot->comm_pipe_w), "%s/%s.%d_%d", opal_cr_pipe_dir, OPAL_CR_NAMED_PROG_R, vpid_snapshot->process_pid, vpid_snapshot->unique_pipe_id); - asprintf(&(vpid_snapshot->comm_pipe_r), + opal_asprintf(&(vpid_snapshot->comm_pipe_r), "%s/%s.%d_%d", opal_cr_pipe_dir, OPAL_CR_NAMED_PROG_W, vpid_snapshot->process_pid, @@ -1918,9 +1919,9 @@ static int snapc_full_local_get_vpids(void) * Otherwise update or populate the list */ for (i=0; i < orte_local_children->size; i++) { - if (NULL == (child = (orte_proc_t*)opal_pointer_array_get_item(orte_local_children, i))) { - continue; - } + if (NULL == (child = (orte_proc_t*)opal_pointer_array_get_item(orte_local_children, i))) { + continue; + } /* if the list is empty or this child is not in the list then add it */ if( 0 >= list_len || diff --git a/orte/mca/sstore/base/base.h b/orte/mca/sstore/base/base.h index 70ee1ec036..b9c0e73566 100644 --- a/orte/mca/sstore/base/base.h +++ b/orte/mca/sstore/base/base.h @@ -3,6 +3,7 @@ * University Research and Technology * Corporation. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -14,6 +15,7 @@ #include "orte_config.h" +#include "opal/util/printf.h" #include "orte/mca/sstore/sstore.h" /* diff --git a/orte/mca/sstore/base/sstore_base_fns.c b/orte/mca/sstore/base/sstore_base_fns.c index 665a94ec17..2962687da6 100644 --- a/orte/mca/sstore/base/sstore_base_fns.c +++ b/orte/mca/sstore/base/sstore_base_fns.c @@ -4,6 +4,7 @@ * Copyright (c) 2004-2011 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -203,7 +204,7 @@ int orte_sstore_base_tool_request_restart_handle(orte_sstore_base_handle_t *hand } else { snapshot->basedir = strdup(basedir); } - asprintf(&(snapshot->metadata_filename), + opal_asprintf(&(snapshot->metadata_filename), "%s/%s/%s", snapshot->basedir, snapshot->reference, @@ -212,7 +213,7 @@ int orte_sstore_base_tool_request_restart_handle(orte_sstore_base_handle_t *hand /* * Check the checkpoint location */ - asprintf(&tmp_str, "%s/%s", + opal_asprintf(&tmp_str, "%s/%s", snapshot->basedir, snapshot->reference); if (0 > (ret = access(tmp_str, F_OK)) ) { @@ -246,7 +247,7 @@ int orte_sstore_base_tool_request_restart_handle(orte_sstore_base_handle_t *hand /* * Check the checkpoint sequence location */ - asprintf(&tmp_str, "%s/%s/%d", + opal_asprintf(&tmp_str, "%s/%s/%d", snapshot->basedir, snapshot->reference, snapshot->seq_num); @@ -292,7 +293,7 @@ int orte_sstore_base_tool_get_attr(orte_sstore_base_handle_t handle, orte_sstore int ret, exit_status = ORTE_SUCCESS; if( SSTORE_METADATA_GLOBAL_SNAP_LOC_ABS == key ) { - asprintf(value, "%s/%s", + opal_asprintf(value, "%s/%s", tool_global_snapshot->basedir, tool_global_snapshot->reference); } @@ -300,13 +301,13 @@ int orte_sstore_base_tool_get_attr(orte_sstore_base_handle_t handle, orte_sstore *value = strdup(orte_sstore_base_local_snapshot_fmt); } else if( SSTORE_METADATA_LOCAL_SNAP_LOC == key ) { - asprintf(value, "%s/%s/%d", + opal_asprintf(value, "%s/%s/%d", tool_global_snapshot->basedir, tool_global_snapshot->reference, tool_global_snapshot->seq_num); } else if( SSTORE_METADATA_LOCAL_SNAP_REF_LOC_FMT == key ) { - asprintf(value, "%s/%s/%d/%s", + opal_asprintf(value, "%s/%s/%d/%s", tool_global_snapshot->basedir, tool_global_snapshot->reference, tool_global_snapshot->seq_num, @@ -322,7 +323,7 @@ int orte_sstore_base_tool_get_attr(orte_sstore_base_handle_t handle, orte_sstore goto cleanup; } } - asprintf(value, "%d", tool_global_snapshot->num_seqs); + opal_asprintf(value, "%d", tool_global_snapshot->num_seqs); } else if( SSTORE_METADATA_GLOBAL_SNAP_ALL_SEQ == key ) { if( NULL == tool_global_snapshot->all_seqs ) { @@ -356,7 +357,7 @@ int orte_sstore_base_tool_get_attr(orte_sstore_base_handle_t handle, orte_sstore int orte_sstore_base_get_global_snapshot_ref(char **name_str, pid_t pid) { if( NULL == orte_sstore_base_global_snapshot_ref ) { - asprintf(name_str, "ompi_global_snapshot_%d.ckpt", pid); + opal_asprintf(name_str, "ompi_global_snapshot_%d.ckpt", pid); } else { *name_str = strdup(orte_sstore_base_global_snapshot_ref); @@ -511,7 +512,7 @@ int orte_sstore_base_get_all_snapshots(opal_list_t *all_snapshots, char *basedir } /* Add the full path */ - asprintf(&tmp_str, "%s/%s", loc_basedir, dir_entp->d_name); + opal_asprintf(&tmp_str, "%s/%s", loc_basedir, dir_entp->d_name); if(0 != (ret = stat(tmp_str, &file_status) ) ){ free( tmp_str); tmp_str = NULL; @@ -519,7 +520,7 @@ int orte_sstore_base_get_all_snapshots(opal_list_t *all_snapshots, char *basedir } else { /* Is it a directory? */ if(S_ISDIR(file_status.st_mode) ) { - asprintf(&metadata_file, "%s/%s", + opal_asprintf(&metadata_file, "%s/%s", tmp_str, orte_sstore_base_global_metadata_filename); if(0 != (ret = stat(metadata_file, &file_status) ) ){ @@ -534,10 +535,10 @@ int orte_sstore_base_get_all_snapshots(opal_list_t *all_snapshots, char *basedir global_snapshot->ss_handle = 1; global_snapshot->basedir = strdup(loc_basedir); - asprintf(&(global_snapshot->reference), + opal_asprintf(&(global_snapshot->reference), "%s", dir_entp->d_name); - asprintf(&(global_snapshot->metadata_filename), + opal_asprintf(&(global_snapshot->metadata_filename), "%s/%s/%s", global_snapshot->basedir, global_snapshot->reference, @@ -756,7 +757,7 @@ int orte_sstore_base_find_all_seq_nums(orte_sstore_base_global_snapshot_info_t * } while(0 <= (tmp_seq_num = orte_sstore_base_metadata_read_next_seq_num(metadata)) ) { - asprintf(&tmp_str, "%d", tmp_seq_num); + opal_asprintf(&tmp_str, "%d", tmp_seq_num); if( NULL != tmp_str ) { opal_argv_append(num_seq, seq_list, tmp_str); diff --git a/orte/mca/sstore/base/sstore_base_frame.c b/orte/mca/sstore/base/sstore_base_frame.c index 1dae2563df..336e1a5db7 100644 --- a/orte/mca/sstore/base/sstore_base_frame.c +++ b/orte/mca/sstore/base/sstore_base_frame.c @@ -7,6 +7,7 @@ * Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -128,7 +129,7 @@ static int orte_sstore_base_open(mca_base_open_flag_t flags) * location */ if( NULL != orte_sstore_base_global_snapshot_ref ) { - asprintf(&orte_sstore_base_prelaunch_location, + opal_asprintf(&orte_sstore_base_prelaunch_location, "%s/%s/%d", orte_sstore_base_global_snapshot_dir, orte_sstore_base_global_snapshot_ref, diff --git a/orte/mca/sstore/central/sstore_central_app.c b/orte/mca/sstore/central/sstore_central_app.c index 09a8419874..8ab1244bdc 100644 --- a/orte/mca/sstore/central/sstore_central_app.c +++ b/orte/mca/sstore/central/sstore_central_app.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2010 The Trustees of Indiana University. * All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -252,7 +253,7 @@ int orte_sstore_central_app_get_attr(orte_sstore_base_handle_t handle, orte_ssto * Access metadata */ if( SSTORE_METADATA_GLOBAL_SNAP_SEQ == key ) { - asprintf(value, "%d", handle_info->seq_num); + opal_asprintf(value, "%d", handle_info->seq_num); OPAL_OUTPUT_VERBOSE((10, mca_sstore_central_component.super.output_handle, "sstore:central:(app): get_attr(%d, %d) Seq = <%s>", key, handle_info->id, *value)); } diff --git a/orte/mca/sstore/central/sstore_central_global.c b/orte/mca/sstore/central/sstore_central_global.c index 15cbb31359..aa361860a3 100644 --- a/orte/mca/sstore/central/sstore_central_global.c +++ b/orte/mca/sstore/central/sstore_central_global.c @@ -4,6 +4,7 @@ * Copyright (c) 2004-2011 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -480,20 +481,20 @@ int orte_sstore_central_global_get_attr(orte_sstore_base_handle_t handle, orte_s *value = strdup(handle_info->ref_name); } else if( SSTORE_METADATA_GLOBAL_SNAP_SEQ == key ) { - asprintf(value, "%d", handle_info->seq_num); + opal_asprintf(value, "%d", handle_info->seq_num); } else if( SSTORE_METADATA_LOCAL_SNAP_REF_FMT == key ) { *value = strdup(orte_sstore_base_local_snapshot_fmt); } /* 'central' does not cache, so these are the same */ else if( SSTORE_METADATA_LOCAL_SNAP_LOC == key ) { - asprintf(value, "%s/%s/%d", + opal_asprintf(value, "%s/%s/%d", handle_info->base_location, handle_info->ref_name, handle_info->seq_num); } else if( SSTORE_METADATA_LOCAL_SNAP_REF_LOC_FMT == key ) { - asprintf(value, "%s/%s/%d/%s", + opal_asprintf(value, "%s/%s/%d/%s", handle_info->base_location, handle_info->ref_name, handle_info->seq_num, @@ -731,15 +732,15 @@ static orte_sstore_central_global_snapshot_info_t *create_new_handle_info(int se orte_sstore_base_get_global_snapshot_ref(&(handle_info->ref_name), getpid()); - asprintf(&(handle_info->local_location), "%s/%d", + opal_asprintf(&(handle_info->local_location), "%s/%d", handle_info->ref_name, handle_info->seq_num); - asprintf(&(handle_info->app_location_fmt), "%s/%s/%s", + opal_asprintf(&(handle_info->app_location_fmt), "%s/%s/%s", handle_info->base_location, handle_info->local_location, orte_sstore_base_local_snapshot_fmt); - asprintf(&(handle_info->metadata_filename), "%s/%s/%s", + opal_asprintf(&(handle_info->metadata_filename), "%s/%s/%s", handle_info->base_location, handle_info->ref_name, orte_sstore_base_global_metadata_filename); @@ -1029,7 +1030,7 @@ static int init_global_snapshot_directory(orte_sstore_central_global_snapshot_in /* * Make the snapshot directory from the uniq_global_snapshot_name */ - asprintf(&dir_name, "%s/%s", + opal_asprintf(&dir_name, "%s/%s", handle_info->base_location, handle_info->local_location); if(OPAL_SUCCESS != (ret = opal_os_dirpath_create(dir_name, my_mode)) ) { diff --git a/orte/mca/sstore/central/sstore_central_local.c b/orte/mca/sstore/central/sstore_central_local.c index cf36b1823d..0ed0f9d2b4 100644 --- a/orte/mca/sstore/central/sstore_central_local.c +++ b/orte/mca/sstore/central/sstore_central_local.c @@ -4,6 +4,7 @@ * Copyright (c) 2004-2011 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -545,7 +546,7 @@ static orte_sstore_central_local_snapshot_info_t *create_new_handle_info(orte_ss * Create a sub structure for each child */ for (i=0; i < orte_local_children->size; i++) { - if (NULL == (child = (orte_proc_t*)opal_pointer_array_get_item(orte_local_children, i))) { + if (NULL == (child = (orte_proc_t*)opal_pointer_array_get_item(orte_local_children, i))) { continue; } append_new_app_handle_info(handle_info, &child->name); @@ -683,13 +684,13 @@ static int process_global_push(orte_process_name_t* peer, opal_buffer_t* buffer, free(app_info->local_location); app_info->local_location = NULL; } - asprintf(&(app_info->local_location), handle_info->location_fmt, app_info->name.vpid); + opal_asprintf(&(app_info->local_location), handle_info->location_fmt, app_info->name.vpid); if( NULL != app_info->metadata_filename ) { free(app_info->metadata_filename); app_info->metadata_filename = NULL; } - asprintf(&(app_info->metadata_filename), "%s/%s", + opal_asprintf(&(app_info->metadata_filename), "%s/%s", app_info->local_location, orte_sstore_base_local_metadata_filename); } diff --git a/orte/mca/sstore/stage/sstore_stage_app.c b/orte/mca/sstore/stage/sstore_stage_app.c index 1bf26b840f..ce5ea40153 100644 --- a/orte/mca/sstore/stage/sstore_stage_app.c +++ b/orte/mca/sstore/stage/sstore_stage_app.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2010 The Trustees of Indiana University. * All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -252,7 +253,7 @@ int orte_sstore_stage_app_get_attr(orte_sstore_base_handle_t handle, orte_sstore * Access metadata */ if( SSTORE_METADATA_GLOBAL_SNAP_SEQ == key ) { - asprintf(value, "%d", handle_info->seq_num); + opal_asprintf(value, "%d", handle_info->seq_num); } else if( SSTORE_METADATA_LOCAL_SNAP_LOC == key) { *value = strdup(handle_info->local_location); diff --git a/orte/mca/sstore/stage/sstore_stage_global.c b/orte/mca/sstore/stage/sstore_stage_global.c index 45f2bf15fe..8379b4e9a5 100644 --- a/orte/mca/sstore/stage/sstore_stage_global.c +++ b/orte/mca/sstore/stage/sstore_stage_global.c @@ -4,6 +4,7 @@ * Copyright (c) 2004-2011 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -582,11 +583,11 @@ int orte_sstore_stage_global_get_attr(orte_sstore_base_handle_t handle, orte_sst } /* Used by snapc */ else if( SSTORE_METADATA_GLOBAL_SNAP_SEQ == key ) { - asprintf(value, "%d", handle_info->seq_num); + opal_asprintf(value, "%d", handle_info->seq_num); } /* Used by orte-restart and RecoS and snapc (kinda) */ else if( SSTORE_METADATA_LOCAL_SNAP_LOC == key ) { - asprintf(value, "%s/%s/%d", + opal_asprintf(value, "%s/%s/%d", handle_info->base_location, handle_info->ref_name, handle_info->seq_num); @@ -597,7 +598,7 @@ int orte_sstore_stage_global_get_attr(orte_sstore_base_handle_t handle, orte_sst } /* Used by orte-restart and RecoS */ else if( SSTORE_METADATA_LOCAL_SNAP_REF_LOC_FMT == key ) { - asprintf(value, "%s/%s/%d/%s", + opal_asprintf(value, "%s/%s/%d/%s", handle_info->base_location, handle_info->ref_name, handle_info->seq_num, @@ -750,7 +751,7 @@ static void sync_global_dir(orte_sstore_stage_global_snapshot_info_t *handle_inf /* * Sync the Sequence num dir */ - asprintf(&fs_str, "%s/%s/%d", + opal_asprintf(&fs_str, "%s/%s/%d", handle_info->base_location, handle_info->ref_name, handle_info->seq_num); @@ -932,18 +933,18 @@ static orte_sstore_stage_global_snapshot_info_t *create_new_handle_info(int seq, orte_sstore_base_get_global_snapshot_ref(&(handle_info->ref_name), getpid()); - asprintf(&(handle_info->local_location), "%s/%d", + opal_asprintf(&(handle_info->local_location), "%s/%d", handle_info->ref_name, handle_info->seq_num); /* This is used by the application to establish the local directory */ - asprintf(&(handle_info->app_local_location_fmt), "%s/%s/%s/%s", + opal_asprintf(&(handle_info->app_local_location_fmt), "%s/%s/%s/%s", orte_sstore_stage_local_snapshot_dir, ORTE_SSTORE_LOCAL_SNAPSHOT_DIR_NAME, ORTE_SSTORE_LOCAL_SNAPSHOT_STAGE_DIR_NAME, orte_sstore_base_local_snapshot_fmt); if( orte_sstore_stage_enabled_caching ) { - asprintf(&(handle_info->app_local_cache_location_fmt), "%s/%s/%s/%d/%s", + opal_asprintf(&(handle_info->app_local_cache_location_fmt), "%s/%s/%s/%d/%s", orte_sstore_stage_local_snapshot_dir, ORTE_SSTORE_LOCAL_SNAPSHOT_DIR_NAME, ORTE_SSTORE_LOCAL_SNAPSHOT_CACHE_DIR_NAME, @@ -952,12 +953,12 @@ static orte_sstore_stage_global_snapshot_info_t *create_new_handle_info(int seq, } /* This is used by the HNP to remember where it should place each process */ - asprintf(&(handle_info->app_global_location_fmt), "%s/%s/%s", + opal_asprintf(&(handle_info->app_global_location_fmt), "%s/%s/%s", handle_info->base_location, handle_info->local_location, orte_sstore_base_local_snapshot_fmt); - asprintf(&(handle_info->metadata_filename), "%s/%s/%s", + opal_asprintf(&(handle_info->metadata_filename), "%s/%s/%s", handle_info->base_location, handle_info->ref_name, orte_sstore_base_global_metadata_filename); @@ -1264,14 +1265,14 @@ static int process_local_push(orte_process_name_t* peer, opal_buffer_t* buffer, } if( orte_sstore_stage_enabled_compression ) { - asprintf(&tmp_str, + opal_asprintf(&tmp_str, handle_info->app_global_location_fmt, name.vpid); - asprintf(&(f_set->local_target), "%s%s", + opal_asprintf(&(f_set->local_target), "%s%s", tmp_str, compress_postfix); } else { - asprintf(&(f_set->local_target), + opal_asprintf(&(f_set->local_target), handle_info->app_global_location_fmt, name.vpid); } @@ -1281,14 +1282,14 @@ static int process_local_push(orte_process_name_t* peer, opal_buffer_t* buffer, } if( orte_sstore_stage_enabled_compression ) { - asprintf(&tmp_str, + opal_asprintf(&tmp_str, handle_info->app_local_location_fmt, name.vpid); - asprintf(&(f_set->remote_target), "%s%s", + opal_asprintf(&(f_set->remote_target), "%s%s", tmp_str, compress_postfix); } else { - asprintf(&(f_set->remote_target), + opal_asprintf(&(f_set->remote_target), handle_info->app_local_location_fmt, name.vpid); } @@ -1428,7 +1429,7 @@ static int init_global_snapshot_directory(orte_sstore_stage_global_snapshot_info /* * Make the snapshot directory from the uniq_global_snapshot_name */ - asprintf(&dir_name, "%s/%s", + opal_asprintf(&dir_name, "%s/%s", handle_info->base_location, handle_info->local_location); if(OPAL_SUCCESS != (ret = opal_os_dirpath_create(dir_name, my_mode)) ) { diff --git a/orte/mca/sstore/stage/sstore_stage_local.c b/orte/mca/sstore/stage/sstore_stage_local.c index 56dd0373fb..c93943e3d6 100644 --- a/orte/mca/sstore/stage/sstore_stage_local.c +++ b/orte/mca/sstore/stage/sstore_stage_local.c @@ -6,6 +6,7 @@ * reserved. * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -353,7 +354,7 @@ int orte_sstore_stage_local_module_init(void) /* * Create the local storage directory */ - asprintf(&sstore_stage_local_basedir, "%s/%s/%s", + opal_asprintf(&sstore_stage_local_basedir, "%s/%s/%s", orte_sstore_stage_local_snapshot_dir, ORTE_SSTORE_LOCAL_SNAPSHOT_DIR_NAME, ORTE_SSTORE_LOCAL_SNAPSHOT_STAGE_DIR_NAME); @@ -367,7 +368,7 @@ int orte_sstore_stage_local_module_init(void) * Create the local cache */ if( orte_sstore_stage_enabled_caching ) { - asprintf(&sstore_stage_cache_basedir, "%s/%s/%s", + opal_asprintf(&sstore_stage_cache_basedir, "%s/%s/%s", orte_sstore_stage_local_snapshot_dir, ORTE_SSTORE_LOCAL_SNAPSHOT_DIR_NAME, ORTE_SSTORE_LOCAL_SNAPSHOT_CACHE_DIR_NAME); @@ -949,7 +950,7 @@ static orte_sstore_stage_local_snapshot_info_t *create_new_handle_info(orte_ssto * Create a sub structure for each child */ for (i=0; i < orte_local_children->size; i++) { - if (NULL == (child = (orte_proc_t*)opal_pointer_array_get_item(orte_local_children, i))) { + if (NULL == (child = (orte_proc_t*)opal_pointer_array_get_item(orte_local_children, i))) { continue; } append_new_app_handle_info(handle_info, &child->name); @@ -1210,21 +1211,21 @@ static int process_global_push(orte_process_name_t* peer, opal_buffer_t* buffer, free(app_info->local_location); app_info->local_location = NULL; } - asprintf(&(app_info->local_location), handle_info->location_fmt, app_info->name.vpid); + opal_asprintf(&(app_info->local_location), handle_info->location_fmt, app_info->name.vpid); if( orte_sstore_stage_enabled_caching ) { if( NULL != app_info->local_cache_location ) { free(app_info->local_cache_location); app_info->local_cache_location = NULL; } - asprintf(&(app_info->local_cache_location), handle_info->cache_location_fmt, app_info->name.vpid); + opal_asprintf(&(app_info->local_cache_location), handle_info->cache_location_fmt, app_info->name.vpid); } if( NULL != app_info->metadata_filename ) { free(app_info->metadata_filename); app_info->metadata_filename = NULL; } - asprintf(&(app_info->metadata_filename), "%s/%s", + opal_asprintf(&(app_info->metadata_filename), "%s/%s", app_info->local_location, orte_sstore_base_local_metadata_filename); } @@ -1260,7 +1261,7 @@ static int process_global_remove(orte_process_name_t* peer, opal_buffer_t* buffe item = opal_list_get_next(item) ) { app_info = (orte_sstore_stage_local_app_snapshot_info_t*)item; - asprintf(&cmd, "rm -rf %s", app_info->local_location); + opal_asprintf(&cmd, "rm -rf %s", app_info->local_location); OPAL_OUTPUT_VERBOSE((10, mca_sstore_stage_component.super.output_handle, "sstore:stage:(local): update_cache(): Removing with command (%s)", cmd)); @@ -1270,7 +1271,7 @@ static int process_global_remove(orte_process_name_t* peer, opal_buffer_t* buffe free(cmd); cmd = NULL; - asprintf(&cmd, "rm -rf %s", app_info->compressed_local_location); + opal_asprintf(&cmd, "rm -rf %s", app_info->compressed_local_location); OPAL_OUTPUT_VERBOSE((10, mca_sstore_stage_component.super.output_handle, "sstore:stage:(local): update_cache(): Removing with command (%s)", cmd)); @@ -1805,7 +1806,7 @@ static int sstore_stage_destroy_local_dir(void) int ret, exit_status = ORTE_SUCCESS; char * basedir_root = NULL; - asprintf(&basedir_root, "%s/%s", + opal_asprintf(&basedir_root, "%s/%s", orte_sstore_stage_local_snapshot_dir, ORTE_SSTORE_LOCAL_SNAPSHOT_DIR_NAME); @@ -1911,7 +1912,7 @@ static int sstore_stage_update_cache(orte_sstore_stage_local_snapshot_info_t *ha item = opal_list_get_next(item) ) { app_info = (orte_sstore_stage_local_app_snapshot_info_t*)item; - asprintf(&cmd, "mv %s %s", app_info->local_location, cache_dirname); + opal_asprintf(&cmd, "mv %s %s", app_info->local_location, cache_dirname); OPAL_OUTPUT_VERBOSE((10, mca_sstore_stage_component.super.output_handle, "sstore:stage:(local): update_cache(): Caching snapshot for process %s [%s]", ORTE_NAME_PRINT(&app_info->name), @@ -1923,7 +1924,7 @@ static int sstore_stage_update_cache(orte_sstore_stage_local_snapshot_info_t *ha free(cmd); cmd = NULL; - asprintf(&cmd, "rm -rf %s", app_info->compressed_local_location); + opal_asprintf(&cmd, "rm -rf %s", app_info->compressed_local_location); OPAL_OUTPUT_VERBOSE((10, mca_sstore_stage_component.super.output_handle, "sstore:stage:(local): update_cache(): Removing with command (%s)", cmd)); @@ -1935,7 +1936,7 @@ static int sstore_stage_update_cache(orte_sstore_stage_local_snapshot_info_t *ha * Remove the previous cached checkpoint */ if( NULL != sstore_stage_cache_last_dir ) { - asprintf(&cmd, "rm -rf %s", sstore_stage_cache_last_dir); + opal_asprintf(&cmd, "rm -rf %s", sstore_stage_cache_last_dir); OPAL_OUTPUT_VERBOSE((10, mca_sstore_stage_component.super.output_handle, "sstore:stage:(local): update_cache(): Removing old cache dir command (%s)", sstore_stage_cache_last_dir)); @@ -2014,12 +2015,12 @@ static int orte_sstore_stage_local_preload_files(char **local_location, bool *sk } #endif - asprintf(local_location, "%s/%s/%s/%d", + opal_asprintf(local_location, "%s/%s/%s/%d", orte_sstore_stage_local_snapshot_dir, ORTE_SSTORE_LOCAL_SNAPSHOT_DIR_NAME, ORTE_SSTORE_LOCAL_SNAPSHOT_RESTART_DIR_NAME, seq); - asprintf(&full_local_location, "%s/%s", + opal_asprintf(&full_local_location, "%s/%s", *local_location, ref); @@ -2070,12 +2071,12 @@ static int orte_sstore_stage_local_preload_files(char **local_location, bool *sk f_set->local_target = strdup(*local_location); if( NULL != postfix && 0 < strlen(postfix) ) { - asprintf(&(f_set->remote_target), "%s/%s%s", + opal_asprintf(&(f_set->remote_target), "%s/%s%s", global_loc, ref, postfix); } else { - asprintf(&(f_set->remote_target), "%s/%s", + opal_asprintf(&(f_set->remote_target), "%s/%s", global_loc, ref); } diff --git a/orte/mca/state/base/base.h b/orte/mca/state/base/base.h index 6202392c77..c027da226a 100644 --- a/orte/mca/state/base/base.h +++ b/orte/mca/state/base/base.h @@ -1,6 +1,7 @@ /* * Copyright (c) 2011-2013 Los Alamos National Security, LLC. * All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -20,6 +21,7 @@ #include "orte/constants.h" #include "opal/class/opal_list.h" +#include "opal/util/printf.h" #include "orte/mca/mca.h" #include "orte/mca/state/state.h" diff --git a/orte/mca/state/base/state_base_fns.c b/orte/mca/state/base/state_base_fns.c index dbd04739fd..accda8edd3 100644 --- a/orte/mca/state/base/state_base_fns.c +++ b/orte/mca/state/base/state_base_fns.c @@ -1118,9 +1118,9 @@ void orte_state_base_check_fds(orte_job_t *jdata) opal_argv_free(list); list = NULL; if (NULL == result) { - asprintf(&result, " %d\t(%s)\t%s\n", i, info, status); + opal_asprintf(&result, " %d\t(%s)\t%s\n", i, info, status); } else { - asprintf(&r2, "%s %d\t(%s)\t%s\n", result, i, info, status); + opal_asprintf(&r2, "%s %d\t(%s)\t%s\n", result, i, info, status); free(result); result = r2; } @@ -1128,7 +1128,7 @@ void orte_state_base_check_fds(orte_job_t *jdata) } ++cnt; } - asprintf(&r2, "%s: %d open file descriptors after job %d completed\n%s", + opal_asprintf(&r2, "%s: %d open file descriptors after job %d completed\n%s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), cnt, ORTE_LOCAL_JOBID(jdata->jobid), result); opal_output(0, "%s", r2); free(result); diff --git a/orte/orted/orted_main.c b/orte/orted/orted_main.c index 89191c4352..b8f995ef52 100644 --- a/orte/orted/orted_main.c +++ b/orte/orted/orted_main.c @@ -623,7 +623,7 @@ int orte_daemon(int argc, char *argv[]) ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND); goto DONE; } - asprintf(&env_str, OPAL_MCA_PREFIX"orte_precondition_transports=%s", string_key); + opal_asprintf(&env_str, OPAL_MCA_PREFIX"orte_precondition_transports=%s", string_key); opal_argv_append_nosize(&singenv, env_str); free(env_str); @@ -632,7 +632,7 @@ int orte_daemon(int argc, char *argv[]) /* create a string that contains our uri + sysinfo + PMIx server URI envars */ orte_util_convert_sysinfo_to_string(&sysinfo, orte_local_cpu_type, orte_local_cpu_model); - asprintf(&tmp, "%s[%s]%s", orte_process_info.my_daemon_uri, sysinfo, nptr); + opal_asprintf(&tmp, "%s[%s]%s", orte_process_info.my_daemon_uri, sysinfo, nptr); free(sysinfo); free(nptr); diff --git a/orte/orted/orted_submit.c b/orte/orted/orted_submit.c index 5b8b0242c3..564a5a05cb 100644 --- a/orte/orted/orted_submit.c +++ b/orte/orted/orted_submit.c @@ -889,12 +889,12 @@ int orte_submit_job(char *argv[], int *index, ORTE_SET_MAPPING_POLICY(jdata->map->mapping, ORTE_MAPPING_PPR); ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_GIVEN); /* define the ppr */ - (void)asprintf(&jdata->map->ppr, "%d:node", orte_cmd_options.npernode); + opal_asprintf(&jdata->map->ppr, "%d:node", orte_cmd_options.npernode); } else if (0 < orte_cmd_options.npersocket) { ORTE_SET_MAPPING_POLICY(jdata->map->mapping, ORTE_MAPPING_PPR); ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_GIVEN); /* define the ppr */ - (void)asprintf(&jdata->map->ppr, "%d:socket", orte_cmd_options.npersocket); + opal_asprintf(&jdata->map->ppr, "%d:socket", orte_cmd_options.npersocket); } @@ -1090,7 +1090,7 @@ int orte_submit_job(char *argv[], int *index, oldenv = getenv("PATH"); if (NULL != oldenv) { char *temp; - asprintf(&temp, "%s:%s", newenv, oldenv ); + opal_asprintf(&temp, "%s:%s", newenv, oldenv ); free( newenv ); newenv = temp; } @@ -1106,7 +1106,7 @@ int orte_submit_job(char *argv[], int *index, oldenv = getenv("LD_LIBRARY_PATH"); if (NULL != oldenv) { char* temp; - asprintf(&temp, "%s:%s", newenv, oldenv); + opal_asprintf(&temp, "%s:%s", newenv, oldenv); free(newenv); newenv = temp; } @@ -1727,9 +1727,9 @@ static int create_app(int argc, char* argv[], if (NULL == strstr(app->argv[i], opal_install_dirs.libdir)) { /* doesn't appear to - add it to be safe */ if (':' == app->argv[i][strlen(app->argv[i]-1)]) { - asprintf(&value, "-Djava.library.path=%s%s", dptr, opal_install_dirs.libdir); + opal_asprintf(&value, "-Djava.library.path=%s%s", dptr, opal_install_dirs.libdir); } else { - asprintf(&value, "-Djava.library.path=%s:%s", dptr, opal_install_dirs.libdir); + opal_asprintf(&value, "-Djava.library.path=%s:%s", dptr, opal_install_dirs.libdir); } free(app->argv[i]); app->argv[i] = value; @@ -1739,7 +1739,7 @@ static int create_app(int argc, char* argv[], } if (!found) { /* need to add it right after the java command */ - asprintf(&value, "-Djava.library.path=%s", opal_install_dirs.libdir); + opal_asprintf(&value, "-Djava.library.path=%s", opal_install_dirs.libdir); opal_argv_insert_element(&app->argv, 1, value); free(value); } @@ -1764,7 +1764,7 @@ static int create_app(int argc, char* argv[], } free(value); /* always add the local directory */ - asprintf(&value, "%s:%s", app->cwd, app->argv[i+1]); + opal_asprintf(&value, "%s:%s", app->cwd, app->argv[i+1]); free(app->argv[i+1]); app->argv[i+1] = value; break; @@ -1791,7 +1791,7 @@ static int create_app(int argc, char* argv[], } free(value); /* always add the local directory */ - (void)asprintf(&value, "%s:%s", app->cwd, app->argv[1]); + opal_asprintf(&value, "%s:%s", app->cwd, app->argv[1]); free(app->argv[1]); app->argv[1] = value; opal_argv_insert_element(&app->argv, 1, "-cp"); @@ -1810,7 +1810,7 @@ static int create_app(int argc, char* argv[], /* check for mpi.jar */ value = opal_os_path(false, opal_install_dirs.libdir, "mpi.jar", NULL); if (access(value, F_OK ) != -1) { - (void)asprintf(&str2, "%s:%s", str, value); + opal_asprintf(&str2, "%s:%s", str, value); free(str); str = str2; } @@ -1818,7 +1818,7 @@ static int create_app(int argc, char* argv[], /* check for shmem.jar */ value = opal_os_path(false, opal_install_dirs.libdir, "shmem.jar", NULL); if (access(value, F_OK ) != -1) { - asprintf(&str2, "%s:%s", str, value); + opal_asprintf(&str2, "%s:%s", str, value); free(str); str = str2; } @@ -1881,7 +1881,7 @@ static void set_classpath_jar_file(orte_app_context_t *app, int index, char *jar char *fmt = ':' == app->argv[index][strlen(app->argv[index]-1)] ? "%s%s/%s" : "%s:%s/%s"; char *str; - asprintf(&str, fmt, app->argv[index], opal_install_dirs.libdir, jarfile); + opal_asprintf(&str, fmt, app->argv[index], opal_install_dirs.libdir, jarfile); free(app->argv[index]); app->argv[index] = str; } @@ -2732,7 +2732,7 @@ static int process(char *orig_line, char *basename, opal_cmd_line_t *cmd_line, } } else if (0 == strcmp(line_argv[i], "@np@")) { used_num_procs = true; - asprintf(&tmp, "%d", num_procs); + opal_asprintf(&tmp, "%d", num_procs); opal_argv_append_nosize(new_argv, tmp); free(tmp); } else if (0 == strcmp(line_argv[i], "@single_app@")) { diff --git a/orte/orted/pmix/pmix_server.c b/orte/orted/pmix/pmix_server.c index ec38988150..ee4f7f4d45 100644 --- a/orte/orted/pmix/pmix_server.c +++ b/orte/orted/pmix/pmix_server.c @@ -59,6 +59,7 @@ #include "opal/util/output.h" #include "opal/util/os_path.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "orte/mca/errmgr/errmgr.h" #include "orte/mca/grpcomm/grpcomm.h" @@ -514,7 +515,7 @@ static void pmix_server_dmdx_recv(int status, orte_process_name_t* sender, * condition, so just log the request and we will fill * it later */ req = OBJ_NEW(pmix_server_req_t); - (void)asprintf(&req->operation, "DMDX: %s:%d", __FILE__, __LINE__); + opal_asprintf(&req->operation, "DMDX: %s:%d", __FILE__, __LINE__); req->proxy = *sender; req->target = idreq; req->remote_room_num = room_num; @@ -541,7 +542,7 @@ static void pmix_server_dmdx_recv(int status, orte_process_name_t* sender, /* track the request since the call down to the PMIx server * is asynchronous */ req = OBJ_NEW(pmix_server_req_t); - (void)asprintf(&req->operation, "DMDX: %s:%d", __FILE__, __LINE__); + opal_asprintf(&req->operation, "DMDX: %s:%d", __FILE__, __LINE__); req->proxy = *sender; req->target = idreq; req->remote_room_num = room_num; diff --git a/orte/orted/pmix/pmix_server_internal.h b/orte/orted/pmix/pmix_server_internal.h index 49ba8a1982..11fe070a0c 100644 --- a/orte/orted/pmix/pmix_server_internal.h +++ b/orte/orted/pmix/pmix_server_internal.h @@ -12,7 +12,7 @@ * Copyright (c) 2006-2013 Los Alamos National Security, LLC. * All rights reserved. * Copyright (c) 2010-2011 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2014 Research Organization for Information Science @@ -42,6 +42,7 @@ #include "opal/mca/base/base.h" #include "opal/mca/event/event.h" #include "opal/mca/pmix/pmix.h" +#include "opal/util/printf.h" #include "opal/util/proc.h" #include "opal/sys/atomic.h" @@ -114,7 +115,7 @@ OBJ_CLASS_DECLARATION(orte_pmix_mdx_caddy_t); do { \ pmix_server_req_t *_req; \ _req = OBJ_NEW(pmix_server_req_t); \ - (void)asprintf(&_req->operation, "DMDX: %s:%d", __FILE__, __LINE__); \ + opal_asprintf(&_req->operation, "DMDX: %s:%d", __FILE__, __LINE__); \ _req->target = (p); \ _req->mdxcbfunc = (ocf); \ _req->cbdata = (ocd); \ @@ -129,7 +130,7 @@ OBJ_CLASS_DECLARATION(orte_pmix_mdx_caddy_t); do { \ pmix_server_req_t *_req; \ _req = OBJ_NEW(pmix_server_req_t); \ - (void)asprintf(&_req->operation, "SPAWN: %s:%d", __FILE__, __LINE__); \ + opal_asprintf(&_req->operation, "SPAWN: %s:%d", __FILE__, __LINE__); \ _req->jdata = (j); \ _req->spcbfunc = (ocf); \ _req->cbdata = (ocd); \ diff --git a/orte/orted/pmix/pmix_server_pub.c b/orte/orted/pmix/pmix_server_pub.c index 0b26936854..db1b44e2a5 100644 --- a/orte/orted/pmix/pmix_server_pub.c +++ b/orte/orted/pmix/pmix_server_pub.c @@ -13,7 +13,7 @@ * All rights reserved. * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2014-2016 Research Organization for Information Science @@ -241,7 +241,7 @@ int pmix_server_publish_fn(opal_process_name_t *proc, /* create the caddy */ req = OBJ_NEW(pmix_server_req_t); - (void)asprintf(&req->operation, "PUBLISH: %s:%d", __FILE__, __LINE__); + opal_asprintf(&req->operation, "PUBLISH: %s:%d", __FILE__, __LINE__); req->opcbfunc = cbfunc; req->cbdata = cbdata; @@ -342,7 +342,7 @@ int pmix_server_lookup_fn(opal_process_name_t *proc, char **keys, /* create the caddy */ req = OBJ_NEW(pmix_server_req_t); - (void)asprintf(&req->operation, "LOOKUP: %s:%d", __FILE__, __LINE__); + opal_asprintf(&req->operation, "LOOKUP: %s:%d", __FILE__, __LINE__); req->lkcbfunc = cbfunc; req->cbdata = cbdata; @@ -439,7 +439,7 @@ int pmix_server_unpublish_fn(opal_process_name_t *proc, char **keys, /* create the caddy */ req = OBJ_NEW(pmix_server_req_t); - (void)asprintf(&req->operation, "UNPUBLISH: %s:%d", __FILE__, __LINE__); + opal_asprintf(&req->operation, "UNPUBLISH: %s:%d", __FILE__, __LINE__); req->opcbfunc = cbfunc; req->cbdata = cbdata; diff --git a/orte/runtime/data_type_support/orte_dt_print_fns.c b/orte/runtime/data_type_support/orte_dt_print_fns.c index fbcfa69850..d2f202752f 100644 --- a/orte/runtime/data_type_support/orte_dt_print_fns.c +++ b/orte/runtime/data_type_support/orte_dt_print_fns.c @@ -55,7 +55,7 @@ static void orte_dt_quick_print(char **output, char *type_name, char *prefix, vo /* check for NULL ptr */ if (NULL == src) { - asprintf(output, "%sData type: %s\tData size: 8-bit\tValue: NULL pointer", + opal_asprintf(output, "%sData type: %s\tData size: 8-bit\tValue: NULL pointer", (NULL == prefix) ? "" : prefix, type_name); return; } @@ -63,49 +63,49 @@ static void orte_dt_quick_print(char **output, char *type_name, char *prefix, vo switch(real_type) { case OPAL_INT8: i8 = (int8_t*)src; - asprintf(output, "%sData type: %s\tData size: 8-bit\tValue: %d", + opal_asprintf(output, "%sData type: %s\tData size: 8-bit\tValue: %d", (NULL == prefix) ? "" : prefix, type_name, (int) *i8); break; case OPAL_UINT8: ui8 = (uint8_t*)src; - asprintf(output, "%sData type: %s\tData size: 8-bit\tValue: %u", + opal_asprintf(output, "%sData type: %s\tData size: 8-bit\tValue: %u", (NULL == prefix) ? "" : prefix, type_name, (unsigned int)*ui8); break; case OPAL_INT16: i16 = (int16_t*)src; - asprintf(output, "%sData type: %s\tData size: 16-bit\tValue: %d", + opal_asprintf(output, "%sData type: %s\tData size: 16-bit\tValue: %d", (NULL == prefix) ? "" : prefix, type_name, (int) *i16); break; case OPAL_UINT16: ui16 = (uint16_t*)src; - asprintf(output, "%sData type: %s\tData size: 16-bit\tValue: %u", + opal_asprintf(output, "%sData type: %s\tData size: 16-bit\tValue: %u", (NULL == prefix) ? "" : prefix, type_name, (unsigned int) *ui16); break; case OPAL_INT32: i32 = (int32_t*)src; - asprintf(output, "%sData type: %s\tData size: 32-bit\tValue: %ld", + opal_asprintf(output, "%sData type: %s\tData size: 32-bit\tValue: %ld", (NULL == prefix) ? "" : prefix, type_name, (long) *i32); break; case OPAL_UINT32: ui32 = (uint32_t*)src; - asprintf(output, "%sData type: %s\tData size: 32-bit\tValue: %lu", + opal_asprintf(output, "%sData type: %s\tData size: 32-bit\tValue: %lu", (NULL == prefix) ? "" : prefix, type_name, (unsigned long) *ui32); break; case OPAL_INT64: i64 = (int64_t*)src; - asprintf(output, "%sData type: %s\tData size: 64-bit\tValue: %ld", + opal_asprintf(output, "%sData type: %s\tData size: 64-bit\tValue: %ld", (NULL == prefix) ? "" : prefix, type_name, (long) *i64); break; case OPAL_UINT64: ui64 = (uint64_t*)src; - asprintf(output, "%sData type: %s\tData size: 64-bit\tValue: %lu", + opal_asprintf(output, "%sData type: %s\tData size: 64-bit\tValue: %lu", (NULL == prefix) ? "" : prefix, type_name, (unsigned long) *ui64); break; @@ -181,13 +181,13 @@ int orte_dt_print_job(char **output, char *prefix, orte_job_t *src, opal_data_ty /* protect against NULL prefix */ if (NULL == prefix) { - asprintf(&pfx2, " "); + opal_asprintf(&pfx2, " "); } else { - asprintf(&pfx2, "%s", prefix); + opal_asprintf(&pfx2, "%s", prefix); } tmp2 = opal_argv_join(src->personality, ','); - asprintf(&tmp, "\n%sData for job: %s\tPersonality: %s\tRecovery: %s(%s)\n%s\tNum apps: %ld\tStdin target: %s\tState: %s\tAbort: %s", pfx2, + opal_asprintf(&tmp, "\n%sData for job: %s\tPersonality: %s\tRecovery: %s(%s)\n%s\tNum apps: %ld\tStdin target: %s\tState: %s\tAbort: %s", pfx2, ORTE_JOBID_PRINT(src->jobid), tmp2, (ORTE_FLAG_TEST(src, ORTE_JOB_FLAG_RECOVERABLE)) ? "ENABLED" : "DISABLED", (orte_get_attribute(&src->attributes, ORTE_JOB_RECOVER_DEFINED, NULL, OPAL_BOOL)) ? "DEFINED" : "DEFAULT", @@ -195,7 +195,7 @@ int orte_dt_print_job(char **output, char *prefix, orte_job_t *src, opal_data_ty (long)src->num_apps, ORTE_VPID_PRINT(src->stdin_target), orte_job_state_to_str(src->state), (ORTE_FLAG_TEST(src, ORTE_JOB_FLAG_ABORTED)) ? "True" : "False"); free(tmp2); - asprintf(&pfx, "%s\t", pfx2); + opal_asprintf(&pfx, "%s\t", pfx2); free(pfx2); for (i=0; i < src->apps->size; i++) { @@ -203,7 +203,7 @@ int orte_dt_print_job(char **output, char *prefix, orte_job_t *src, opal_data_ty continue; } opal_dss.print(&tmp2, pfx, app, ORTE_APP_CONTEXT); - asprintf(&tmp3, "%s\n%s", tmp, tmp2); + opal_asprintf(&tmp3, "%s\n%s", tmp, tmp2); free(tmp); free(tmp2); tmp = tmp3; @@ -214,17 +214,17 @@ int orte_dt_print_job(char **output, char *prefix, orte_job_t *src, opal_data_ty ORTE_ERROR_LOG(rc); return rc; } - asprintf(&tmp3, "%s%s", tmp, tmp2); + opal_asprintf(&tmp3, "%s%s", tmp, tmp2); free(tmp); free(tmp2); tmp = tmp3; } else { - asprintf(&tmp2, "%s\n%sNo Map", tmp, pfx); + opal_asprintf(&tmp2, "%s\n%sNo Map", tmp, pfx); free(tmp); tmp = tmp2; } - asprintf(&tmp2, "%s\n%sNum procs: %ld\tOffset: %ld", tmp, pfx, (long)src->num_procs, (long)src->offset); + opal_asprintf(&tmp2, "%s\n%sNum procs: %ld\tOffset: %ld", tmp, pfx, (long)src->num_procs, (long)src->offset); free(tmp); tmp = tmp2; @@ -236,13 +236,13 @@ int orte_dt_print_job(char **output, char *prefix, orte_job_t *src, opal_data_ty ORTE_ERROR_LOG(rc); return rc; } - asprintf(&tmp3, "%s%s", tmp, tmp2); + opal_asprintf(&tmp3, "%s%s", tmp, tmp2); free(tmp); free(tmp2); tmp = tmp3; } - asprintf(&tmp2, "%s\n%s\tNum launched: %ld\tNum reported: %ld\tNum terminated: %ld", + opal_asprintf(&tmp2, "%s\n%s\tNum launched: %ld\tNum reported: %ld\tNum terminated: %ld", tmp, pfx, (long)src->num_launched, (long)src->num_reported, (long)src->num_terminated); free(tmp); @@ -270,14 +270,14 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_ /* protect against NULL prefix */ if (NULL == prefix) { - asprintf(&pfx2, " "); + opal_asprintf(&pfx2, " "); } else { - asprintf(&pfx2, "%s", prefix); + opal_asprintf(&pfx2, "%s", prefix); } if (orte_xml_output) { /* need to create the output in XML format */ - asprintf(&tmp, "%s\n", pfx2, + opal_asprintf(&tmp, "%s\n", pfx2, (NULL == src->name) ? "UNKNOWN" : src->name, (int)src->slots, (int)src->slots_max); /* does this node have any aliases? */ @@ -285,7 +285,7 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_ if (orte_get_attribute(&src->attributes, ORTE_NODE_ALIAS, (void**)&tmp3, OPAL_STRING)) { alias = opal_argv_split(tmp3, ','); for (i=0; NULL != alias[i]; i++) { - asprintf(&tmp2, "%s%s\t\n", tmp, pfx2, alias[i]); + opal_asprintf(&tmp2, "%s%s\t\n", tmp, pfx2, alias[i]); free(tmp); tmp = tmp2; } @@ -303,7 +303,7 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_ /* just provide a simple output for users */ if (0 == src->num_procs) { /* no procs mapped yet, so just show allocation */ - asprintf(&tmp, "\n%sData for node: %s\tNum slots: %ld\tMax slots: %ld", + opal_asprintf(&tmp, "\n%sData for node: %s\tNum slots: %ld\tMax slots: %ld", pfx2, (NULL == src->name) ? "UNKNOWN" : src->name, (long)src->slots, (long)src->slots_max); /* does this node have any aliases? */ @@ -311,7 +311,7 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_ if (orte_get_attribute(&src->attributes, ORTE_NODE_ALIAS, (void**)&tmp3, OPAL_STRING)) { alias = opal_argv_split(tmp3, ','); for (i=0; NULL != alias[i]; i++) { - asprintf(&tmp2, "%s%s\tresolved from %s\n", tmp, pfx2, alias[i]); + opal_asprintf(&tmp2, "%s%s\tresolved from %s\n", tmp, pfx2, alias[i]); free(tmp); tmp = tmp2; } @@ -324,7 +324,7 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_ *output = tmp; return ORTE_SUCCESS; } - asprintf(&tmp, "\n%sData for node: %s\tNum slots: %ld\tMax slots: %ld\tNum procs: %ld", + opal_asprintf(&tmp, "\n%sData for node: %s\tNum slots: %ld\tMax slots: %ld\tNum procs: %ld", pfx2, (NULL == src->name) ? "UNKNOWN" : src->name, (long)src->slots, (long)src->slots_max, (long)src->num_procs); /* does this node have any aliases? */ @@ -332,7 +332,7 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_ if (orte_get_attribute(&src->attributes, ORTE_NODE_ALIAS, (void**)&tmp3, OPAL_STRING)) { alias = opal_argv_split(tmp3, ','); for (i=0; NULL != alias[i]; i++) { - asprintf(&tmp2, "%s%s\tresolved from %s\n", tmp, pfx2, alias[i]); + opal_asprintf(&tmp2, "%s%s\tresolved from %s\n", tmp, pfx2, alias[i]); free(tmp); tmp = tmp2; } @@ -344,14 +344,14 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_ goto PRINT_PROCS; } - asprintf(&tmp, "\n%sData for node: %s\tState: %0x\tFlags: %02x", + opal_asprintf(&tmp, "\n%sData for node: %s\tState: %0x\tFlags: %02x", pfx2, (NULL == src->name) ? "UNKNOWN" : src->name, src->state, src->flags); /* does this node have any aliases? */ tmp3 = NULL; if (orte_get_attribute(&src->attributes, ORTE_NODE_ALIAS, (void**)&tmp3, OPAL_STRING)) { alias = opal_argv_split(tmp3, ','); for (i=0; NULL != alias[i]; i++) { - asprintf(&tmp2, "%s%s\tresolved from %s\n", tmp, pfx2, alias[i]); + opal_asprintf(&tmp2, "%s%s\tresolved from %s\n", tmp, pfx2, alias[i]); free(tmp); tmp = tmp2; } @@ -362,30 +362,30 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_ } if (NULL == src->daemon) { - asprintf(&tmp2, "%s\n%s\tDaemon: %s\tDaemon launched: %s", tmp, pfx2, + opal_asprintf(&tmp2, "%s\n%s\tDaemon: %s\tDaemon launched: %s", tmp, pfx2, "Not defined", ORTE_FLAG_TEST(src, ORTE_NODE_FLAG_DAEMON_LAUNCHED) ? "True" : "False"); } else { - asprintf(&tmp2, "%s\n%s\tDaemon: %s\tDaemon launched: %s", tmp, pfx2, + opal_asprintf(&tmp2, "%s\n%s\tDaemon: %s\tDaemon launched: %s", tmp, pfx2, ORTE_NAME_PRINT(&(src->daemon->name)), ORTE_FLAG_TEST(src, ORTE_NODE_FLAG_DAEMON_LAUNCHED) ? "True" : "False"); } free(tmp); tmp = tmp2; - asprintf(&tmp2, "%s\n%s\tNum slots: %ld\tSlots in use: %ld\tOversubscribed: %s", tmp, pfx2, + opal_asprintf(&tmp2, "%s\n%s\tNum slots: %ld\tSlots in use: %ld\tOversubscribed: %s", tmp, pfx2, (long)src->slots, (long)src->slots_inuse, ORTE_FLAG_TEST(src, ORTE_NODE_FLAG_OVERSUBSCRIBED) ? "TRUE" : "FALSE"); free(tmp); tmp = tmp2; - asprintf(&tmp2, "%s\n%s\tNum slots allocated: %ld\tMax slots: %ld", tmp, pfx2, + opal_asprintf(&tmp2, "%s\n%s\tNum slots allocated: %ld\tMax slots: %ld", tmp, pfx2, (long)src->slots, (long)src->slots_max); free(tmp); tmp = tmp2; tmp3 = NULL; if (orte_get_attribute(&src->attributes, ORTE_NODE_USERNAME, (void**)&tmp3, OPAL_STRING)) { - asprintf(&tmp2, "%s\n%s\tUsername on node: %s", tmp, pfx2, tmp3); + opal_asprintf(&tmp2, "%s\n%s\tUsername on node: %s", tmp, pfx2, tmp3); free(tmp3); free(tmp); tmp = tmp2; @@ -393,27 +393,27 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_ if (orte_display_topo_with_map && NULL != src->topology) { char *pfx3; - asprintf(&tmp2, "%s\n%s\tDetected Resources:\n", tmp, pfx2); + opal_asprintf(&tmp2, "%s\n%s\tDetected Resources:\n", tmp, pfx2); free(tmp); tmp = tmp2; tmp2 = NULL; - asprintf(&pfx3, "%s\t\t", pfx2); + opal_asprintf(&pfx3, "%s\t\t", pfx2); opal_dss.print(&tmp2, pfx3, src->topology, OPAL_HWLOC_TOPO); free(pfx3); - asprintf(&tmp3, "%s%s", tmp, tmp2); + opal_asprintf(&tmp3, "%s%s", tmp, tmp2); free(tmp); free(tmp2); tmp = tmp3; } - asprintf(&tmp2, "%s\n%s\tNum procs: %ld\tNext node_rank: %ld", tmp, pfx2, + opal_asprintf(&tmp2, "%s\n%s\tNum procs: %ld\tNext node_rank: %ld", tmp, pfx2, (long)src->num_procs, (long)src->next_node_rank); free(tmp); tmp = tmp2; PRINT_PROCS: - asprintf(&pfx, "%s\t", pfx2); + opal_asprintf(&pfx, "%s\t", pfx2); free(pfx2); for (i=0; i < src->procs->size; i++) { @@ -424,7 +424,7 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_ ORTE_ERROR_LOG(rc); return rc; } - asprintf(&tmp3, "%s%s", tmp, tmp2); + opal_asprintf(&tmp3, "%s%s", tmp, tmp2); free(tmp); free(tmp2); tmp = tmp3; @@ -454,18 +454,18 @@ int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_ /* protect against NULL prefix */ if (NULL == prefix) { - asprintf(&pfx2, " "); + opal_asprintf(&pfx2, " "); } else { - asprintf(&pfx2, "%s", prefix); + opal_asprintf(&pfx2, "%s", prefix); } if (orte_xml_output) { /* need to create the output in XML format */ if (0 == src->pid) { - asprintf(output, "%s\n", pfx2, + opal_asprintf(output, "%s\n", pfx2, ORTE_VPID_PRINT(src->name.vpid), orte_proc_state_to_str(src->state)); } else { - asprintf(output, "%s\n", pfx2, + opal_asprintf(output, "%s\n", pfx2, ORTE_VPID_PRINT(src->name.vpid), (int)src->pid, orte_proc_state_to_str(src->state)); } free(pfx2); @@ -481,10 +481,10 @@ int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_ str = strdup("UNBOUND"); } else { opal_hwloc_base_cset2mapstr(tmp2, sizeof(tmp2), src->node->topology->topo, mycpus); - asprintf(&str, "%s:%s", tmp1, tmp2); + opal_asprintf(&str, "%s:%s", tmp1, tmp2); } hwloc_bitmap_free(mycpus); - asprintf(&tmp, "\n%sProcess OMPI jobid: %s App: %ld Process rank: %s Bound: %s", pfx2, + opal_asprintf(&tmp, "\n%sProcess OMPI jobid: %s App: %ld Process rank: %s Bound: %s", pfx2, ORTE_JOBID_PRINT(src->name.jobid), (long)src->app_idx, ORTE_VPID_PRINT(src->name.vpid), (NULL == str) ? "N/A" : str); if (NULL != str) { @@ -495,7 +495,7 @@ int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_ } } else { /* just print a very simple output for users */ - asprintf(&tmp, "\n%sProcess OMPI jobid: %s App: %ld Process rank: %s Bound: N/A", pfx2, + opal_asprintf(&tmp, "\n%sProcess OMPI jobid: %s App: %ld Process rank: %s Bound: N/A", pfx2, ORTE_JOBID_PRINT(src->name.jobid), (long)src->app_idx, ORTE_VPID_PRINT(src->name.vpid)); } @@ -506,9 +506,9 @@ int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_ return ORTE_SUCCESS; } - asprintf(&tmp, "\n%sData for proc: %s", pfx2, ORTE_NAME_PRINT(&src->name)); + opal_asprintf(&tmp, "\n%sData for proc: %s", pfx2, ORTE_NAME_PRINT(&src->name)); - asprintf(&tmp3, "%s\n%s\tPid: %ld\tLocal rank: %lu\tNode rank: %lu\tApp rank: %d", tmp, pfx2, + opal_asprintf(&tmp3, "%s\n%s\tPid: %ld\tLocal rank: %lu\tNode rank: %lu\tApp rank: %d", tmp, pfx2, (long)src->pid, (unsigned long)src->local_rank, (unsigned long)src->node_rank, src->app_rank); free(tmp); tmp = tmp3; @@ -532,7 +532,7 @@ int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_ } else { snprintf(tmp2, sizeof(tmp2), "UNBOUND"); } - asprintf(&tmp3, "%s\n%s\tState: %s\tApp_context: %ld\n%s\tLocale: %s\n%s\tBinding: %s", tmp, pfx2, + opal_asprintf(&tmp3, "%s\n%s\tState: %s\tApp_context: %ld\n%s\tLocale: %s\n%s\tBinding: %s", tmp, pfx2, orte_proc_state_to_str(src->state), (long)src->app_idx, pfx2, locale, pfx2, tmp2); free(tmp); if (NULL != str) { @@ -563,12 +563,12 @@ int orte_dt_print_app_context(char **output, char *prefix, orte_app_context_t *s /* protect against NULL prefix */ if (NULL == prefix) { - asprintf(&pfx2, " "); + opal_asprintf(&pfx2, " "); } else { - asprintf(&pfx2, "%s", prefix); + opal_asprintf(&pfx2, "%s", prefix); } - asprintf(&tmp, "\n%sData for app_context: index %lu\tapp: %s\n%s\tNum procs: %lu\tFirstRank: %s", + opal_asprintf(&tmp, "\n%sData for app_context: index %lu\tapp: %s\n%s\tNum procs: %lu\tFirstRank: %s", pfx2, (unsigned long)src->idx, (NULL == src->app) ? "NULL" : src->app, pfx2, (unsigned long)src->num_procs, @@ -576,21 +576,21 @@ int orte_dt_print_app_context(char **output, char *prefix, orte_app_context_t *s count = opal_argv_count(src->argv); for (i=0; i < count; i++) { - asprintf(&tmp2, "%s\n%s\tArgv[%d]: %s", tmp, pfx2, i, src->argv[i]); + opal_asprintf(&tmp2, "%s\n%s\tArgv[%d]: %s", tmp, pfx2, i, src->argv[i]); free(tmp); tmp = tmp2; } count = opal_argv_count(src->env); for (i=0; i < count; i++) { - asprintf(&tmp2, "%s\n%s\tEnv[%lu]: %s", tmp, pfx2, (unsigned long)i, src->env[i]); + opal_asprintf(&tmp2, "%s\n%s\tEnv[%lu]: %s", tmp, pfx2, (unsigned long)i, src->env[i]); free(tmp); tmp = tmp2; } tmp3 = NULL; orte_get_attribute(&src->attributes, ORTE_APP_PREFIX_DIR, (void**)&tmp3, OPAL_STRING); - asprintf(&tmp2, "%s\n%s\tWorking dir: %s\n%s\tPrefix: %s\n%s\tUsed on node: %s", tmp, + opal_asprintf(&tmp2, "%s\n%s\tWorking dir: %s\n%s\tPrefix: %s\n%s\tUsed on node: %s", tmp, pfx2, (NULL == src->cwd) ? "NULL" : src->cwd, pfx2, (NULL == tmp3) ? "NULL" : tmp3, pfx2, ORTE_FLAG_TEST(src, ORTE_APP_FLAG_USED_ON_NODE) ? "TRUE" : "FALSE"); @@ -599,7 +599,7 @@ int orte_dt_print_app_context(char **output, char *prefix, orte_app_context_t *s OPAL_LIST_FOREACH(kv, &src->attributes, opal_value_t) { opal_dss.print(&tmp2, pfx2, kv, ORTE_ATTRIBUTE); - asprintf(&tmp3, "%s\n%s", tmp, tmp2); + opal_asprintf(&tmp3, "%s\n%s", tmp, tmp2); free(tmp2); free(tmp); tmp = tmp3; @@ -628,21 +628,21 @@ int orte_dt_print_map(char **output, char *prefix, orte_job_map_t *src, opal_dat /* protect against NULL prefix */ if (NULL == prefix) { - asprintf(&pfx2, " "); + opal_asprintf(&pfx2, " "); } else { - asprintf(&pfx2, "%s", prefix); + opal_asprintf(&pfx2, "%s", prefix); } if (orte_xml_output) { /* need to create the output in XML format */ - asprintf(&tmp, "\n"); + opal_asprintf(&tmp, "\n"); /* loop through nodes */ for (i=0; i < src->nodes->size; i++) { if (NULL == (node = (orte_node_t*)opal_pointer_array_get_item(src->nodes, i))) { continue; } orte_dt_print_node(&tmp2, "\t", node, ORTE_NODE); - asprintf(&tmp3, "%s%s", tmp, tmp2); + opal_asprintf(&tmp3, "%s%s", tmp, tmp2); free(tmp2); free(tmp); tmp = tmp3; @@ -652,16 +652,16 @@ int orte_dt_print_map(char **output, char *prefix, orte_job_map_t *src, opal_dat continue; } orte_dt_print_proc(&tmp2, "\t\t", proc, ORTE_PROC); - asprintf(&tmp3, "%s%s", tmp, tmp2); + opal_asprintf(&tmp3, "%s%s", tmp, tmp2); free(tmp2); free(tmp); tmp = tmp3; } - asprintf(&tmp3, "%s\t\n", tmp); + opal_asprintf(&tmp3, "%s\t\n", tmp); free(tmp); tmp = tmp3; } - asprintf(&tmp2, "%s\n", tmp); + opal_asprintf(&tmp2, "%s\n", tmp); free(tmp); free(pfx2); *output = tmp2; @@ -669,10 +669,10 @@ int orte_dt_print_map(char **output, char *prefix, orte_job_map_t *src, opal_dat } - asprintf(&pfx, "%s\t", pfx2); + opal_asprintf(&pfx, "%s\t", pfx2); if (orte_devel_level_output) { - asprintf(&tmp, "\n%sMapper requested: %s Last mapper: %s Mapping policy: %s Ranking policy: %s\n%sBinding policy: %s Cpu set: %s PPR: %s Cpus-per-rank: %d", + opal_asprintf(&tmp, "\n%sMapper requested: %s Last mapper: %s Mapping policy: %s Ranking policy: %s\n%sBinding policy: %s Cpu set: %s PPR: %s Cpus-per-rank: %d", pfx2, (NULL == src->req_mapper) ? "NULL" : src->req_mapper, (NULL == src->last_mapper) ? "NULL" : src->last_mapper, orte_rmaps_base_print_mapping(src->mapping), @@ -683,10 +683,10 @@ int orte_dt_print_map(char **output, char *prefix, orte_job_map_t *src, opal_dat (int)src->cpus_per_rank); if (ORTE_VPID_INVALID == src->daemon_vpid_start) { - asprintf(&tmp2, "%s\n%sNum new daemons: %ld\tNew daemon starting vpid INVALID\n%sNum nodes: %ld", + opal_asprintf(&tmp2, "%s\n%sNum new daemons: %ld\tNew daemon starting vpid INVALID\n%sNum nodes: %ld", tmp, pfx, (long)src->num_new_daemons, pfx, (long)src->num_nodes); } else { - asprintf(&tmp2, "%s\n%sNum new daemons: %ld\tNew daemon starting vpid %ld\n%sNum nodes: %ld", + opal_asprintf(&tmp2, "%s\n%sNum new daemons: %ld\tNew daemon starting vpid %ld\n%sNum nodes: %ld", tmp, pfx, (long)src->num_new_daemons, (long)src->daemon_vpid_start, pfx, (long)src->num_nodes); } @@ -694,7 +694,7 @@ int orte_dt_print_map(char **output, char *prefix, orte_job_map_t *src, opal_dat tmp = tmp2; } else { /* this is being printed for a user, so let's make it easier to see */ - asprintf(&tmp, "\n%s======================== JOB MAP ========================", pfx2); + opal_asprintf(&tmp, "\n%s======================== JOB MAP ========================", pfx2); } @@ -708,7 +708,7 @@ int orte_dt_print_map(char **output, char *prefix, orte_job_map_t *src, opal_dat free(tmp); return rc; } - asprintf(&tmp3, "%s\n%s", tmp, tmp2); + opal_asprintf(&tmp3, "%s\n%s", tmp, tmp2); free(tmp); free(tmp2); tmp = tmp3; @@ -716,7 +716,7 @@ int orte_dt_print_map(char **output, char *prefix, orte_job_map_t *src, opal_dat if (!orte_devel_level_output) { /* this is being printed for a user, so let's make it easier to see */ - asprintf(&tmp2, "%s\n\n%s=============================================================\n", tmp, pfx2); + opal_asprintf(&tmp2, "%s\n\n%s=============================================================\n", tmp, pfx2); free(tmp); tmp = tmp2; } @@ -736,99 +736,99 @@ int orte_dt_print_attr(char **output, char *prefix, char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = strdup(prefix); /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: ORTE_ATTR\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: ORTE_ATTR\tValue: NULL pointer", prefx); free(prefx); return OPAL_SUCCESS; } switch (src->type) { case OPAL_STRING: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_STRING\tKey: %s\tValue: %s", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_STRING\tKey: %s\tValue: %s", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), src->data.string); break; case OPAL_SIZE: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_SIZE\tKey: %s\tValue: %lu", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_SIZE\tKey: %s\tValue: %lu", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned long)src->data.size); break; case OPAL_PID: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_PID\tKey: %s\tValue: %lu", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_PID\tKey: %s\tValue: %lu", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned long)src->data.pid); break; case OPAL_INT: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT\tKey: %s\tValue: %d", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT\tKey: %s\tValue: %d", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), src->data.integer); break; case OPAL_INT8: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT8\tKey: %s\tValue: %d", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT8\tKey: %s\tValue: %d", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (int)src->data.int8); break; case OPAL_INT16: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT16\tKey: %s\tValue: %d", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT16\tKey: %s\tValue: %d", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (int)src->data.int16); break; case OPAL_INT32: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT32\tKey: %s\tValue: %d", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT32\tKey: %s\tValue: %d", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), src->data.int32); break; case OPAL_INT64: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT64\tKey: %s\tValue: %d", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT64\tKey: %s\tValue: %d", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (int)src->data.int64); break; case OPAL_UINT: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT\tKey: %s\tValue: %u", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT\tKey: %s\tValue: %u", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned int)src->data.uint); break; case OPAL_UINT8: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT8\tKey: %s\tValue: %u", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT8\tKey: %s\tValue: %u", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned int)src->data.uint8); break; case OPAL_UINT16: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT16\tKey: %s\tValue: %u", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT16\tKey: %s\tValue: %u", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned int)src->data.uint16); break; case OPAL_UINT32: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT32\tKey: %s\tValue: %u", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT32\tKey: %s\tValue: %u", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), src->data.uint32); break; case OPAL_UINT64: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT64\tKey: %s\tValue: %lu", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT64\tKey: %s\tValue: %lu", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned long)src->data.uint64); break; case OPAL_BYTE_OBJECT: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_BYTE_OBJECT\tKey: %s\tValue: UNPRINTABLE", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_BYTE_OBJECT\tKey: %s\tValue: UNPRINTABLE", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key)); break; case OPAL_BUFFER: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_BUFFER\tKey: %s\tValue: UNPRINTABLE", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_BUFFER\tKey: %s\tValue: UNPRINTABLE", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key)); break; case OPAL_FLOAT: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_FLOAT\tKey: %s\tValue: %f", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_FLOAT\tKey: %s\tValue: %f", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), src->data.fval); break; case OPAL_TIMEVAL: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_TIMEVAL\tKey: %s\tValue: %ld.%06ld", prefx, + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_TIMEVAL\tKey: %s\tValue: %ld.%06ld", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (long)src->data.tv.tv_sec, (long)src->data.tv.tv_usec); break; case OPAL_PTR: - asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_PTR\tKey: %s", prefx, + opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_PTR\tKey: %s", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key)); break; case ORTE_VPID: - asprintf(output, "%sORTE_ATTR: %s Data type: ORTE_VPID\tKey: %s\tValue: %s", prefx, src->local ? "LOCAL" : "GLOBAL", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: ORTE_VPID\tKey: %s\tValue: %s", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), ORTE_VPID_PRINT(src->data.vpid)); break; case ORTE_JOBID: - asprintf(output, "%sORTE_ATTR: %s Data type: ORTE_JOBID\tKey: %s\tValue: %s", prefx, src->local ? "LOCAL" : "GLOBAL", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: ORTE_JOBID\tKey: %s\tValue: %s", prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), ORTE_JOBID_PRINT(src->data.jobid)); break; default: - asprintf(output, "%sORTE_ATTR: %s Data type: UNKNOWN\tKey: %s\tValue: UNPRINTABLE", + opal_asprintf(output, "%sORTE_ATTR: %s Data type: UNKNOWN\tKey: %s\tValue: UNPRINTABLE", prefx, orte_attr_key_to_str(src->key), src->local ? "LOCAL" : "GLOBAL"); break; } @@ -843,27 +843,27 @@ int orte_dt_print_sig(char **output, char *prefix, orte_grpcomm_signature_t *src char *tmp, *tmp2; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = strdup(prefix); /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: ORTE_SIG", prefx); + opal_asprintf(output, "%sData type: ORTE_SIG", prefx); free(prefx); return OPAL_SUCCESS; } if (NULL == src->signature) { - asprintf(output, "%sORTE_SIG Procs: NULL", prefx); + opal_asprintf(output, "%sORTE_SIG Procs: NULL", prefx); free(prefx); return ORTE_SUCCESS; } /* there must be at least one proc in the signature */ - asprintf(&tmp, "%sORTE_SIG Procs: ", prefx); + opal_asprintf(&tmp, "%sORTE_SIG Procs: ", prefx); for (i=0; i < src->sz; i++) { - asprintf(&tmp2, "%s%s", tmp, ORTE_NAME_PRINT(&src->signature[i])); + opal_asprintf(&tmp2, "%s%s", tmp, ORTE_NAME_PRINT(&src->signature[i])); free(tmp); tmp = tmp2; } diff --git a/orte/runtime/orte_info_support.c b/orte/runtime/orte_info_support.c index 32c811a410..9151664f11 100644 --- a/orte/runtime/orte_info_support.c +++ b/orte/runtime/orte_info_support.c @@ -14,6 +14,7 @@ * Copyright (c) 2010-2015 Los Alamos National Security, LLC. * All rights reserved. * Copyright (c) 2011-2012 University of Houston. All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -27,6 +28,7 @@ #include "opal/class/opal_pointer_array.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "opal/runtime/opal_info_support.h" #include "orte/include/orte/frameworks.h" @@ -97,7 +99,7 @@ void orte_info_show_orte_version(const char *scope) { char *tmp, *tmp2; - asprintf(&tmp, "%s:version:full", orte_info_type_orte); + opal_asprintf(&tmp, "%s:version:full", orte_info_type_orte); tmp2 = opal_info_make_version_str(scope, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION, ORTE_RELEASE_VERSION, @@ -106,11 +108,10 @@ void orte_info_show_orte_version(const char *scope) opal_info_out("Open RTE", tmp, tmp2); free(tmp); free(tmp2); - asprintf(&tmp, "%s:version:repo", orte_info_type_orte); + opal_asprintf(&tmp, "%s:version:repo", orte_info_type_orte); opal_info_out("Open RTE repo revision", tmp, ORTE_REPO_REV); free(tmp); - asprintf(&tmp, "%s:version:release_date", orte_info_type_orte); + opal_asprintf(&tmp, "%s:version:release_date", orte_info_type_orte); opal_info_out("Open RTE release date", tmp, ORTE_RELEASE_DATE); free(tmp); } - diff --git a/orte/runtime/orte_mca_params.c b/orte/runtime/orte_mca_params.c index caf6b59dab..ba29ef2fa7 100644 --- a/orte/runtime/orte_mca_params.c +++ b/orte/runtime/orte_mca_params.c @@ -37,6 +37,7 @@ #include "opal/mca/installdirs/installdirs.h" #include "opal/util/output.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "orte/util/proc_info.h" #include "orte/mca/errmgr/errmgr.h" @@ -380,7 +381,7 @@ int orte_register_params(void) if (NULL == orte_default_hostfile) { /* nothing was given, so define the default */ - asprintf(&orte_default_hostfile, "%s/openmpi-default-hostfile", opal_install_dirs.sysconfdir); + opal_asprintf(&orte_default_hostfile, "%s/openmpi-default-hostfile", opal_install_dirs.sysconfdir); /* flag that nothing was given */ orte_default_hostfile_given = false; } else if (0 == strcmp(orte_default_hostfile, "none")) { diff --git a/orte/test/mpi/concurrent_spawn.c b/orte/test/mpi/concurrent_spawn.c index 83bfc63f7e..a79f2fc6d5 100644 --- a/orte/test/mpi/concurrent_spawn.c +++ b/orte/test/mpi/concurrent_spawn.c @@ -32,7 +32,7 @@ int main(int argc, char* argv[]) for (i = 0; i < NUM_CHILDREN; ++i) { printf("Parent [pid %ld] about to spawn child #%d\n", (long)pid, i); - asprintf(&(child_argv[0]), "%d", i); + opal_asprintf(&(child_argv[0]), "%d", i); MPI_Comm_spawn(argv[0], child_argv, 1, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &children[i], MPI_ERRCODES_IGNORE); diff --git a/orte/test/mpi/hello_nodename.c b/orte/test/mpi/hello_nodename.c index 42023ee6f9..7699e3e745 100644 --- a/orte/test/mpi/hello_nodename.c +++ b/orte/test/mpi/hello_nodename.c @@ -32,15 +32,15 @@ int main(int argc, char* argv[]) MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_APPNUM, &appnum, &flag); if (NULL == appnum) { - asprintf(&appstr, "UNDEFINED"); + opal_asprintf(&appstr, "UNDEFINED"); } else { - asprintf(&appstr, "%d", *(int*)appnum); + opal_asprintf(&appstr, "%d", *(int*)appnum); } MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &univ_size, &flag); if (NULL == univ_size) { - asprintf(&unistr, "UNDEFINED"); + opal_asprintf(&unistr, "UNDEFINED"); } else { - asprintf(&unistr, "%d", *(int*)univ_size); + opal_asprintf(&unistr, "%d", *(int*)univ_size); } gethostname(hostname, sizeof(hostname)); diff --git a/orte/test/mpi/intercomm_create.c b/orte/test/mpi/intercomm_create.c index b572f7842c..7bd1dc9be6 100644 --- a/orte/test/mpi/intercomm_create.c +++ b/orte/test/mpi/intercomm_create.c @@ -23,7 +23,7 @@ void ompitest_warning( char* filename, int lineno, const char* fmt, ... ) va_list va_list; va_start(va_list, fmt); - vasprintf( &buf, fmt, va_list ); + opal_vasprintf( &buf, fmt, va_list ); va_end(va_list); printf( "*warning* %s:%d %s\n", filename, lineno, buf ); free(buf); @@ -35,7 +35,7 @@ void ompitest_error( char* filename, int lineno, const char* fmt, ... ) va_list va_list; va_start(va_list, fmt); - vasprintf( &buf, fmt, va_list ); + opal_vasprintf( &buf, fmt, va_list ); va_end(va_list); printf( "*error* %s:%d %s\n", filename, lineno, buf ); free(buf); diff --git a/orte/test/mpi/read_write.c b/orte/test/mpi/read_write.c index 808682cc45..c51b8e2304 100644 --- a/orte/test/mpi/read_write.c +++ b/orte/test/mpi/read_write.c @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) printf("Hello from process %d of %d\n", self, size); MPI_Barrier(MPI_COMM_WORLD); if (-1 == reader || reader == self) { - asprintf(&junk, "./junk%d", self); + opal_asprintf(&junk, "./junk%d", self); unlink(junk); file = fopen(junk, "w+"); if (NULL == file) { diff --git a/orte/test/mpi/ziatest.c b/orte/test/mpi/ziatest.c index 647d0a1d00..63c6cb722f 100644 --- a/orte/test/mpi/ziatest.c +++ b/orte/test/mpi/ziatest.c @@ -3,6 +3,7 @@ * Copyright (c) 2008 Los Alamos National Security, LLC. All rights reserved. * * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -40,7 +41,7 @@ int main(int argc, char* argv[]) gettimeofday(&tv, NULL); /* form the command */ - asprintf(&cmd, "mpirun -npernode %d ./ziaprobe %ld %d", + opal_asprintf(&cmd, "mpirun -npernode %d ./ziaprobe %ld %d", nppn, (long) tv.tv_sec, tv.tv_usec); /* execute it */ diff --git a/orte/test/system/threads.c b/orte/test/system/threads.c index 3b5c813037..6a83264fd3 100644 --- a/orte/test/system/threads.c +++ b/orte/test/system/threads.c @@ -328,7 +328,7 @@ void bind_me_to(bool main_thread) { set = hwloc_bitmap_alloc(); hwloc_get_cpubind(topo, set, HWLOC_CPUBIND_THREAD); - hwloc_bitmap_asprintf(&buffer, set); + hwloc_bitmap_opal_asprintf(&buffer, set); printf("%s : [objs = %d] : cpuset is %s\n", (main_thread ? "Main" : "Peer"), num_objs, buffer); free(buffer); hwloc_bitmap_free(set); diff --git a/orte/tools/ompi-prun/prun.c b/orte/tools/ompi-prun/prun.c index 17683b803f..a03c54c11b 100644 --- a/orte/tools/ompi-prun/prun.c +++ b/orte/tools/ompi-prun/prun.c @@ -446,7 +446,7 @@ int prun(int argc, char *argv[]) } /* if they specified the DVM's pid, then pass it along */ if (0 != myoptions.pid) { - asprintf(¶m, "%d", myoptions.pid); + opal_asprintf(¶m, "%d", myoptions.pid); opal_setenv(OPAL_MCA_PREFIX"ess_tool_server_pid", param, true, &environ); free(param); } @@ -612,14 +612,14 @@ int prun(int argc, char *argv[]) val = OBJ_NEW(opal_value_t); val->key = strdup(OPAL_PMIX_PPR); val->type = OPAL_STRING; - (void)asprintf(&val->data.string, "%d:node", orte_cmd_options.npernode); + opal_asprintf(&val->data.string, "%d:node", orte_cmd_options.npernode); opal_list_append(&job_info, &val->super); } else if (0 < orte_cmd_options.npersocket) { /* define the ppr */ val = OBJ_NEW(opal_value_t); val->key = strdup(OPAL_PMIX_PPR); val->type = OPAL_STRING; - (void)asprintf(&val->data.string, "%d:socket", orte_cmd_options.npernode); + opal_asprintf(&val->data.string, "%d:socket", orte_cmd_options.npernode); opal_list_append(&job_info, &val->super); } @@ -1212,9 +1212,9 @@ static int create_app(int argc, char* argv[], if (NULL == strstr(app->argv[i], opal_install_dirs.libdir)) { /* doesn't appear to - add it to be safe */ if (':' == app->argv[i][strlen(app->argv[i]-1)]) { - asprintf(&value, "-Djava.library.path=%s%s", dptr, opal_install_dirs.libdir); + opal_asprintf(&value, "-Djava.library.path=%s%s", dptr, opal_install_dirs.libdir); } else { - asprintf(&value, "-Djava.library.path=%s:%s", dptr, opal_install_dirs.libdir); + opal_asprintf(&value, "-Djava.library.path=%s:%s", dptr, opal_install_dirs.libdir); } free(app->argv[i]); app->argv[i] = value; @@ -1224,7 +1224,7 @@ static int create_app(int argc, char* argv[], } if (!found) { /* need to add it right after the java command */ - asprintf(&value, "-Djava.library.path=%s", opal_install_dirs.libdir); + opal_asprintf(&value, "-Djava.library.path=%s", opal_install_dirs.libdir); opal_argv_insert_element(&app->argv, 1, value); free(value); } @@ -1249,7 +1249,7 @@ static int create_app(int argc, char* argv[], } free(value); /* always add the local directory */ - asprintf(&value, "%s:%s", app->cwd, app->argv[i+1]); + opal_asprintf(&value, "%s:%s", app->cwd, app->argv[i+1]); free(app->argv[i+1]); app->argv[i+1] = value; break; @@ -1276,7 +1276,7 @@ static int create_app(int argc, char* argv[], } free(value); /* always add the local directory */ - (void)asprintf(&value, "%s:%s", app->cwd, app->argv[1]); + opal_asprintf(&value, "%s:%s", app->cwd, app->argv[1]); free(app->argv[1]); app->argv[1] = value; opal_argv_insert_element(&app->argv, 1, "-cp"); @@ -1295,7 +1295,7 @@ static int create_app(int argc, char* argv[], /* check for mpi.jar */ value = opal_os_path(false, opal_install_dirs.libdir, "mpi.jar", NULL); if (access(value, F_OK ) != -1) { - (void)asprintf(&str2, "%s:%s", str, value); + opal_asprintf(&str2, "%s:%s", str, value); free(str); str = str2; } @@ -1303,7 +1303,7 @@ static int create_app(int argc, char* argv[], /* check for shmem.jar */ value = opal_os_path(false, opal_install_dirs.libdir, "shmem.jar", NULL); if (access(value, F_OK ) != -1) { - asprintf(&str2, "%s:%s", str, value); + opal_asprintf(&str2, "%s:%s", str, value); free(str); str = str2; } @@ -1366,7 +1366,7 @@ static void set_classpath_jar_file(opal_pmix_app_t *app, int index, char *jarfil char *fmt = ':' == app->argv[index][strlen(app->argv[index]-1)] ? "%s%s/%s" : "%s:%s/%s"; char *str; - asprintf(&str, fmt, app->argv[index], opal_install_dirs.libdir, jarfile); + opal_asprintf(&str, fmt, app->argv[index], opal_install_dirs.libdir, jarfile); free(app->argv[index]); app->argv[index] = str; } diff --git a/orte/tools/orte-clean/orte-clean.c b/orte/tools/orte-clean/orte-clean.c index fbbc04b5ff..d4d6eb32fe 100644 --- a/orte/tools/orte-clean/orte-clean.c +++ b/orte/tools/orte-clean/orte-clean.c @@ -16,7 +16,7 @@ * Copyright (c) 2011-2013 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 UT-Battelle, LLC. All rights reserved. * $COPYRIGHT$ * @@ -59,6 +59,7 @@ #include "opal/util/os_dirpath.h" #include "opal/util/basename.h" #include "opal/util/error.h" +#include "opal/util/printf.h" #include "opal/mca/base/base.h" #include "opal/util/show_help.h" @@ -176,14 +177,14 @@ main(int argc, char *argv[]) opal_os_dirpath_destroy(orte_process_info.top_session_dir, true, NULL); /* also get rid of any legacy session directories */ - asprintf(&legacy, "%s/openmpi-sessions-%d@%s_0", + opal_asprintf(&legacy, "%s/openmpi-sessions-%d@%s_0", orte_process_info.tmpdir_base, (int)geteuid(), orte_process_info.nodename); opal_os_dirpath_destroy(legacy, true, NULL); free(legacy); /* and finally get rid of any lingering pmix-related artifacts */ - asprintf(&legacy, "rm -rf %s/pmix*", orte_process_info.tmpdir_base); + opal_asprintf(&legacy, "rm -rf %s/pmix*", orte_process_info.tmpdir_base); system(legacy); free(legacy); @@ -315,7 +316,7 @@ void kill_procs(void) { /* get the userid of the user */ uid = getuid(); - asprintf(&this_user, "%d", uid); + opal_asprintf(&this_user, "%d", uid); /* * There is a race condition here. The problem is that we are looking diff --git a/orte/tools/orte-info/orte-info.h b/orte/tools/orte-info/orte-info.h index 0841baa097..30d4c69f33 100644 --- a/orte/tools/orte-info/orte-info.h +++ b/orte/tools/orte-info/orte-info.h @@ -12,6 +12,7 @@ * Copyright (c) 2007-2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -26,6 +27,7 @@ #include "opal/class/opal_list.h" #include "opal/class/opal_pointer_array.h" #include "opal/util/cmd_line.h" +#include "opal/util/printf.h" #include "opal/mca/mca.h" BEGIN_C_DECLS diff --git a/orte/tools/orte-info/output.c b/orte/tools/orte-info/output.c index 44839e0272..f6cb0ea888 100644 --- a/orte/tools/orte-info/output.c +++ b/orte/tools/orte-info/output.c @@ -10,6 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -104,7 +105,7 @@ void orte_info_out(const char *pretty_message, const char *plain_message, const if (orte_info_pretty && NULL != pretty_message) { if (centerpoint > (int)strlen(pretty_message)) { - asprintf(&spaces, "%*s", centerpoint - + opal_asprintf(&spaces, "%*s", centerpoint - (int)strlen(pretty_message), " "); } else { spaces = strdup(""); @@ -118,9 +119,9 @@ void orte_info_out(const char *pretty_message, const char *plain_message, const } max_value_width = screen_width - strlen(spaces) - strlen(pretty_message) - 2; if (0 < strlen(pretty_message)) { - asprintf(&filler, "%s%s: ", spaces, pretty_message); + opal_asprintf(&filler, "%s%s: ", spaces, pretty_message); } else { - asprintf(&filler, "%s ", spaces); + opal_asprintf(&filler, "%s ", spaces); } free(spaces); spaces = NULL; @@ -130,7 +131,7 @@ void orte_info_out(const char *pretty_message, const char *plain_message, const printf("%s%s\n", filler, v); break; } else { - asprintf(&spaces, "%*s", centerpoint + 2, " "); + opal_asprintf(&spaces, "%*s", centerpoint + 2, " "); /* Work backwards to find the first space before * max_value_width @@ -193,7 +194,7 @@ void orte_info_out_int(const char *pretty_message, { char *valstr; - asprintf(&valstr, "%d", (int)value); + opal_asprintf(&valstr, "%d", (int)value); orte_info_out(pretty_message, plain_message, valstr); free(valstr); } diff --git a/orte/tools/orte-info/param.c b/orte/tools/orte-info/param.c index 5525b951b4..0e118eb829 100644 --- a/orte/tools/orte-info/param.c +++ b/orte/tools/orte-info/param.c @@ -16,6 +16,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2018 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -165,7 +166,7 @@ static void orte_info_show_mca_group_params(const mca_base_var_group_t *group, b if (0 == j && orte_info_pretty) { char *message; - asprintf (&message, "MCA %s", group->group_framework); + opal_asprintf (&message, "MCA %s", group->group_framework); orte_info_out(message, message, strings[j]); free(message); } else { @@ -305,7 +306,7 @@ void orte_info_show_path(const char *type, const char *value) pretty = strdup(type); pretty[0] = toupper(pretty[0]); - asprintf(&path, "path:%s", type); + opal_asprintf(&path, "path:%s", type); orte_info_out(pretty, path, value); free(pretty); free(path); @@ -327,8 +328,8 @@ void orte_info_do_hostname() /* * do_config * Accepts: - * - want_all: boolean flag; TRUE -> display all options - * FALSE -> display selected options + * - want_all: boolean flag; TRUE -> display all options + * FALSE -> display selected options * * This function displays all the options with which the current * installation of orte was configured. There are many options here @@ -360,10 +361,10 @@ void orte_info_do_config(bool want_all) symbol_visibility = OPAL_C_HAVE_VISIBILITY ? "yes" : "no"; /* setup strings that require allocation */ - asprintf(&threads, "%s (OPAL: yes, ORTE progress: yes, Event lib: yes)", + opal_asprintf(&threads, "%s (OPAL: yes, ORTE progress: yes, Event lib: yes)", "posix"); - asprintf(&ft_support, "%s (checkpoint thread: %s)", + opal_asprintf(&ft_support, "%s (checkpoint thread: %s)", OPAL_ENABLE_FT ? "yes" : "no", OPAL_ENABLE_FT_THREAD ? "yes" : "no");; /* output values */ diff --git a/orte/tools/orte-info/version.c b/orte/tools/orte-info/version.c index 7ee68f6031..c30648bbf9 100644 --- a/orte/tools/orte-info/version.c +++ b/orte/tools/orte-info/version.c @@ -13,6 +13,7 @@ * Copyright (c) 2010-2011 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -71,8 +72,8 @@ static char *make_version_str(const char *scope, * Determines the version information related to the orte components * being used. * Accepts: - * - want_all: True if all components' info is required. - * - cmd_line: The constructed command line argument + * - want_all: True if all components' info is required. + * - cmd_line: The constructed command line argument */ void orte_info_do_version(bool want_all, opal_cmd_line_t *cmd_line) { @@ -239,12 +240,12 @@ static void show_mca_version(const mca_base_component_t* component, "", false, ""); if (orte_info_pretty) { - asprintf(&message, "MCA %s", component->mca_type_name); + opal_asprintf(&message, "MCA %s", component->mca_type_name); printed = false; - asprintf(&content, "%s (", component->mca_component_name); + opal_asprintf(&content, "%s (", component->mca_component_name); if (want_mca) { - asprintf(&tmp, "%sMCA v%s", content, mca_version); + opal_asprintf(&tmp, "%sMCA v%s", content, mca_version); free(content); content = tmp; printed = true; @@ -252,11 +253,11 @@ static void show_mca_version(const mca_base_component_t* component, if (want_type) { if (printed) { - asprintf(&tmp, "%s, ", content); + opal_asprintf(&tmp, "%s, ", content); free(content); content = tmp; } - asprintf(&tmp, "%sAPI v%s", content, api_version); + opal_asprintf(&tmp, "%sAPI v%s", content, api_version); free(content); content = tmp; printed = true; @@ -264,20 +265,20 @@ static void show_mca_version(const mca_base_component_t* component, if (want_component) { if (printed) { - asprintf(&tmp, "%s, ", content); + opal_asprintf(&tmp, "%s, ", content); free(content); content = tmp; } - asprintf(&tmp, "%sComponent v%s", content, component_version); + opal_asprintf(&tmp, "%sComponent v%s", content, component_version); free(content); content = tmp; printed = true; } if (NULL != content) { - asprintf(&tmp, "%s)", content); + opal_asprintf(&tmp, "%s)", content); free(content); } else { - asprintf(&tmp, ")"); + opal_asprintf(&tmp, ")"); } orte_info_out(message, NULL, tmp); @@ -285,19 +286,19 @@ static void show_mca_version(const mca_base_component_t* component, free(tmp); } else { - asprintf(&message, "mca:%s:%s:version", component->mca_type_name, component->mca_component_name); + opal_asprintf(&message, "mca:%s:%s:version", component->mca_type_name, component->mca_component_name); if (want_mca) { - asprintf(&tmp, "mca:%s", mca_version); + opal_asprintf(&tmp, "mca:%s", mca_version); orte_info_out(NULL, message, tmp); free(tmp); } if (want_type) { - asprintf(&tmp, "api:%s", api_version); + opal_asprintf(&tmp, "api:%s", api_version); orte_info_out(NULL, message, tmp); free(tmp); } if (want_component) { - asprintf(&tmp, "component:%s", component_version); + opal_asprintf(&tmp, "component:%s", component_version); orte_info_out(NULL, message, tmp); free(tmp); } @@ -325,17 +326,17 @@ static char *make_version_str(const char *scope, str = strdup(temp); if (release > 0) { snprintf(temp, BUFSIZ - 1, ".%d", release); - asprintf(&tmp, "%s%s", str, temp); + opal_asprintf(&tmp, "%s%s", str, temp); free(str); str = tmp; } if (NULL != greek) { - asprintf(&tmp, "%s%s", str, greek); + opal_asprintf(&tmp, "%s%s", str, greek); free(str); str = tmp; } if (want_repo && NULL != repo) { - asprintf(&tmp, "%s%s", str, repo); + opal_asprintf(&tmp, "%s%s", str, repo); free(str); str = tmp; } diff --git a/orte/tools/orte-ps/orte-ps.c b/orte/tools/orte-ps/orte-ps.c index 4f444ad012..12a4a35785 100644 --- a/orte/tools/orte-ps/orte-ps.c +++ b/orte/tools/orte-ps/orte-ps.c @@ -15,7 +15,7 @@ * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -58,6 +58,7 @@ #include "opal/util/cmd_line.h" #include "opal/util/output.h" #include "opal/util/opal_environ.h" +#include "opal/util/printf.h" #include "opal/util/show_help.h" #include "opal/mca/base/base.h" #include "opal/runtime/opal.h" @@ -439,7 +440,7 @@ static int pretty_print(orte_ps_mpirun_info_t *hnpinfo) { /* * Print header and remember header length */ - len_hdr = asprintf(&header, "Information from mpirun %s", ORTE_JOBID_PRINT(hnpinfo->hnp->name.jobid)); + len_hdr = opal_asprintf(&header, "Information from mpirun %s", ORTE_JOBID_PRINT(hnpinfo->hnp->name.jobid)); printf("\n\n%s\n", header); free(header); @@ -708,7 +709,7 @@ static int pretty_print_vpids(orte_job_t *job) { if ((int)strlen(o_proc_name) > len_o_proc_name) len_o_proc_name = strlen(o_proc_name); - asprintf(&rankstr, "%u", (uint)vpid->local_rank); + opal_asprintf(&rankstr, "%u", (uint)vpid->local_rank); if ((int)strlen(rankstr) > len_rank) len_rank = strlen(rankstr); free(rankstr); diff --git a/orte/tools/orte-top/orte-top.c b/orte/tools/orte-top/orte-top.c index 42e2f1f76f..f221d24b5e 100644 --- a/orte/tools/orte-top/orte-top.c +++ b/orte/tools/orte-top/orte-top.c @@ -13,7 +13,7 @@ * Copyright (c) 2007-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -43,6 +43,7 @@ #include "opal/util/argv.h" #include "opal/util/show_help.h" #include "opal/util/opal_environ.h" +#include "opal/util/printf.h" #include "opal/dss/dss.h" #include "opal/mca/base/base.h" #include "opal/mca/pmix/pmix.h" @@ -638,14 +639,14 @@ static void recv_stats(int status, orte_process_name_t* sender, nodefield = tmp; } - asprintf(&ctmp, "%d", stats->rank); + opal_asprintf(&ctmp, "%d", stats->rank); tmp = strlen(ctmp); free(ctmp); if (rankfield < tmp) { rankfield = tmp; } - asprintf(&ctmp, "%lu", (unsigned long)stats->pid); + opal_asprintf(&ctmp, "%lu", (unsigned long)stats->pid); tmp = strlen(ctmp); free(ctmp); if (pidfield < tmp) { @@ -659,7 +660,7 @@ static void recv_stats(int status, orte_process_name_t* sender, if (0 <= stats->priority) { pri_found = true; - asprintf(&ctmp, "%d", stats->priority); + opal_asprintf(&ctmp, "%d", stats->priority); tmp = strlen(ctmp); free(ctmp); if (prifield < tmp) { @@ -669,7 +670,7 @@ static void recv_stats(int status, orte_process_name_t* sender, if (0 <= stats->num_threads) { thr_found = true; - asprintf(&ctmp, "%d", stats->num_threads); + opal_asprintf(&ctmp, "%d", stats->num_threads); tmp = strlen(ctmp); free(ctmp); if (thrfield < tmp) { @@ -679,7 +680,7 @@ static void recv_stats(int status, orte_process_name_t* sender, if (0 < stats->vsize) { vsize_found = true; - asprintf(&ctmp, "%8.2f", stats->vsize); + opal_asprintf(&ctmp, "%8.2f", stats->vsize); tmp = strlen(ctmp); free(ctmp); if (vsizefield < tmp) { @@ -689,7 +690,7 @@ static void recv_stats(int status, orte_process_name_t* sender, if (0 < stats->rss) { rss_found = true; - asprintf(&ctmp, "%8.2f", stats->rss); + opal_asprintf(&ctmp, "%8.2f", stats->rss); tmp = strlen(ctmp); free(ctmp); if (rssfield < tmp) { @@ -699,7 +700,7 @@ static void recv_stats(int status, orte_process_name_t* sender, if (0 < stats->peak_vsize) { pkv_found = true; - asprintf(&ctmp, "%8.2f", stats->peak_vsize); + opal_asprintf(&ctmp, "%8.2f", stats->peak_vsize); tmp = strlen(ctmp); free(ctmp); if (pkvfield < tmp) { @@ -709,7 +710,7 @@ static void recv_stats(int status, orte_process_name_t* sender, if (0 <= stats->processor) { p_found = true; - asprintf(&ctmp, "%d", stats->processor); + opal_asprintf(&ctmp, "%d", stats->processor); tmp = strlen(ctmp); free(ctmp); if (pfield < tmp) { diff --git a/orte/util/name_fns.c b/orte/util/name_fns.c index e25ddeacf9..4c91dfe121 100644 --- a/orte/util/name_fns.c +++ b/orte/util/name_fns.c @@ -12,7 +12,7 @@ * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014-2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2016 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -360,7 +360,7 @@ int orte_util_convert_vpid_to_string(char **vpid_string, const orte_vpid_t vpid) return ORTE_SUCCESS; } - if (0 > asprintf(vpid_string, "%ld", (long) vpid)) { + if (0 > opal_asprintf(vpid_string, "%ld", (long) vpid)) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); return ORTE_ERR_OUT_OF_RESOURCE; } @@ -469,22 +469,22 @@ int orte_util_convert_process_name_to_string(char **name_string, * it is passed back to us later */ if (ORTE_JOBID_WILDCARD == name->jobid) { - asprintf(&tmp, "%s", ORTE_SCHEMA_WILDCARD_STRING); + opal_asprintf(&tmp, "%s", ORTE_SCHEMA_WILDCARD_STRING); } else if (ORTE_JOBID_INVALID == name->jobid) { - asprintf(&tmp, "%s", ORTE_SCHEMA_INVALID_STRING); + opal_asprintf(&tmp, "%s", ORTE_SCHEMA_INVALID_STRING); } else { - asprintf(&tmp, "%lu", (unsigned long)name->jobid); + opal_asprintf(&tmp, "%lu", (unsigned long)name->jobid); } if (ORTE_VPID_WILDCARD == name->vpid) { - asprintf(&tmp2, "%s%c%s", tmp, ORTE_SCHEMA_DELIMITER_CHAR, ORTE_SCHEMA_WILDCARD_STRING); + opal_asprintf(&tmp2, "%s%c%s", tmp, ORTE_SCHEMA_DELIMITER_CHAR, ORTE_SCHEMA_WILDCARD_STRING); } else if (ORTE_VPID_INVALID == name->vpid) { - asprintf(&tmp2, "%s%c%s", tmp, ORTE_SCHEMA_DELIMITER_CHAR, ORTE_SCHEMA_INVALID_STRING); + opal_asprintf(&tmp2, "%s%c%s", tmp, ORTE_SCHEMA_DELIMITER_CHAR, ORTE_SCHEMA_INVALID_STRING); } else { - asprintf(&tmp2, "%s%c%lu", tmp, ORTE_SCHEMA_DELIMITER_CHAR, (unsigned long)name->vpid); + opal_asprintf(&tmp2, "%s%c%lu", tmp, ORTE_SCHEMA_DELIMITER_CHAR, (unsigned long)name->vpid); } - asprintf(name_string, "%s", tmp2); + opal_asprintf(name_string, "%s", tmp2); free(tmp); free(tmp2); @@ -593,7 +593,7 @@ uint32_t orte_util_hash_vpid(orte_vpid_t vpid) { /* sysinfo conversion to and from string */ int orte_util_convert_string_to_sysinfo(char **cpu_type, char **cpu_model, - const char* sysinfo_string) + const char* sysinfo_string) { char *temp, *token; int return_code=ORTE_SUCCESS; @@ -634,7 +634,7 @@ int orte_util_convert_string_to_sysinfo(char **cpu_type, char **cpu_model, } int orte_util_convert_sysinfo_to_string(char **sysinfo_string, - const char *cpu_type, const char *cpu_model) + const char *cpu_type, const char *cpu_model) { char *tmp; @@ -643,15 +643,15 @@ int orte_util_convert_sysinfo_to_string(char **sysinfo_string, * it is passed back to us later */ if (NULL == cpu_type) { - asprintf(&tmp, "%s", ORTE_SCHEMA_INVALID_STRING); + opal_asprintf(&tmp, "%s", ORTE_SCHEMA_INVALID_STRING); } else { - asprintf(&tmp, "%s", cpu_type); + opal_asprintf(&tmp, "%s", cpu_type); } if (NULL == cpu_model) { - asprintf(sysinfo_string, "%s%c%s", tmp, ORTE_SCHEMA_DELIMITER_CHAR, ORTE_SCHEMA_INVALID_STRING); + opal_asprintf(sysinfo_string, "%s%c%s", tmp, ORTE_SCHEMA_DELIMITER_CHAR, ORTE_SCHEMA_INVALID_STRING); } else { - asprintf(sysinfo_string, "%s%c%s", tmp, ORTE_SCHEMA_DELIMITER_CHAR, cpu_model); + opal_asprintf(sysinfo_string, "%s%c%s", tmp, ORTE_SCHEMA_DELIMITER_CHAR, cpu_model); } free(tmp); return ORTE_SUCCESS; @@ -668,12 +668,10 @@ char *orte_pretty_print_timing(int64_t secs, int64_t usecs) seconds = seconds % 60l; if (0 == minutes && 0 == seconds) { fsecs = ((float)(secs)*1000000.0 + (float)usecs) / 1000.0; - asprintf(×tring, "%8.2f millisecs", fsecs); + opal_asprintf(×tring, "%8.2f millisecs", fsecs); } else { - asprintf(×tring, "%3lu:%02lu min:sec", minutes, seconds); + opal_asprintf(×tring, "%3lu:%02lu min:sec", minutes, seconds); } return timestring; } - - diff --git a/orte/util/pre_condition_transports.c b/orte/util/pre_condition_transports.c index ec514ea496..bbcb6fb53e 100644 --- a/orte/util/pre_condition_transports.c +++ b/orte/util/pre_condition_transports.c @@ -12,7 +12,7 @@ * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -40,6 +40,7 @@ #include "opal/mca/base/mca_base_var.h" #include "opal/util/alfg.h" #include "opal/util/opal_environ.h" +#include "opal/util/printf.h" #include "orte/constants.h" #include "orte/types.h" @@ -89,7 +90,7 @@ char* orte_pre_condition_transports_print(uint64_t *unique_key) * number if the system has a different sized long (8 would be for * sizeof(int) == 4)). */ - asprintf(&format, "%%0%dx", (int)(sizeof(unsigned int)) * 2); + opal_asprintf(&format, "%%0%dx", (int)(sizeof(unsigned int)) * 2); /* print the first number */ int_ptr = (unsigned int*) &unique_key[0]; diff --git a/orte/util/session_dir.c b/orte/util/session_dir.c index 657cec6586..ffd9781e6b 100644 --- a/orte/util/session_dir.c +++ b/orte/util/session_dir.c @@ -55,6 +55,7 @@ #include "opal/util/os_dirpath.h" #include "opal/util/basename.h" #include "opal/util/opal_environ.h" +#include "opal/util/printf.h" #include "orte/util/proc_info.h" #include "orte/util/name_fns.h" @@ -150,7 +151,7 @@ int orte_setup_top_session_dir(void) goto exit; } - if (0 > asprintf(&orte_process_info.top_session_dir, + if (0 > opal_asprintf(&orte_process_info.top_session_dir, "%s/ompi.%s.%lu", orte_process_info.tmpdir_base, orte_process_info.nodename, (unsigned long)uid)) { orte_process_info.top_session_dir = NULL; @@ -176,13 +177,13 @@ static int _setup_jobfam_session_dir(orte_process_name_t *proc) } if (ORTE_PROC_IS_MASTER) { - if (0 > asprintf(&orte_process_info.jobfam_session_dir, + if (0 > opal_asprintf(&orte_process_info.jobfam_session_dir, "%s/dvm", orte_process_info.top_session_dir)) { rc = ORTE_ERR_OUT_OF_RESOURCE; goto exit; } } else if (ORTE_PROC_IS_HNP) { - if (0 > asprintf(&orte_process_info.jobfam_session_dir, + if (0 > opal_asprintf(&orte_process_info.jobfam_session_dir, "%s/pid.%lu", orte_process_info.top_session_dir, (unsigned long)orte_process_info.pid)) { rc = ORTE_ERR_OUT_OF_RESOURCE; @@ -191,13 +192,13 @@ static int _setup_jobfam_session_dir(orte_process_name_t *proc) } else { /* we were not given one, so define it */ if (NULL == proc || (ORTE_JOBID_INVALID == proc->jobid)) { - if (0 > asprintf(&orte_process_info.jobfam_session_dir, + if (0 > opal_asprintf(&orte_process_info.jobfam_session_dir, "%s/jobfam", orte_process_info.top_session_dir) ) { rc = ORTE_ERR_OUT_OF_RESOURCE; goto exit; } } else { - if (0 > asprintf(&orte_process_info.jobfam_session_dir, + if (0 > opal_asprintf(&orte_process_info.jobfam_session_dir, "%s/jf.%d", orte_process_info.top_session_dir, ORTE_JOB_FAMILY(proc->jobid))) { orte_process_info.jobfam_session_dir = NULL; @@ -225,7 +226,7 @@ _setup_job_session_dir(orte_process_name_t *proc) return rc; } if (ORTE_JOBID_INVALID != proc->jobid) { - if (0 > asprintf(&orte_process_info.job_session_dir, + if (0 > opal_asprintf(&orte_process_info.job_session_dir, "%s/%d", orte_process_info.jobfam_session_dir, ORTE_LOCAL_JOBID(proc->jobid))) { orte_process_info.job_session_dir = NULL; @@ -255,7 +256,7 @@ _setup_proc_session_dir(orte_process_name_t *proc) return rc; } if (ORTE_VPID_INVALID != proc->vpid) { - if (0 > asprintf(&orte_process_info.proc_session_dir, + if (0 > opal_asprintf(&orte_process_info.proc_session_dir, "%s/%d", orte_process_info.job_session_dir, proc->vpid)) { orte_process_info.proc_session_dir = NULL; diff --git a/orte/util/show_help.c b/orte/util/show_help.c index e49c38c7ca..8ea1519d6b 100644 --- a/orte/util/show_help.c +++ b/orte/util/show_help.c @@ -12,7 +12,7 @@ * Copyright (c) 2008-2018 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012-2013 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * $COPYRIGHT$ * @@ -30,6 +30,7 @@ #include "opal/util/show_help.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal/dss/dss.h" #include "opal/mca/event/event.h" #include "opal/mca/pmix/pmix.h" @@ -349,7 +350,7 @@ static void show_accumulated_duplicates(int fd, short event, void *context) tli->tli_count_since_last_display > 0) { static bool first = true; if (orte_xml_output) { - asprintf(&tmp, "%d more process%s sent help message %s / %s", + opal_asprintf(&tmp, "%d more process%s sent help message %s / %s", tli->tli_count_since_last_display, (tli->tli_count_since_last_display > 1) ? "es have" : " has", tli->tli_filename, tli->tli_topic);