From e9e4d2a4bc4ca34d8f426a5f175e3a9eabe50a66 Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Sat, 6 Oct 2018 16:58:16 -0700 Subject: [PATCH] Handle asprintf errors with opal_asprintf wrapper The Open MPI code base assumed that asprintf always behaved like the FreeBSD variant, where ptr is set to NULL on error. However, the C standard (and Linux) only guarantee that the return code will be -1 on error and leave ptr undefined. Rather than fix all the usage in the code, we use opal_asprintf() wrapper instead, which guarantees the BSD-like behavior of ptr always being set to NULL. In addition to being correct, this will fix many, many warnings in the Open MPI code base. Signed-off-by: Brian Barrett --- .../btl_tcp2_component.c | 6 +- contrib/check_unnecessary_headers.sh | 2 +- contrib/scaling/mpi_memprobe.c | 7 +- ompi/communicator/comm_cid.c | 6 +- ompi/datatype/ompi_datatype_create.c | 4 +- ompi/debuggers/dlopen_test.c | 4 +- ompi/debuggers/ompi_debuggers.c | 4 +- ompi/dpm/dpm.c | 14 +- ompi/errhandler/errhandler_predefined.c | 7 +- ompi/mca/coll/fca/coll_fca_component.c | 9 +- ompi/mca/coll/sm/coll_sm_component.c | 2 + ompi/mca/coll/sm/coll_sm_module.c | 4 +- .../mca/common/monitoring/common_monitoring.c | 6 +- ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c | 4 +- ompi/mca/mtl/ofi/mtl_ofi.h | 6 +- ompi/mca/mtl/ofi/mtl_ofi_component.c | 6 +- ompi/mca/mtl/psm2/mtl_psm2_component.c | 10 +- ompi/mca/op/example/op_example_component.c | 5 +- .../mca/osc/portals4/osc_portals4_component.c | 5 +- ompi/mca/osc/pt2pt/osc_pt2pt_component.c | 4 +- ompi/mca/osc/rdma/osc_rdma_component.c | 22 +- ompi/mca/osc/sm/osc_sm_component.c | 4 +- ompi/mca/osc/ucx/osc_ucx_component.c | 7 +- ompi/mca/pml/v/pml_v_component.c | 4 +- ompi/mca/pml/v/pml_v_output.c | 6 +- ompi/mca/pml/v/pml_v_output.h | 8 +- ompi/mca/rte/orte/rte_orte_module.c | 4 +- ompi/mca/rte/pmix/rte_pmix_module.c | 27 ++- .../pessimist/vprotocol_pessimist_eventlog.c | 4 +- .../vprotocol_pessimist_sender_based.c | 4 +- ompi/mpi/c/type_create_f90_complex.c | 5 +- ompi/mpi/c/type_create_f90_integer.c | 5 +- ompi/mpi/c/type_create_f90_real.c | 5 +- ompi/op/op.h | 8 +- ompi/runtime/ompi_cr.c | 8 +- ompi/runtime/ompi_info_support.c | 8 +- ompi/tools/ompi_info/param.c | 13 +- opal/dss/dss_pack.c | 6 +- opal/dss/dss_print.c | 222 +++++++++--------- opal/mca/base/mca_base_cmd_line.c | 4 +- opal/mca/base/mca_base_component_compare.c | 5 +- opal/mca/base/mca_base_component_repository.c | 8 +- opal/mca/base/mca_base_framework.c | 6 +- opal/mca/base/mca_base_open.c | 9 +- opal/mca/base/mca_base_pvar.c | 24 +- opal/mca/base/mca_base_var.c | 105 +++++---- opal/mca/base/mca_base_var_enum.c | 12 +- opal/mca/btl/base/btl_base_error.c | 4 +- opal/mca/btl/ofi/btl_ofi_component.c | 5 +- opal/mca/btl/ofi/btl_ofi_module.c | 4 +- opal/mca/btl/openib/btl_openib.c | 8 +- opal/mca/btl/openib/btl_openib_component.c | 4 +- opal/mca/btl/openib/btl_openib_mca.c | 8 +- opal/mca/btl/openib/btl_openib_xrc.c | 4 +- .../openib/connect/btl_openib_connect_base.c | 6 +- .../connect/btl_openib_connect_rdmacm.c | 4 +- opal/mca/btl/smcuda/btl_smcuda_component.c | 10 +- opal/mca/btl/tcp/btl_tcp_component.c | 6 +- opal/mca/btl/tcp/btl_tcp_endpoint.c | 4 +- opal/mca/btl/tcp/btl_tcp_proc.c | 6 +- opal/mca/btl/uct/btl_uct_component.c | 4 +- opal/mca/btl/ugni/btl_ugni_component.c | 4 +- opal/mca/btl/usnic/btl_usnic_cagent.c | 6 +- opal/mca/btl/usnic/btl_usnic_cclient.c | 4 +- opal/mca/btl/usnic/btl_usnic_component.c | 6 +- opal/mca/btl/usnic/btl_usnic_map.c | 4 +- opal/mca/btl/usnic/btl_usnic_module.c | 4 +- opal/mca/btl/usnic/btl_usnic_stats.c | 4 +- opal/mca/btl/vader/btl_vader_component.c | 4 +- opal/mca/common/cuda/common_cuda.c | 4 +- opal/mca/common/sm/common_sm_mpool.c | 4 +- opal/mca/common/verbs/common_verbs_basics.c | 4 +- opal/mca/compress/base/compress_base_fns.c | 8 +- opal/mca/compress/bzip/compress_bzip_module.c | 18 +- opal/mca/compress/gzip/compress_gzip_module.c | 18 +- opal/mca/crs/blcr/crs_blcr_module.c | 10 +- opal/mca/crs/dmtcp/crs_dmtcp_module.c | 10 +- opal/mca/crs/self/crs_self_module.c | 8 +- opal/mca/dl/dlopen/dl_dlopen_module.c | 6 +- .../event/external/event_external_component.c | 4 +- .../libevent2022/libevent2022_component.c | 4 +- opal/mca/hwloc/base/hwloc_base_dt.c | 18 +- opal/mca/hwloc/base/hwloc_base_util.c | 24 +- .../base/installdirs_base_expand.c | 6 +- opal/mca/mpool/base/mpool_base_tree.c | 6 +- .../mpool/hugepage/mpool_hugepage_module.c | 4 +- opal/runtime/opal_cr.c | 4 +- opal/runtime/opal_info_support.c | 70 +++--- opal/runtime/opal_params.c | 6 +- opal/tools/opal-checkpoint/opal-checkpoint.c | 8 +- opal/tools/opal-restart/opal-restart.c | 20 +- opal/tools/wrappers/opal_wrapper.c | 20 +- opal/util/error.c | 6 +- opal/util/opal_environ.c | 9 +- opal/util/output.c | 10 +- opal/util/printf.c | 15 +- opal/util/show_help.c | 7 +- opal/util/uri.c | 6 +- oshmem/info/info.c | 4 +- oshmem/mca/scoll/fca/scoll_fca_component.c | 6 +- oshmem/mca/spml/ikrit/spml_ikrit_component.c | 4 +- oshmem/runtime/oshmem_info_support.c | 9 +- oshmem/tools/oshmem_info/param.c | 11 +- oshmem/util/oshmem_util.c | 11 +- test/dss/dss_buffer.c | 10 +- test/util/opal_basename.c | 4 +- test/util/opal_bit_ops.c | 10 +- test/util/opal_path_nfs.c | 4 +- 108 files changed, 698 insertions(+), 483 deletions(-) mode change 100755 => 100644 contrib/check_unnecessary_headers.sh diff --git a/contrib/build-mca-comps-outside-of-tree/btl_tcp2_component.c b/contrib/build-mca-comps-outside-of-tree/btl_tcp2_component.c index d79aac4b32..5203a1e660 100644 --- a/contrib/build-mca-comps-outside-of-tree/btl_tcp2_component.c +++ b/contrib/build-mca-comps-outside-of-tree/btl_tcp2_component.c @@ -12,6 +12,7 @@ * Copyright (c) 2007-2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2009 Oak Ridge National Laboratory + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -55,6 +56,7 @@ #include "opal/util/argv.h" #include "opal/util/net.h" #include "opal/util/opal_sos.h" +#include "opal/util/printf.h" #include "orte/types.h" #include "orte/util/show_help.h" @@ -225,7 +227,7 @@ int mca_btl_tcp2_component_open(void) mca_btl_tcp2_component.tcp_port_min ); mca_btl_tcp2_component.tcp_port_min = 1024; } - asprintf( &message, + opal_asprintf( &message, "The number of ports where the TCP BTL will try to bind (default %d)." " This parameter together with the port min, define a range of ports" " where Open MPI will open sockets.", @@ -244,7 +246,7 @@ int mca_btl_tcp2_component_open(void) mca_btl_tcp2_component.tcp6_port_min ); mca_btl_tcp2_component.tcp6_port_min = 1024; } - asprintf( &message, + opal_asprintf( &message, "The number of ports where the TCP BTL will try to bind (default %d)." " This parameter together with the port min, define a range of ports" " where Open MPI will open sockets.", diff --git a/contrib/check_unnecessary_headers.sh b/contrib/check_unnecessary_headers.sh old mode 100755 new mode 100644 index 0c6f028b05..601121af31 --- a/contrib/check_unnecessary_headers.sh +++ b/contrib/check_unnecessary_headers.sh @@ -122,7 +122,7 @@ SEARCH_HEADER[37]="opal/util/os_dirpath.h opal_os_dirpath_create opal_os_dirpath SEARCH_HEADER[38]="opal/util/os_path.h opal_os_path opal_make_filename_os_friendly" SEARCH_HEADER[39]="opal/util/output.h opal_output_stream_t opal_output_init opal_output_finalize opal_output_open opal_output_reopen opal_output_switch opal_output_reopen_all opal_output_close opal_output opal_output_verbose opal_output_vverbose opal_output_string opal_output_vstring opal_output_set_verbosity opal_output_get_verbosity opal_output_set_output_file_info OPAL_OUTPUT OPAL_OUTPUT_VERBOSE" SEARCH_HEADER[40]="opal/util/path.h opal_path_find opal_path_findv opal_path_is_absolute opal_find_absolute_path opal_path_access" -SEARCH_HEADER[41]="opal/util/printf.h snprintf vsnprintf asprintf vasprintf" +SEARCH_HEADER[41]="opal/util/printf.h snprintf vsnprintf" SEARCH_HEADER[42]="opal/util/show_help.h opal_show_help_init opal_show_help_finalize opal_show_help opal_show_vhelp opal_show_help_string opal_show_help_finish_parsing" SEARCH_HEADER[43]="opal/util/strncpy.h opal_strncpy" SEARCH_HEADER[44]="opal/util/sys_limits.h opal_sys_limits opal_util_init_sys_limits" diff --git a/contrib/scaling/mpi_memprobe.c b/contrib/scaling/mpi_memprobe.c index 75ab6c174c..3f25543d84 100644 --- a/contrib/scaling/mpi_memprobe.c +++ b/contrib/scaling/mpi_memprobe.c @@ -11,6 +11,7 @@ #include "mpi.h" #include "opal/mca/pmix/pmix.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "orte/runtime/runtime.h" #include "orte/util/proc_info.h" #include "orte/util/name_fns.h" @@ -113,7 +114,7 @@ static void sample(void) wait_for_release = true; /* log my own results as a single string so the output * doesn't get garbled on the other end */ - asprintf(&tmp, "Data for node %s", orte_process_info.nodename); + opal_asprintf(&tmp, "Data for node %s", orte_process_info.nodename); opal_argv_append_nosize(&answer, tmp); free(tmp); OPAL_LIST_FOREACH(kv, &response, opal_value_t) { @@ -121,11 +122,11 @@ static void sample(void) if (NULL != lt) { OPAL_LIST_FOREACH(ival, lt, opal_value_t) { if (0 == strcmp(ival->key, OPAL_PMIX_DAEMON_MEMORY)) { - asprintf(&tmp, "\tDaemon: %f", ival->data.fval); + opal_asprintf(&tmp, "\tDaemon: %f", ival->data.fval); opal_argv_append_nosize(&answer, tmp); free(tmp); } else if (0 == strcmp(ival->key, OPAL_PMIX_CLIENT_AVG_MEMORY)) { - asprintf(&tmp, "\tClient: %f", ival->data.fval); + opal_asprintf(&tmp, "\tClient: %f", ival->data.fval); opal_argv_append_nosize(&answer, tmp); free(tmp); } else { diff --git a/ompi/communicator/comm_cid.c b/ompi/communicator/comm_cid.c index 764fe42f4e..63e882a2a6 100644 --- a/ompi/communicator/comm_cid.c +++ b/ompi/communicator/comm_cid.c @@ -22,6 +22,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. * Copyright (c) 2017 Mellanox Technologies. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -33,6 +34,7 @@ #include "opal/dss/dss.h" #include "opal/mca/pmix/pmix.h" +#include "opal/util/printf.h" #include "ompi/proc/proc.h" #include "ompi/communicator/communicator.h" @@ -900,7 +902,7 @@ static int ompi_comm_allreduce_pmix_reduce_complete (ompi_comm_request_t *reques opal_dss.unload(&sbuf, (void**)&info.data.bo.bytes, &info.data.bo.size); OBJ_DESTRUCT(&sbuf); - bytes_written = asprintf(&info.key, + bytes_written = opal_asprintf(&info.key, cid_context->send_first ? "%s:%s:send:%d" : "%s:%s:recv:%d", cid_context->port_string, @@ -910,7 +912,7 @@ static int ompi_comm_allreduce_pmix_reduce_complete (ompi_comm_request_t *reques if (bytes_written == -1) { opal_output_verbose (verbosity_level, output_id, "writing info.key failed\n"); } else { - bytes_written = asprintf(&pdat.value.key, + bytes_written = opal_asprintf(&pdat.value.key, cid_context->send_first ? "%s:%s:recv:%d" : "%s:%s:send:%d", cid_context->port_string, diff --git a/ompi/datatype/ompi_datatype_create.c b/ompi/datatype/ompi_datatype_create.c index aa0760c2c5..0d59db2149 100644 --- a/ompi/datatype/ompi_datatype_create.c +++ b/ompi/datatype/ompi_datatype_create.c @@ -10,6 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2009 Oak Ridge National Labs. All rights reserved. * Copyright (c) 2010-2018 Cisco Systems, Inc. All rights reserved + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -23,6 +24,7 @@ #include #include "opal/class/opal_pointer_array.h" +#include "opal/util/printf.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/attribute/attribute.h" @@ -110,7 +112,7 @@ ompi_datatype_duplicate( const ompi_datatype_t* oldType, ompi_datatype_t** newTy new_ompi_datatype->args = NULL; char *new_name; - asprintf(&new_name, "Dup %s", oldType->name); + opal_asprintf(&new_name, "Dup %s", oldType->name); strncpy(new_ompi_datatype->name, new_name, MPI_MAX_OBJECT_NAME - 1); new_ompi_datatype->name[MPI_MAX_OBJECT_NAME - 1] = '\0'; free(new_name); diff --git a/ompi/debuggers/dlopen_test.c b/ompi/debuggers/dlopen_test.c index 27ef62c5a6..47b5ae5a85 100644 --- a/ompi/debuggers/dlopen_test.c +++ b/ompi/debuggers/dlopen_test.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2009-2018 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -15,6 +16,7 @@ #include #include "opal/runtime/opal.h" +#include "opal/util/printf.h" #include "opal/mca/dl/base/base.h" #if !OPAL_HAVE_DL_SUPPORT @@ -119,7 +121,7 @@ static int do_test(void) get here, manually prefix the filename with .libs/ and try again. */ char *rel_filename; - asprintf(&rel_filename, ".libs/%s", filename); + opal_asprintf(&rel_filename, ".libs/%s", filename); if (NULL == rel_filename) { return 1; } diff --git a/ompi/debuggers/ompi_debuggers.c b/ompi/debuggers/ompi_debuggers.c index 1e38b03d27..13415b7469 100644 --- a/ompi/debuggers/ompi_debuggers.c +++ b/ompi/debuggers/ompi_debuggers.c @@ -13,6 +13,7 @@ * Copyright (c) 2007-2016 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -48,6 +49,7 @@ #include "opal/mca/base/base.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "opal/mca/installdirs/installdirs.h" #include "debuggers.h" #include "ompi/mca/rte/rte.h" @@ -132,7 +134,7 @@ static void check(char *dir, char *file, char **locations) { char *str; - asprintf(&str, "%s/%s.so", dir, file); + opal_asprintf(&str, "%s/%s.so", dir, file); #if defined(HAVE_SYS_STAT_H) { diff --git a/ompi/dpm/dpm.c b/ompi/dpm/dpm.c index a9a2de586c..a14abe1d72 100644 --- a/ompi/dpm/dpm.c +++ b/ompi/dpm/dpm.c @@ -18,6 +18,7 @@ * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -41,6 +42,7 @@ #include "opal/util/opal_getcwd.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "opal/dss/dss.h" #include "opal/mca/hwloc/base/base.h" #include "opal/mca/pmix/pmix.h" @@ -153,7 +155,7 @@ int ompi_dpm_connect_accept(ompi_communicator_t *comm, int root, return OMPI_ERR_NOT_SUPPORTED; } opal_argv_append_nosize(&members, nstring); - (void)asprintf(&nstring, "%d", size); + (void)opal_asprintf(&nstring, "%d", size); opal_argv_append_nosize(&members, nstring); free(nstring); } else { @@ -208,11 +210,11 @@ int ompi_dpm_connect_accept(ompi_communicator_t *comm, int root, OBJ_CONSTRUCT(&info, opal_value_t); OBJ_CONSTRUCT(&pdat, opal_pmix_pdata_t); if (send_first) { - (void)asprintf(&info.key, "%s:connect", port_string); - (void)asprintf(&pdat.value.key, "%s:accept", port_string); + (void)opal_asprintf(&info.key, "%s:connect", port_string); + (void)opal_asprintf(&pdat.value.key, "%s:accept", port_string); } else { - (void)asprintf(&info.key, "%s:accept", port_string); - (void)asprintf(&pdat.value.key, "%s:connect", port_string); + (void)opal_asprintf(&info.key, "%s:accept", port_string); + (void)opal_asprintf(&pdat.value.key, "%s:connect", port_string); } info.type = OPAL_STRING; info.data.string = opal_argv_join(members, ':'); @@ -812,7 +814,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[], info = OBJ_NEW(opal_value_t); info->key = strdup(OPAL_PMIX_PPR); info->type = OPAL_STRING; - (void)asprintf(&(info->data.string), "%s:n", slot_list); + (void)opal_asprintf(&(info->data.string), "%s:n", slot_list); opal_list_append(&job_info, &info->super); } ompi_info_get (array_of_info[i], "pernode", sizeof(slot_list) - 1, slot_list, &flag); diff --git a/ompi/errhandler/errhandler_predefined.c b/ompi/errhandler/errhandler_predefined.c index 9d0bdf7711..8eb4954db5 100644 --- a/ompi/errhandler/errhandler_predefined.c +++ b/ompi/errhandler/errhandler_predefined.c @@ -16,6 +16,7 @@ * Copyright (c) 2012 Los Alamos National Security, LLC. * All rights reserved. * Copyright (c) 2016 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -194,7 +195,7 @@ static void backend_fatal_aggregate(char *type, arg = va_arg(arglist, char*); va_end(arglist); - if (asprintf(&prefix, "[%s:%05d]", + if (opal_asprintf(&prefix, "[%s:%05d]", ompi_process_info.nodename, (int) ompi_process_info.pid) == -1) { prefix = NULL; @@ -207,7 +208,7 @@ static void backend_fatal_aggregate(char *type, if (NULL != error_code) { err_msg = ompi_mpi_errnum_get_string(*error_code); if (NULL == err_msg) { - if (asprintf(&err_msg, unknown_error_code, + if (opal_asprintf(&err_msg, unknown_error_code, *error_code) == -1) { err_msg = NULL; opal_output(0, "%s", "Could not write to err_msg"); @@ -333,7 +334,7 @@ static void backend_fatal_no_aggregate(char *type, } if (NULL != name) { - /* Don't use asprintf() here because there may be stack / + /* Don't use opal_asprintf() here because there may be stack / heap corruption by the time we're invoked, so just do it on the stack */ str[0] = '\0'; diff --git a/ompi/mca/coll/fca/coll_fca_component.c b/ompi/mca/coll/fca/coll_fca_component.c index 7f3c4a4935..a6360c6868 100644 --- a/ompi/mca/coll/fca/coll_fca_component.c +++ b/ompi/mca/coll/fca/coll_fca_component.c @@ -5,6 +5,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -27,9 +28,9 @@ #ifdef HAVE_UNISTD_H #include #endif + #include "opal/mca/installdirs/installdirs.h" - - +#include "opal/util/printf.h" #include "coll_fca.h" @@ -1212,10 +1213,10 @@ static char *fca_check_file(char *file) static char *fca_get_spec_file(void) { char *file; - asprintf(&file, "%s/etc/fca_mpi_spec.ini", COLL_FCA_HOME); + opal_asprintf(&file, "%s/etc/fca_mpi_spec.ini", COLL_FCA_HOME); if (NULL == fca_check_file(file)) { free(file); - asprintf(&file, "%s/../fca/etc/fca_mpi_spec.ini", opal_install_dirs.prefix); + opal_asprintf(&file, "%s/../fca/etc/fca_mpi_spec.ini", opal_install_dirs.prefix); if (NULL == fca_check_file(file)) { free(file); return NULL; diff --git a/ompi/mca/coll/sm/coll_sm_component.c b/ompi/mca/coll/sm/coll_sm_component.c index d88f42470c..3f590acb29 100644 --- a/ompi/mca/coll/sm/coll_sm_component.c +++ b/ompi/mca/coll/sm/coll_sm_component.c @@ -14,6 +14,7 @@ * Copyright (c) 2011-2015 Los Alamos National Security, LLC. * All rights reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -30,6 +31,7 @@ #include "ompi_config.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "ompi/constants.h" #include "ompi/mca/coll/coll.h" #include "coll_sm.h" diff --git a/ompi/mca/coll/sm/coll_sm_module.c b/ompi/mca/coll/sm/coll_sm_module.c index d1804a0061..ba7c6f9364 100644 --- a/ompi/mca/coll/sm/coll_sm_module.c +++ b/ompi/mca/coll/sm/coll_sm_module.c @@ -16,6 +16,7 @@ * Copyright (c) 2014-2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -51,6 +52,7 @@ #include "opal_stdint.h" #include "opal/mca/hwloc/base/base.h" #include "opal/util/os_path.h" +#include "opal/util/printf.h" #include "ompi/communicator/communicator.h" #include "ompi/group/group.h" @@ -518,7 +520,7 @@ static int bootstrap_comm(ompi_communicator_t *comm, lowest_name = OMPI_CAST_RTE_NAME(&proc->super.proc_name); } } - asprintf(&shortpath, "coll-sm-cid-%d-name-%s.mmap", comm->c_contextid, + opal_asprintf(&shortpath, "coll-sm-cid-%d-name-%s.mmap", comm->c_contextid, OMPI_NAME_PRINT(lowest_name)); if (NULL == shortpath) { opal_output_verbose(10, ompi_coll_base_framework.framework_output, diff --git a/ompi/mca/common/monitoring/common_monitoring.c b/ompi/mca/common/monitoring/common_monitoring.c index 8598155156..a4cd08fe0f 100644 --- a/ompi/mca/common/monitoring/common_monitoring.c +++ b/ompi/mca/common/monitoring/common_monitoring.c @@ -9,6 +9,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2017-2018 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -24,6 +25,7 @@ #include #include #include +#include "opal/util/printf.h" #include #if SIZEOF_LONG_LONG == SIZEOF_SIZE_T @@ -216,7 +218,7 @@ int mca_common_monitoring_init( void ) log10_2 = log10(2.); /* Open the opal_output stream */ gethostname(hostname, sizeof(hostname)); - asprintf(&mca_common_monitoring_output_stream_obj.lds_prefix, + opal_asprintf(&mca_common_monitoring_output_stream_obj.lds_prefix, "[%s:%06d] monitoring: ", hostname, getpid()); mca_common_monitoring_output_stream_id = opal_output_open(&mca_common_monitoring_output_stream_obj); @@ -775,7 +777,7 @@ static int mca_common_monitoring_flush(int fd, char* filename) OPAL_MONITORING_PRINT_ERR("Error while flushing: no filename provided"); return OMPI_ERROR; } else { - asprintf(&tmpfn, "%s.%" PRId32 ".prof", filename, rank_world); + opal_asprintf(&tmpfn, "%s.%" PRId32 ".prof", filename, rank_world); pf = fopen(tmpfn, "w"); free(tmpfn); } diff --git a/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c b/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c index 3276df26d0..da4b8d8a5b 100644 --- a/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c +++ b/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c @@ -9,6 +9,7 @@ * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -30,6 +31,7 @@ #include "opal/runtime/opal_cr.h" #include "opal/mca/event/event.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal/util/opal_environ.h" #include "ompi/mca/mca.h" @@ -6283,7 +6285,7 @@ static void display_indv_timer_core(int idx, int proc, int msgs, bool direct) { /* These timers do not mean anything in the aggregate, so only display * them when directly asked for */ if( direct && timing_enabled >= 2) { - asprintf(&str, "Proc %2d, Msg %5d", proc, msgs); + opal_asprintf(&str, "Proc %2d, Msg %5d", proc, msgs); } else { return; } diff --git a/ompi/mca/mtl/ofi/mtl_ofi.h b/ompi/mca/mtl/ofi/mtl_ofi.h index 1a04a5bad2..6fe10cf3c8 100644 --- a/ompi/mca/mtl/ofi/mtl_ofi.h +++ b/ompi/mca/mtl/ofi/mtl_ofi.h @@ -3,6 +3,7 @@ * Copyright (c) 2017 Los Alamos National Security, LLC. All rights * reserved. * + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -17,6 +18,7 @@ #include "ompi/mca/mtl/base/base.h" #include "opal/datatype/opal_convertor.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include #include @@ -483,10 +485,10 @@ ompi_mtl_ofi_isend(struct mca_mtl_base_module_t *mtl, if (OPAL_UNLIKELY(0 > ret)) { char *fi_api; if (ompi_mtl_ofi.fi_cq_data) { - asprintf( &fi_api, "fi_tsendddata") ; + opal_asprintf( &fi_api, "fi_tsendddata") ; } else { - asprintf( &fi_api, "fi_send") ; + opal_asprintf( &fi_api, "fi_send") ; } opal_output_verbose(1, ompi_mtl_base_framework.framework_output, "%s:%d: %s failed: %s(%zd)", diff --git a/ompi/mca/mtl/ofi/mtl_ofi_component.c b/ompi/mca/mtl/ofi/mtl_ofi_component.c index 6ba80e68da..90931fb135 100644 --- a/ompi/mca/mtl/ofi/mtl_ofi_component.c +++ b/ompi/mca/mtl/ofi/mtl_ofi_component.c @@ -5,6 +5,7 @@ * Copyright (c) 2014-2017 Cisco Systems, Inc. All rights reserved * Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -15,6 +16,7 @@ #include "mtl_ofi.h" #include "opal/util/argv.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" static int ompi_mtl_ofi_component_open(void); static int ompi_mtl_ofi_component_query(mca_base_module_t **module, int *priority); @@ -143,7 +145,7 @@ ompi_mtl_ofi_component_register(void) &prov_exclude); ompi_mtl_ofi.ofi_progress_event_count = 100; - asprintf(&desc, "Max number of events to read each call to OFI progress (default: %d events will be read per OFI progress call)", ompi_mtl_ofi.ofi_progress_event_count); + opal_asprintf(&desc, "Max number of events to read each call to OFI progress (default: %d events will be read per OFI progress call)", ompi_mtl_ofi.ofi_progress_event_count); mca_base_component_var_register(&mca_mtl_ofi_component.super.mtl_version, "progress_event_cnt", desc, @@ -160,7 +162,7 @@ ompi_mtl_ofi_component_register(void) } ofi_tag_mode = MTL_OFI_TAG_AUTO; - asprintf(&desc, "Mode specifying how many bits to use for various MPI values in OFI/Libfabric" + opal_asprintf(&desc, "Mode specifying how many bits to use for various MPI values in OFI/Libfabric" " communications. Some Libfabric provider network types can support most of Open MPI" " needs; others can only supply a limited number of bits, which then must be split" " across the MPI communicator ID, MPI source rank, and MPI tag. Three different" diff --git a/ompi/mca/mtl/psm2/mtl_psm2_component.c b/ompi/mca/mtl/psm2/mtl_psm2_component.c index 633c315304..6121d416d8 100644 --- a/ompi/mca/mtl/psm2/mtl_psm2_component.c +++ b/ompi/mca/mtl/psm2/mtl_psm2_component.c @@ -16,6 +16,7 @@ * Copyright (c) 2013-2017 Intel, Inc. All rights reserved * Copyright (c) 2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,6 +30,7 @@ #include "opal/util/output.h" #include "opal/util/show_help.h" #include "opal/util/opal_environ.h" +#include "opal/util/printf.h" #include "ompi/proc/proc.h" #include "mtl_psm2.h" @@ -147,19 +149,19 @@ static void ompi_mtl_psm2_set_shadow_env (struct ompi_mtl_psm2_shadow_variable * switch (variable->variable_type) { case MCA_BASE_VAR_TYPE_BOOL: - ret = asprintf (&env_value, "%s=%d", variable->env_name, storage->boolval ? 1 : 0); + ret = opal_asprintf (&env_value, "%s=%d", variable->env_name, storage->boolval ? 1 : 0); break; case MCA_BASE_VAR_TYPE_UNSIGNED_LONG: if (0 == strcmp (variable->env_name, "PSM2_TRACEMASK")) { /* PSM2 documentation shows the tracemask as a hexidecimal number. to be consitent * use hexidecimal here. */ - ret = asprintf (&env_value, "%s=0x%lx", variable->env_name, storage->ulval); + ret = opal_asprintf (&env_value, "%s=0x%lx", variable->env_name, storage->ulval); } else { - ret = asprintf (&env_value, "%s=%lu", variable->env_name, storage->ulval); + ret = opal_asprintf (&env_value, "%s=%lu", variable->env_name, storage->ulval); } break; case MCA_BASE_VAR_TYPE_STRING: - ret = asprintf (&env_value, "%s=%s", variable->env_name, storage->stringval); + ret = opal_asprintf (&env_value, "%s=%s", variable->env_name, storage->stringval); break; } diff --git a/ompi/mca/op/example/op_example_component.c b/ompi/mca/op/example/op_example_component.c index 43a1e6d71f..af2ac8f4c4 100644 --- a/ompi/mca/op/example/op_example_component.c +++ b/ompi/mca/op/example/op_example_component.c @@ -13,6 +13,7 @@ * Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -30,6 +31,8 @@ #include "ompi_config.h" +#include "opal/util/printf.h" + #include "ompi/constants.h" #include "ompi/op/op.h" #include "ompi/mca/op/op.h" @@ -132,7 +135,7 @@ static int example_component_register(void) containing the major.minor.release version number from the libfoo support library (see configure.m4 for how we got these C macros). */ - asprintf(&str, "%s.%s.%s", + opal_asprintf(&str, "%s.%s.%s", OP_EXAMPLE_LIBFOO_VERSION_MAJOR, OP_EXAMPLE_LIBFOO_VERSION_MINOR, OP_EXAMPLE_LIBFOO_VERSION_RELEASE); diff --git a/ompi/mca/osc/portals4/osc_portals4_component.c b/ompi/mca/osc/portals4/osc_portals4_component.c index 473873407c..f914831252 100644 --- a/ompi/mca/osc/portals4/osc_portals4_component.c +++ b/ompi/mca/osc/portals4/osc_portals4_component.c @@ -9,6 +9,7 @@ * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2016-2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -18,6 +19,8 @@ #include "ompi_config.h" +#include "opal/util/printf.h" + #include "ompi/mca/osc/osc.h" #include "ompi/mca/osc/base/base.h" #include "ompi/mca/osc/base/osc_base_obj_convert.h" @@ -435,7 +438,7 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit "portals4 component creating window with id %d", ompi_comm_get_cid(module->comm)); - asprintf(&name, "portals4 window %d", ompi_comm_get_cid(module->comm)); + opal_asprintf(&name, "portals4 window %d", ompi_comm_get_cid(module->comm)); ompi_win_set_name(win, name); free(name); diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt_component.c b/ompi/mca/osc/pt2pt/osc_pt2pt_component.c index 0fbcd2af32..2ef298fdbc 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt_component.c +++ b/ompi/mca/osc/pt2pt/osc_pt2pt_component.c @@ -17,6 +17,7 @@ * Copyright (c) 2015-2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016-2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -26,6 +27,7 @@ #include "ompi_config.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include @@ -411,7 +413,7 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit /* fill in window information */ *model = MPI_WIN_UNIFIED; win->w_osc_module = (ompi_osc_base_module_t*) module; - asprintf(&name, "pt2pt window %d", ompi_comm_get_cid(module->comm)); + opal_asprintf(&name, "pt2pt window %d", ompi_comm_get_cid(module->comm)); ompi_win_set_name(win, name); free(name); diff --git a/ompi/mca/osc/rdma/osc_rdma_component.c b/ompi/mca/osc/rdma/osc_rdma_component.c index ef0fad453c..8e7d0da5ef 100644 --- a/ompi/mca/osc/rdma/osc_rdma_component.c +++ b/ompi/mca/osc/rdma/osc_rdma_component.c @@ -18,6 +18,7 @@ * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. * Copyright (c) 2016-2017 IBM Corporation. All rights reserved. * Copyright (c) 2018 Cisco Systems, Inc. All rights reserved + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -41,6 +42,7 @@ #include "opal/threads/mutex.h" #include "opal/util/arch.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "opal/align.h" #if OPAL_CUDA_SUPPORT #include "opal/datatype/opal_datatype_cuda.h" @@ -181,7 +183,7 @@ static int ompi_osc_rdma_component_register (void) mca_base_var_enum_t *new_enum; mca_osc_rdma_component.no_locks = false; - asprintf(&description_str, "Enable optimizations available only if MPI_LOCK is " + opal_asprintf(&description_str, "Enable optimizations available only if MPI_LOCK is " "not used. Info key of same name overrides this value (default: %s)", mca_osc_rdma_component.no_locks ? "true" : "false"); (void) mca_base_component_var_register(&mca_osc_rdma_component.super.osc_version, "no_locks", description_str, @@ -190,7 +192,7 @@ static int ompi_osc_rdma_component_register (void) free(description_str); mca_osc_rdma_component.acc_single_intrinsic = false; - asprintf(&description_str, "Enable optimizations for MPI_Fetch_and_op, MPI_Accumulate, etc for codes " + opal_asprintf(&description_str, "Enable optimizations for MPI_Fetch_and_op, MPI_Accumulate, etc for codes " "that will not use anything more than a single predefined datatype (default: %s)", mca_osc_rdma_component.acc_single_intrinsic ? "true" : "false"); (void) mca_base_component_var_register(&mca_osc_rdma_component.super.osc_version, "acc_single_intrinsic", @@ -199,7 +201,7 @@ static int ompi_osc_rdma_component_register (void) free(description_str); mca_osc_rdma_component.acc_use_amo = true; - asprintf(&description_str, "Enable the use of network atomic memory operations when using single " + opal_asprintf(&description_str, "Enable the use of network atomic memory operations when using single " "intrinsic optimizations. If not set network compare-and-swap will be " "used instread (default: %s)", mca_osc_rdma_component.acc_use_amo ? "true" : "false"); (void) mca_base_component_var_register(&mca_osc_rdma_component.super.osc_version, "acc_use_amo", description_str, @@ -208,14 +210,14 @@ static int ompi_osc_rdma_component_register (void) free(description_str); mca_osc_rdma_component.buffer_size = 32768; - asprintf(&description_str, "Size of temporary buffers (default: %d)", mca_osc_rdma_component.buffer_size); + opal_asprintf(&description_str, "Size of temporary buffers (default: %d)", mca_osc_rdma_component.buffer_size); (void) mca_base_component_var_register (&mca_osc_rdma_component.super.osc_version, "buffer_size", description_str, MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0, OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_LOCAL, &mca_osc_rdma_component.buffer_size); free(description_str); mca_osc_rdma_component.max_attach = 32; - asprintf(&description_str, "Maximum number of buffers that can be attached to a dynamic window. " + opal_asprintf(&description_str, "Maximum number of buffers that can be attached to a dynamic window. " "Keep in mind that each attached buffer will use a potentially limited " "resource (default: %d)", mca_osc_rdma_component.max_attach); (void) mca_base_component_var_register (&mca_osc_rdma_component.super.osc_version, "max_attach", description_str, @@ -224,7 +226,7 @@ static int ompi_osc_rdma_component_register (void) free(description_str); mca_osc_rdma_component.priority = 101; - asprintf(&description_str, "Priority of the osc/rdma component (default: %d)", + opal_asprintf(&description_str, "Priority of the osc/rdma component (default: %d)", mca_osc_rdma_component.priority); (void) mca_base_component_var_register (&mca_osc_rdma_component.super.osc_version, "priority", description_str, MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0, OPAL_INFO_LVL_3, @@ -241,7 +243,7 @@ static int ompi_osc_rdma_component_register (void) OBJ_RELEASE(new_enum); ompi_osc_rdma_btl_names = "openib,ugni,uct,ucp"; - asprintf(&description_str, "Comma-delimited list of BTL component names to allow without verifying " + opal_asprintf(&description_str, "Comma-delimited list of BTL component names to allow without verifying " "connectivity. Do not add a BTL to to this list unless it can reach all " "processes in any communicator used with an MPI window (default: %s)", ompi_osc_rdma_btl_names); @@ -251,7 +253,7 @@ static int ompi_osc_rdma_component_register (void) free(description_str); ompi_osc_rdma_mtl_names = "psm2"; - asprintf(&description_str, "Comma-delimited list of MTL component names to lower the priority of rdma " + opal_asprintf(&description_str, "Comma-delimited list of MTL component names to lower the priority of rdma " "osc component favoring pt2pt osc (default: %s)", ompi_osc_rdma_mtl_names); (void) mca_base_component_var_register (&mca_osc_rdma_component.super.osc_version, "mtls", description_str, MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, @@ -585,7 +587,7 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s } /* allocate the shared memory segment */ - ret = asprintf (&data_file, "%s" OPAL_PATH_SEP "osc_rdma.%s.%x.%d", + ret = opal_asprintf (&data_file, "%s" OPAL_PATH_SEP "osc_rdma.%s.%x.%d", mca_osc_rdma_component.backing_directory, ompi_process_info.nodename, OMPI_PROC_MY_NAME->jobid, ompi_comm_get_cid(module->comm)); if (0 > ret) { @@ -1269,7 +1271,7 @@ static int ompi_osc_rdma_component_select (struct ompi_win_t *win, void **base, /* fill in window information */ *model = MPI_WIN_UNIFIED; win->w_osc_module = (ompi_osc_base_module_t*) module; - asprintf(&name, "rdma window %d", ompi_comm_get_cid(module->comm)); + opal_asprintf(&name, "rdma window %d", ompi_comm_get_cid(module->comm)); ompi_win_set_name(win, name); free(name); diff --git a/ompi/mca/osc/sm/osc_sm_component.c b/ompi/mca/osc/sm/osc_sm_component.c index 1006291584..36941a0e56 100644 --- a/ompi/mca/osc/sm/osc_sm_component.c +++ b/ompi/mca/osc/sm/osc_sm_component.c @@ -11,6 +11,7 @@ * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2016-2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -27,6 +28,7 @@ #include "opal/util/sys_limits.h" #include "opal/include/opal/align.h" #include "opal/util/info_subscriber.h" +#include "opal/util/printf.h" #include "osc_sm.h" @@ -282,7 +284,7 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit posts_size += OPAL_ALIGN_PAD_AMOUNT(posts_size, 64); if (0 == ompi_comm_rank (module->comm)) { char *data_file; - ret = asprintf (&data_file, "%s" OPAL_PATH_SEP "osc_sm.%s.%x.%d.%d", + ret = opal_asprintf (&data_file, "%s" OPAL_PATH_SEP "osc_sm.%s.%x.%d.%d", mca_osc_sm_component.backing_directory, ompi_process_info.nodename, OMPI_PROC_MY_NAME->jobid, (int) OMPI_PROC_MY_NAME->vpid, ompi_comm_get_cid(module->comm)); if (ret < 0) { diff --git a/ompi/mca/osc/ucx/osc_ucx_component.c b/ompi/mca/osc/ucx/osc_ucx_component.c index 955857d974..4d0d28a6d2 100644 --- a/ompi/mca/osc/ucx/osc_ucx_component.c +++ b/ompi/mca/osc/ucx/osc_ucx_component.c @@ -1,5 +1,6 @@ /* * Copyright (C) Mellanox Technologies Ltd. 2001-2017. ALL RIGHTS RESERVED. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -9,6 +10,8 @@ #include "ompi_config.h" +#include "opal/util/printf.h" + #include "ompi/mca/osc/osc.h" #include "ompi/mca/osc/base/base.h" #include "ompi/mca/osc/base/osc_base_obj_convert.h" @@ -100,7 +103,7 @@ static int component_open(void) { static int component_register(void) { char *description_str; mca_osc_ucx_component.priority = 0; - asprintf(&description_str, "Priority of the osc/ucx component (default: %d)", + opal_asprintf(&description_str, "Priority of the osc/ucx component (default: %d)", mca_osc_ucx_component.priority); (void) mca_base_component_var_register(&mca_osc_ucx_component.super.osc_version, "priority", description_str, MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0, OPAL_INFO_LVL_3, @@ -378,7 +381,7 @@ static int component_select(struct ompi_win_t *win, void **base, size_t size, in } *model = MPI_WIN_UNIFIED; - asprintf(&name, "ucx window %d", ompi_comm_get_cid(module->comm)); + opal_asprintf(&name, "ucx window %d", ompi_comm_get_cid(module->comm)); ompi_win_set_name(win, name); free(name); diff --git a/ompi/mca/pml/v/pml_v_component.c b/ompi/mca/pml/v/pml_v_component.c index fce84fc228..0b5048d733 100644 --- a/ompi/mca/pml/v/pml_v_component.c +++ b/ompi/mca/pml/v/pml_v_component.c @@ -8,6 +8,7 @@ * Copyright (c) 2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -19,6 +20,7 @@ #include "opal/mca/base/base.h" #include "opal/mca/base/mca_base_component_repository.h" +#include "opal/util/printf.h" #include "ompi/constants.h" #include "ompi/mca/pml/base/base.h" #include "ompi/mca/vprotocol/vprotocol.h" @@ -141,7 +143,7 @@ static int mca_pml_v_component_close(void) /* Mark that we have changed something */ char *new_name; - asprintf(&new_name, "%s]v%s", + opal_asprintf(&new_name, "%s]v%s", mca_pml_v.host_pml_component.pmlm_version.mca_component_name, mca_vprotocol_component.pmlm_version.mca_component_name); size_t len = sizeof(mca_pml_base_selected_component.pmlm_version.mca_component_name); diff --git a/ompi/mca/pml/v/pml_v_output.c b/ompi/mca/pml/v/pml_v_output.c index 6fa44042ad..145c33ce6b 100644 --- a/ompi/mca/pml/v/pml_v_output.c +++ b/ompi/mca/pml/v/pml_v_output.c @@ -2,6 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of the University of Tennessee. * All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -10,8 +11,9 @@ */ #include "ompi_config.h" -#include "opal/util/output.h" +#include "opal/util/output.h" +#include "opal/util/printf.h" #include "pml_v_output.h" @@ -42,7 +44,7 @@ int ompi_pml_v_output_open(char *output, int verbosity) { } lds.lds_is_debugging = true; gethostname(hostname, sizeof(hostname)); - asprintf(&lds.lds_prefix, "[%s:%05d] pml_v: ", hostname, getpid()); + opal_asprintf(&lds.lds_prefix, "[%s:%05d] pml_v: ", hostname, getpid()); lds.lds_verbose_level = verbosity; mca_pml_v.output = opal_output_open(&lds); free(lds.lds_prefix); diff --git a/ompi/mca/pml/v/pml_v_output.h b/ompi/mca/pml/v/pml_v_output.h index 3ddf213e26..9b80102e2c 100644 --- a/ompi/mca/pml/v/pml_v_output.h +++ b/ompi/mca/pml/v/pml_v_output.h @@ -2,6 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of the University of Tennessee. * All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -13,6 +14,7 @@ #define PML_V_OUTPUT_H_HAS_BEEN_INCLUDED #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal_stdint.h" #include #include "pml_v.h" @@ -29,7 +31,7 @@ static inline void V_OUTPUT_ERR(const char *fmt, ... ) char *str; int ret; va_start(list, fmt); - ret = vasprintf(&str, fmt, list); + ret = opal_vasprintf(&str, fmt, list); assert(-1 != ret); (void)ret; // silence compiler warning opal_output(0, "%s", str); @@ -60,7 +62,7 @@ static inline void V_OUTPUT(const char* fmt, ... ) char *str; int ret; va_start(list, fmt); - ret = vasprintf(&str, fmt, list); + ret = opal_vasprintf(&str, fmt, list); assert(-1 != ret); opal_output(mca_pml_v.output, "%s", str); free(str); @@ -72,7 +74,7 @@ static inline void V_OUTPUT_VERBOSE(int V, const char* fmt, ... ) { char *str; int ret; va_start(list, fmt); - ret = vasprintf(&str, fmt, list); + ret = opal_vasprintf(&str, fmt, list); assert(-1 != ret); opal_output_verbose(V, mca_pml_v.output, "%s", str); free(str); diff --git a/ompi/mca/rte/orte/rte_orte_module.c b/ompi/mca/rte/orte/rte_orte_module.c index 33dc0a1029..046b6d2532 100644 --- a/ompi/mca/rte/orte/rte_orte_module.c +++ b/ompi/mca/rte/orte/rte_orte_module.c @@ -6,6 +6,7 @@ * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ */ #include "ompi_config.h" @@ -19,6 +20,7 @@ #include "opal/util/argv.h" #include "opal/util/proc.h" #include "opal/util/opal_getcwd.h" +#include "opal/util/printf.h" #include "opal/mca/pmix/pmix.h" #include "opal/threads/threads.h" #include "opal/class/opal_list.h" @@ -61,7 +63,7 @@ void ompi_rte_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 ); } diff --git a/ompi/mca/rte/pmix/rte_pmix_module.c b/ompi/mca/rte/pmix/rte_pmix_module.c index cd393e3a0c..9defda5da0 100644 --- a/ompi/mca/rte/pmix/rte_pmix_module.c +++ b/ompi/mca/rte/pmix/rte_pmix_module.c @@ -6,6 +6,7 @@ * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ */ #include "ompi_config.h" @@ -375,22 +376,22 @@ int ompi_rte_convert_process_name_to_string(char** name_string, * it is passed back to us later */ if (pmix_name_wildcard.jobid == name->jobid) { - asprintf(&tmp, "%s", OPAL_SCHEMA_WILDCARD_STRING); + opal_asprintf(&tmp, "%s", OPAL_SCHEMA_WILDCARD_STRING); } else if (pmix_name_invalid.jobid == name->jobid) { - asprintf(&tmp, "%s", OPAL_SCHEMA_INVALID_STRING); + opal_asprintf(&tmp, "%s", OPAL_SCHEMA_INVALID_STRING); } else { - asprintf(&tmp, "%lu", (unsigned long)name->jobid); + opal_asprintf(&tmp, "%lu", (unsigned long)name->jobid); } if (pmix_name_wildcard.vpid == name->vpid) { - asprintf(&tmp2, "%s%c%s", tmp, OPAL_SCHEMA_DELIMITER_CHAR, OPAL_SCHEMA_WILDCARD_STRING); + opal_asprintf(&tmp2, "%s%c%s", tmp, OPAL_SCHEMA_DELIMITER_CHAR, OPAL_SCHEMA_WILDCARD_STRING); } else if (pmix_name_invalid.vpid == name->vpid) { - asprintf(&tmp2, "%s%c%s", tmp, OPAL_SCHEMA_DELIMITER_CHAR, OPAL_SCHEMA_INVALID_STRING); + opal_asprintf(&tmp2, "%s%c%s", tmp, OPAL_SCHEMA_DELIMITER_CHAR, OPAL_SCHEMA_INVALID_STRING); } else { - asprintf(&tmp2, "%s%c%lu", tmp, OPAL_SCHEMA_DELIMITER_CHAR, (unsigned long)name->vpid); + opal_asprintf(&tmp2, "%s%c%lu", tmp, OPAL_SCHEMA_DELIMITER_CHAR, (unsigned long)name->vpid); } - asprintf(name_string, "%s", tmp2); + opal_asprintf(name_string, "%s", tmp2); free(tmp); free(tmp2); @@ -589,12 +590,12 @@ int ompi_rte_init(int *pargc, char ***pargv) * MPI-3 required info key */ if (NULL == getenv(OPAL_MCA_PREFIX"opal_ess_num_procs")) { - asprintf(&ev1, OPAL_MCA_PREFIX"opal_ess_num_procs=%d", pmix_process_info.num_procs); + opal_asprintf(&ev1, OPAL_MCA_PREFIX"opal_ess_num_procs=%d", pmix_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", pmix_process_info.num_procs); + opal_asprintf(&ev2, "OMPI_APP_CTX_NUM_PROCS=%d", pmix_process_info.num_procs); putenv(ev2); added_app_ctx = true; } @@ -632,7 +633,7 @@ int ompi_rte_init(int *pargc, char ***pargv) opal_output_verbose(2, ompi_rte_base_framework.framework_output, "%s transport key %s", OPAL_NAME_PRINT(pmix_process_info.my_name), string_key); - asprintf(&envar, OPAL_MCA_PREFIX"opal_precondition_transports=%s", string_key); + opal_asprintf(&envar, OPAL_MCA_PREFIX"opal_precondition_transports=%s", string_key); putenv(envar); added_transport_keys = true; /* cannot free the envar as that messes up our environ */ @@ -816,7 +817,7 @@ void ompi_rte_abort(int error_code, char *fmt, ...) /* If there was a message, output it */ va_start(arglist, fmt); if( NULL != fmt ) { - vasprintf( &buffer, fmt, arglist ); + opal_vasprintf( &buffer, fmt, arglist ); } va_end(arglist); @@ -964,7 +965,7 @@ static char* 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]; @@ -1015,7 +1016,7 @@ static int _setup_job_session_dir(char **sdir) if( NULL == (tmpdir = getenv("TMP")) ) tmpdir = "/tmp"; - if (0 > asprintf(&pmix_process_info.job_session_dir, + if (0 > opal_asprintf(&pmix_process_info.job_session_dir, "%s/ompi.%s.%lu/jf.0/%u", tmpdir, pmix_process_info.nodename, (unsigned long)uid, diff --git a/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_eventlog.c b/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_eventlog.c index ce3c6b172b..a6ae610cd7 100644 --- a/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_eventlog.c +++ b/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_eventlog.c @@ -4,6 +4,7 @@ * Copyright (c) 2012 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -14,6 +15,7 @@ #include "ompi_config.h" #include "vprotocol_pessimist_eventlog.h" #include "opal/mca/pmix/pmix.h" +#include "opal/util/printf.h" #include "ompi/dpm/dpm.h" int vprotocol_pessimist_event_logger_connect(int el_rank, ompi_communicator_t **el_comm) @@ -27,7 +29,7 @@ int vprotocol_pessimist_event_logger_connect(int el_rank, ompi_communicator_t ** OBJ_CONSTRUCT(&results, opal_list_t); pdat = OBJ_NEW(opal_pmix_pdata_t); - asprintf(&pdat->value.key, VPROTOCOL_EVENT_LOGGER_NAME_FMT, el_rank); + opal_asprintf(&pdat->value.key, VPROTOCOL_EVENT_LOGGER_NAME_FMT, el_rank); opal_list_append(&results, &pdat->super); rc = opal_pmix.lookup(&results, NULL); diff --git a/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_sender_based.c b/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_sender_based.c index f9d5772c8f..063880b80d 100644 --- a/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_sender_based.c +++ b/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_sender_based.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2004-2014 The Trustees of the University of Tennessee. * All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -20,6 +21,7 @@ #include #include #include "opal/datatype/opal_datatype_memcpy.h" +#include "opal/util/printf.h" #include #define sb mca_vprotocol_pessimist.sender_based @@ -96,7 +98,7 @@ int vprotocol_pessimist_sender_based_init(const char *mmapfile, size_t size) OBJ_CONSTRUCT(&sb.sb_sendreq, opal_list_t); #endif - asprintf(&path, "%s"OPAL_PATH_SEP"%s", ompi_process_info.proc_session_dir, + opal_asprintf(&path, "%s"OPAL_PATH_SEP"%s", ompi_process_info.proc_session_dir, mmapfile); if(OPAL_SUCCESS != sb_mmap_file_open(path)) return OPAL_ERR_FILE_OPEN_FAILURE; diff --git a/ompi/mpi/c/type_create_f90_complex.c b/ompi/mpi/c/type_create_f90_complex.c index e8ec6d6f9a..687b954515 100644 --- a/ompi/mpi/c/type_create_f90_complex.c +++ b/ompi/mpi/c/type_create_f90_complex.c @@ -17,6 +17,7 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -26,6 +27,8 @@ #include "ompi_config.h" +#include "opal/util/printf.h" + #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/params.h" #include "ompi/communicator/communicator.h" @@ -108,7 +111,7 @@ int MPI_Type_create_f90_complex(int p, int r, MPI_Datatype *newtype) datatype->super.flags |= OMPI_DATATYPE_FLAG_PREDEFINED; /* Mark the datatype as a special F90 convenience type */ char *new_name; - asprintf(&new_name, "COMBINER %s", (*newtype)->name); + opal_asprintf(&new_name, "COMBINER %s", (*newtype)->name); size_t max_len = MPI_MAX_OBJECT_NAME; strncpy(datatype->name, new_name, max_len - 1); datatype->name[max_len - 1] = '\0'; diff --git a/ompi/mpi/c/type_create_f90_integer.c b/ompi/mpi/c/type_create_f90_integer.c index 108893dfaa..79fff68cd6 100644 --- a/ompi/mpi/c/type_create_f90_integer.c +++ b/ompi/mpi/c/type_create_f90_integer.c @@ -16,6 +16,7 @@ * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -25,6 +26,8 @@ #include "ompi_config.h" +#include "opal/util/printf.h" + #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/params.h" #include "ompi/communicator/communicator.h" @@ -104,7 +107,7 @@ int MPI_Type_create_f90_integer(int r, MPI_Datatype *newtype) datatype->super.flags |= OMPI_DATATYPE_FLAG_PREDEFINED; /* Mark the datatype as a special F90 convenience type */ char *new_name; - asprintf(&new_name, "COMBINER %s", (*newtype)->name); + opal_asprintf(&new_name, "COMBINER %s", (*newtype)->name); size_t max_len = MPI_MAX_OBJECT_NAME; strncpy(datatype->name, new_name, max_len - 1); datatype->name[max_len - 1] = '\0'; diff --git a/ompi/mpi/c/type_create_f90_real.c b/ompi/mpi/c/type_create_f90_real.c index de2ee83fac..43b279a356 100644 --- a/ompi/mpi/c/type_create_f90_real.c +++ b/ompi/mpi/c/type_create_f90_real.c @@ -17,6 +17,7 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -26,6 +27,8 @@ #include "ompi_config.h" +#include "opal/util/printf.h" + #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/params.h" #include "ompi/communicator/communicator.h" @@ -108,7 +111,7 @@ int MPI_Type_create_f90_real(int p, int r, MPI_Datatype *newtype) datatype->super.flags |= OMPI_DATATYPE_FLAG_PREDEFINED; /* Mark the datatype as a special F90 convenience type */ char *new_name; - asprintf(&new_name, "COMBINER %s", (*newtype)->name); + opal_asprintf(&new_name, "COMBINER %s", (*newtype)->name); size_t max_len = MPI_MAX_OBJECT_NAME; strncpy(datatype->name, new_name, max_len - 1); datatype->name[max_len - 1] = '\0'; diff --git a/ompi/op/op.h b/ompi/op/op.h index aa52688cb2..6fe93d38f3 100644 --- a/ompi/op/op.h +++ b/ompi/op/op.h @@ -15,6 +15,7 @@ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -37,6 +38,7 @@ #include "mpi.h" #include "opal/class/opal_object.h" +#include "opal/util/printf.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/mpi/fortran/base/fint_2_int.h" @@ -483,7 +485,7 @@ static inline bool ompi_op_is_valid(ompi_op_t * op, ompi_datatype_t * ddt, /* Intrinsic ddt on intrinsic op */ if (-1 == ompi_op_ddt_map[ddt->id] || NULL == op->o_func.intrinsic.fns[ompi_op_ddt_map[ddt->id]]) { - (void) asprintf(msg, + (void) opal_asprintf(msg, "%s: the reduction operation %s is not defined on the %s datatype", func, op->o_name, ddt->name); return false; @@ -491,11 +493,11 @@ static inline bool ompi_op_is_valid(ompi_op_t * op, ompi_datatype_t * ddt, } else { /* Non-intrinsic ddt on intrinsic op */ if ('\0' != ddt->name[0]) { - (void) asprintf(msg, + (void) opal_asprintf(msg, "%s: the reduction operation %s is not defined for non-intrinsic datatypes (attempted with datatype named \"%s\")", func, op->o_name, ddt->name); } else { - (void) asprintf(msg, + (void) opal_asprintf(msg, "%s: the reduction operation %s is not defined for non-intrinsic datatypes", func, op->o_name); } diff --git a/ompi/runtime/ompi_cr.c b/ompi/runtime/ompi_cr.c index eb3720cfe1..3371899afa 100644 --- a/ompi/runtime/ompi_cr.c +++ b/ompi/runtime/ompi_cr.c @@ -12,6 +12,7 @@ * All rights reserved. * Copyright (c) 2012 The University of Wisconsin-La Crosse. All rights * reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -43,6 +44,7 @@ #include "opal/mca/event/event.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal/mca/crs/crs.h" #include "opal/mca/crs/base/base.h" #include "opal/mca/installdirs/installdirs.h" @@ -193,14 +195,14 @@ int ompi_cr_init(void) /* Set the checkpoint and restart commands */ /* Add the full path to the binary */ - asprintf(&MPIR_checkpoint_command, + opal_asprintf(&MPIR_checkpoint_command, "%s/ompi-checkpoint --crdebug --hnp-jobid %u", opal_install_dirs.bindir, ORTE_PROC_MY_HNP->jobid); - asprintf(&MPIR_restart_command, + opal_asprintf(&MPIR_restart_command, "%s/ompi-restart --crdebug ", opal_install_dirs.bindir); - asprintf(&MPIR_checkpoint_listing_command, + opal_asprintf(&MPIR_checkpoint_listing_command, "%s/ompi-checkpoint -l --crdebug ", opal_install_dirs.bindir); diff --git a/ompi/runtime/ompi_info_support.c b/ompi/runtime/ompi_info_support.c index 17980ad1e9..e77a208772 100644 --- a/ompi/runtime/ompi_info_support.c +++ b/ompi/runtime/ompi_info_support.c @@ -14,6 +14,7 @@ * Copyright (c) 2011-2012 University of Houston. All rights reserved. * Copyright (c) 2010-2015 Los Alamos National Security, LLC. * All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -37,6 +38,7 @@ #endif #include "opal/util/show_help.h" +#include "opal/util/printf.h" const char *ompi_info_type_ompi = "ompi"; const char *ompi_info_type_base = "base"; @@ -120,7 +122,7 @@ void ompi_info_show_ompi_version(const char *scope) { char *tmp, *tmp2; - (void)asprintf(&tmp, "%s:version:full", ompi_info_type_ompi); + (void)opal_asprintf(&tmp, "%s:version:full", ompi_info_type_ompi); tmp2 = opal_info_make_version_str(scope, OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION, OMPI_RELEASE_VERSION, @@ -129,10 +131,10 @@ void ompi_info_show_ompi_version(const char *scope) opal_info_out("Open MPI", tmp, tmp2); free(tmp); free(tmp2); - (void)asprintf(&tmp, "%s:version:repo", ompi_info_type_ompi); + (void)opal_asprintf(&tmp, "%s:version:repo", ompi_info_type_ompi); opal_info_out("Open MPI repo revision", tmp, OMPI_REPO_REV); free(tmp); - (void)asprintf(&tmp, "%s:version:release_date", ompi_info_type_ompi); + (void)opal_asprintf(&tmp, "%s:version:release_date", ompi_info_type_ompi); opal_info_out("Open MPI release date", tmp, OMPI_RELEASE_DATE); free(tmp); diff --git a/ompi/tools/ompi_info/param.c b/ompi/tools/ompi_info/param.c index 17e2cc42e2..acf87c4790 100644 --- a/ompi/tools/ompi_info/param.c +++ b/ompi/tools/ompi_info/param.c @@ -14,6 +14,7 @@ * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -288,7 +289,7 @@ void ompi_info_do_config(bool want_all) /* setup strings that require allocation */ if (OMPI_BUILD_FORTRAN_BINDINGS >= OMPI_FORTRAN_MPIFH_BINDINGS) { - (void)asprintf(&fortran_mpifh, "yes (%s)", + (void)opal_asprintf(&fortran_mpifh, "yes (%s)", (OPAL_HAVE_WEAK_SYMBOLS ? "all" : (OMPI_FORTRAN_CAPS ? "caps" : (OMPI_FORTRAN_PLAIN ? "lower case" : @@ -302,24 +303,24 @@ void ompi_info_do_config(bool want_all) didn't work consistently to put it in _STRINGIFY because sometimes the compiler would actually interpret the pragma in there before stringify-ing it. */ - (void)asprintf(&fortran_have_ignore_tkr, "yes (%s)", + (void)opal_asprintf(&fortran_have_ignore_tkr, "yes (%s)", OMPI_FORTRAN_IGNORE_TKR_PREDECL); } else { fortran_have_ignore_tkr = strdup("no"); } #if OMPI_RTE_ORTE - (void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, ORTE progress: yes, Event lib: yes)", + (void)opal_asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, ORTE progress: yes, Event lib: yes)", "posix", OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no"); #else - (void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, Event lib: yes)", + (void)opal_asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, Event lib: yes)", "posix", OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no"); #endif - (void)asprintf(&ft_support, "%s (checkpoint thread: %s)", + (void)opal_asprintf(&ft_support, "%s (checkpoint thread: %s)", OPAL_ENABLE_FT ? "yes" : "no", OPAL_ENABLE_FT_THREAD ? "yes" : "no"); - (void)asprintf(&crdebug_support, "%s", + (void)opal_asprintf(&crdebug_support, "%s", OPAL_ENABLE_CRDEBUG ? "yes" : "no"); /* output values */ diff --git a/opal/dss/dss_pack.c b/opal/dss/dss_pack.c index 703886856f..62fa39f65d 100644 --- a/opal/dss/dss_pack.c +++ b/opal/dss/dss_pack.c @@ -13,6 +13,7 @@ * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -25,6 +26,7 @@ #include "opal/types.h" #include "opal/util/error.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal/dss/dss_internal.h" int opal_dss_pack(opal_buffer_t *buffer, @@ -339,7 +341,7 @@ int opal_dss_pack_float(opal_buffer_t *buffer, const void *src, char *convert; for (i = 0; i < num_vals; ++i) { - asprintf(&convert, "%f", ssrc[i]); + opal_asprintf(&convert, "%f", ssrc[i]); if (OPAL_SUCCESS != (ret = opal_dss_pack_string(buffer, &convert, 1, OPAL_STRING))) { free(convert); return ret; @@ -360,7 +362,7 @@ int opal_dss_pack_double(opal_buffer_t *buffer, const void *src, char *convert; for (i = 0; i < num_vals; ++i) { - asprintf(&convert, "%f", ssrc[i]); + opal_asprintf(&convert, "%f", ssrc[i]); if (OPAL_SUCCESS != (ret = opal_dss_pack_string(buffer, &convert, 1, OPAL_STRING))) { free(convert); return ret; diff --git a/opal/dss/dss_print.c b/opal/dss/dss_print.c index 8009c3f2c1..88c0de7192 100644 --- a/opal/dss/dss_print.c +++ b/opal/dss/dss_print.c @@ -13,6 +13,7 @@ * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -26,6 +27,7 @@ #include #include "opal/util/error.h" +#include "opal/util/printf.h" #include "opal/dss/dss_internal.h" int opal_dss_print(char **output, char *prefix, void *src, opal_data_type_t type) @@ -54,19 +56,19 @@ int opal_dss_print_byte(char **output, char *prefix, uint8_t *src, opal_data_typ char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_BYTE\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_BYTE\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_BYTE\tValue: %x", prefix, *src); + opal_asprintf(output, "%sData type: OPAL_BYTE\tValue: %x", prefix, *src); if (prefx != prefix) { free(prefx); } @@ -79,19 +81,19 @@ int opal_dss_print_string(char **output, char *prefix, char *src, opal_data_type char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_STRING\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_STRING\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_STRING\tValue: %s", prefx, src); + opal_asprintf(output, "%sData type: OPAL_STRING\tValue: %s", prefx, src); if (prefx != prefix) { free(prefx); } @@ -104,19 +106,19 @@ int opal_dss_print_size(char **output, char *prefix, size_t *src, opal_data_type char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_SIZE\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_SIZE\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_SIZE\tValue: %lu", prefx, (unsigned long) *src); + opal_asprintf(output, "%sData type: OPAL_SIZE\tValue: %lu", prefx, (unsigned long) *src); if (prefx != prefix) { free(prefx); } @@ -129,19 +131,19 @@ int opal_dss_print_pid(char **output, char *prefix, pid_t *src, opal_data_type_t char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_PID\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_PID\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_PID\tValue: %lu", prefx, (unsigned long) *src); + opal_asprintf(output, "%sData type: OPAL_PID\tValue: %lu", prefx, (unsigned long) *src); if (prefx != prefix) { free(prefx); } @@ -153,19 +155,19 @@ int opal_dss_print_bool(char **output, char *prefix, bool *src, opal_data_type_t char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_BOOL\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_BOOL\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_BOOL\tValue: %s", prefx, *src ? "TRUE" : "FALSE"); + opal_asprintf(output, "%sData type: OPAL_BOOL\tValue: %s", prefx, *src ? "TRUE" : "FALSE"); if (prefx != prefix) { free(prefx); } @@ -178,19 +180,19 @@ int opal_dss_print_int(char **output, char *prefix, int *src, opal_data_type_t t char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_INT\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_INT\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_INT\tValue: %ld", prefx, (long) *src); + opal_asprintf(output, "%sData type: OPAL_INT\tValue: %ld", prefx, (long) *src); if (prefx != prefix) { free(prefx); } @@ -203,19 +205,19 @@ int opal_dss_print_uint(char **output, char *prefix, int *src, opal_data_type_t char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_UINT\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_UINT\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_UINT\tValue: %lu", prefx, (unsigned long) *src); + opal_asprintf(output, "%sData type: OPAL_UINT\tValue: %lu", prefx, (unsigned long) *src); if (prefx != prefix) { free(prefx); } @@ -228,19 +230,19 @@ int opal_dss_print_uint8(char **output, char *prefix, uint8_t *src, opal_data_ty char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_UINT8\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_UINT8\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_UINT8\tValue: %u", prefx, (unsigned int) *src); + opal_asprintf(output, "%sData type: OPAL_UINT8\tValue: %u", prefx, (unsigned int) *src); if (prefx != prefix) { free(prefx); } @@ -253,19 +255,19 @@ int opal_dss_print_uint16(char **output, char *prefix, uint16_t *src, opal_data_ char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_UINT16\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_UINT16\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_UINT16\tValue: %u", prefx, (unsigned int) *src); + opal_asprintf(output, "%sData type: OPAL_UINT16\tValue: %u", prefx, (unsigned int) *src); if (prefx != prefix) { free(prefx); } @@ -278,19 +280,19 @@ int opal_dss_print_uint32(char **output, char *prefix, uint32_t *src, opal_data_ char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_UINT32\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_UINT32\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_UINT32\tValue: %u", prefx, (unsigned int) *src); + opal_asprintf(output, "%sData type: OPAL_UINT32\tValue: %u", prefx, (unsigned int) *src); if (prefx != prefix) { free(prefx); } @@ -303,19 +305,19 @@ int opal_dss_print_int8(char **output, char *prefix, int8_t *src, opal_data_type char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_INT8\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_INT8\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_INT8\tValue: %d", prefx, (int) *src); + opal_asprintf(output, "%sData type: OPAL_INT8\tValue: %d", prefx, (int) *src); if (prefx != prefix) { free(prefx); } @@ -328,19 +330,19 @@ int opal_dss_print_int16(char **output, char *prefix, int16_t *src, opal_data_ty char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_INT16\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_INT16\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_INT16\tValue: %d", prefx, (int) *src); + opal_asprintf(output, "%sData type: OPAL_INT16\tValue: %d", prefx, (int) *src); if (prefx != prefix) { free(prefx); } @@ -353,19 +355,19 @@ int opal_dss_print_int32(char **output, char *prefix, int32_t *src, opal_data_ty char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_INT32\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_INT32\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_INT32\tValue: %d", prefx, (int) *src); + opal_asprintf(output, "%sData type: OPAL_INT32\tValue: %d", prefx, (int) *src); if (prefx != prefix) { free(prefx); } @@ -383,12 +385,12 @@ int opal_dss_print_uint64(char **output, char *prefix, char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_UINT64\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_UINT64\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } @@ -396,9 +398,9 @@ int opal_dss_print_uint64(char **output, char *prefix, } #ifdef HAVE_INT64_T - asprintf(output, "%sData type: OPAL_UINT64\tValue: %lu", prefx, (unsigned long) *src); + opal_asprintf(output, "%sData type: OPAL_UINT64\tValue: %lu", prefx, (unsigned long) *src); #else - asprintf(output, "%sData type: OPAL_UINT64\tValue: unsupported", prefx); + opal_asprintf(output, "%sData type: OPAL_UINT64\tValue: unsupported", prefx); #endif /* HAVE_INT64_T */ if (prefx != prefix) { free(prefx); @@ -418,12 +420,12 @@ int opal_dss_print_int64(char **output, char *prefix, char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_INT64\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_INT64\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } @@ -431,9 +433,9 @@ int opal_dss_print_int64(char **output, char *prefix, } #ifdef HAVE_INT64_T - asprintf(output, "%sData type: OPAL_INT64\tValue: %ld", prefx, (long) *src); + opal_asprintf(output, "%sData type: OPAL_INT64\tValue: %ld", prefx, (long) *src); #else - asprintf(output, "%sData type: OPAL_INT64\tValue: unsupported", prefx); + opal_asprintf(output, "%sData type: OPAL_INT64\tValue: unsupported", prefx); #endif /* HAVE_INT64_T */ if (prefx != prefix) { free(prefx); @@ -448,19 +450,19 @@ int opal_dss_print_float(char **output, char *prefix, char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_FLOAT\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_FLOAT\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_FLOAT\tValue: %f", prefx, *src); + opal_asprintf(output, "%sData type: OPAL_FLOAT\tValue: %f", prefx, *src); if (prefx != prefix) { free(prefx); } @@ -474,19 +476,19 @@ int opal_dss_print_double(char **output, char *prefix, char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_DOUBLE\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_DOUBLE\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_DOUBLE\tValue: %f", prefx, *src); + opal_asprintf(output, "%sData type: OPAL_DOUBLE\tValue: %f", prefx, *src); if (prefx != prefix) { free(prefx); } @@ -501,12 +503,12 @@ int opal_dss_print_time(char **output, char *prefix, char *t; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_TIME\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_TIME\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } @@ -516,7 +518,7 @@ int opal_dss_print_time(char **output, char *prefix, t = ctime(src); t[strlen(t)-1] = '\0'; // remove trailing newline - asprintf(output, "%sData type: OPAL_TIME\tValue: %s", prefx, t); + opal_asprintf(output, "%sData type: OPAL_TIME\tValue: %s", prefx, t); if (prefx != prefix) { free(prefx); } @@ -530,19 +532,19 @@ int opal_dss_print_timeval(char **output, char *prefix, char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_TIMEVAL\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_TIMEVAL\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_TIMEVAL\tValue: %ld.%06ld", prefx, + opal_asprintf(output, "%sData type: OPAL_TIMEVAL\tValue: %ld.%06ld", prefx, (long)src->tv_sec, (long)src->tv_usec); if (prefx != prefix) { free(prefx); @@ -556,19 +558,19 @@ int opal_dss_print_null(char **output, char *prefix, void *src, opal_data_type_t char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_NULL\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_NULL\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_NULL", prefx); + opal_asprintf(output, "%sData type: OPAL_NULL", prefx); if (prefx != prefix) { free(prefx); } @@ -587,19 +589,19 @@ int opal_dss_print_data_type(char **output, char *prefix, opal_data_type_t *src, char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_DATA_TYPE\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_DATA_TYPE\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_DATA_TYPE\tValue: %lu", prefx, (unsigned long) *src); + opal_asprintf(output, "%sData type: OPAL_DATA_TYPE\tValue: %lu", prefx, (unsigned long) *src); if (prefx != prefix) { free(prefx); } @@ -614,19 +616,19 @@ int opal_dss_print_byte_object(char **output, char *prefix, opal_byte_object_t * char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_BYTE_OBJECT\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_BYTE_OBJECT\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_BYTE_OBJECT\tSize: %lu", prefx, (unsigned long) src->size); + opal_asprintf(output, "%sData type: OPAL_BYTE_OBJECT\tSize: %lu", prefx, (unsigned long) src->size); if (prefx != prefix) { free(prefx); } @@ -642,18 +644,18 @@ int opal_dss_print_pstat(char **output, char *prefix, opal_pstats_t *src, opal_d char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_PSTATS\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_PSTATS\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sOPAL_PSTATS SAMPLED AT: %ld.%06ld\n%snode: %s rank: %d pid: %d cmd: %s state: %c pri: %d #threads: %d Processor: %d\n" + opal_asprintf(output, "%sOPAL_PSTATS SAMPLED AT: %ld.%06ld\n%snode: %s rank: %d pid: %d cmd: %s state: %c pri: %d #threads: %d Processor: %d\n" "%s\ttime: %ld.%06ld cpu: %5.2f PSS: %8.2f VMsize: %8.2f PeakVMSize: %8.2f RSS: %8.2f\n", prefx, (long)src->sample_time.tv_sec, (long)src->sample_time.tv_usec, prefx, src->node, src->rank, src->pid, src->cmd, src->state[0], src->priority, src->num_threads, src->processor, @@ -673,18 +675,18 @@ int opal_dss_print_node_stat(char **output, char *prefix, opal_node_stats_t *src char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_NODE_STATS\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_NODE_STATS\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } return OPAL_SUCCESS; } - asprintf(output, "%sOPAL_NODE_STATS SAMPLED AT: %ld.%06ld\n%sTotal Mem: %5.2f Free Mem: %5.2f Buffers: %5.2f Cached: %5.2f\n" + opal_asprintf(output, "%sOPAL_NODE_STATS SAMPLED AT: %ld.%06ld\n%sTotal Mem: %5.2f Free Mem: %5.2f Buffers: %5.2f Cached: %5.2f\n" "%sSwapCached: %5.2f SwapTotal: %5.2f SwapFree: %5.2f Mapped: %5.2f\n" "%s\tla: %5.2f\tla5: %5.2f\tla15: %5.2f\n", prefx, (long)src->sample_time.tv_sec, (long)src->sample_time.tv_usec, @@ -706,12 +708,12 @@ int opal_dss_print_value(char **output, char *prefix, opal_value_t *src, opal_da char *prefx; /* deal with NULL prefix */ - if (NULL == prefix) asprintf(&prefx, " "); + if (NULL == prefix) opal_asprintf(&prefx, " "); else prefx = prefix; /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_VALUE\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_VALUE\tValue: NULL pointer", prefx); if (prefx != prefix) { free(prefx); } @@ -720,101 +722,101 @@ int opal_dss_print_value(char **output, char *prefix, opal_value_t *src, opal_da switch (src->type) { case OPAL_BOOL: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BOOL\tKey: %s\tValue: %s", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BOOL\tKey: %s\tValue: %s", prefx, src->key, src->data.flag ? "true" : "false"); break; case OPAL_BYTE: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BYTE\tKey: %s\tValue: %x", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BYTE\tKey: %s\tValue: %x", prefx, src->key, src->data.byte); break; case OPAL_STRING: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_STRING\tKey: %s\tValue: %s", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_STRING\tKey: %s\tValue: %s", prefx, src->key, src->data.string); break; case OPAL_SIZE: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_SIZE\tKey: %s\tValue: %lu", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_SIZE\tKey: %s\tValue: %lu", prefx, src->key, (unsigned long)src->data.size); break; case OPAL_PID: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_PID\tKey: %s\tValue: %lu", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_PID\tKey: %s\tValue: %lu", prefx, src->key, (unsigned long)src->data.pid); break; case OPAL_INT: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT\tKey: %s\tValue: %d", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT\tKey: %s\tValue: %d", prefx, src->key, src->data.integer); break; case OPAL_INT8: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT8\tKey: %s\tValue: %d", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT8\tKey: %s\tValue: %d", prefx, src->key, (int)src->data.int8); break; case OPAL_INT16: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT16\tKey: %s\tValue: %d", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT16\tKey: %s\tValue: %d", prefx, src->key, (int)src->data.int16); break; case OPAL_INT32: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT32\tKey: %s\tValue: %d", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT32\tKey: %s\tValue: %d", prefx, src->key, src->data.int32); break; case OPAL_INT64: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT64\tKey: %s\tValue: %ld", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT64\tKey: %s\tValue: %ld", prefx, src->key, (long)src->data.int64); break; case OPAL_UINT: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT\tKey: %s\tValue: %u", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT\tKey: %s\tValue: %u", prefx, src->key, src->data.uint); break; case OPAL_UINT8: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT8\tKey: %s\tValue: %u", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT8\tKey: %s\tValue: %u", prefx, src->key, (unsigned int)src->data.uint8); break; case OPAL_UINT16: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT16\tKey: %s\tValue: %u", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT16\tKey: %s\tValue: %u", prefx, src->key, (unsigned int)src->data.uint16); break; case OPAL_UINT32: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT32\tKey: %s\tValue: %u", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT32\tKey: %s\tValue: %u", prefx, src->key, src->data.uint32); break; case OPAL_UINT64: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT64\tKey: %s\tValue: %lu", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT64\tKey: %s\tValue: %lu", prefx, src->key, (unsigned long)src->data.uint64); break; case OPAL_FLOAT: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_FLOAT\tKey: %s\tValue: %f", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_FLOAT\tKey: %s\tValue: %f", prefx, src->key, src->data.fval); break; case OPAL_DOUBLE: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_DOUBLE\tKey: %s\tValue: %f", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_DOUBLE\tKey: %s\tValue: %f", prefx, src->key, src->data.dval); break; case OPAL_BYTE_OBJECT: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BYTE_OBJECT\tKey: %s\tData: %s\tSize: %lu", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BYTE_OBJECT\tKey: %s\tData: %s\tSize: %lu", prefx, src->key, (NULL == src->data.bo.bytes) ? "NULL" : "NON-NULL", (unsigned long)src->data.bo.size); break; case OPAL_TIMEVAL: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_TIMEVAL\tKey: %s\tValue: %ld.%06ld", prefx, + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_TIMEVAL\tKey: %s\tValue: %ld.%06ld", prefx, src->key, (long)src->data.tv.tv_sec, (long)src->data.tv.tv_usec); break; case OPAL_TIME: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_TIME\tKey: %s\tValue: %s", prefx, + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_TIME\tKey: %s\tValue: %s", prefx, src->key, ctime(&src->data.time)); break; case OPAL_NAME: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_NAME\tKey: %s\tValue: %s", prefx, + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_NAME\tKey: %s\tValue: %s", prefx, src->key, OPAL_NAME_PRINT(src->data.name)); break; case OPAL_PTR: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_PTR\tKey: %s", prefx, src->key); + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_PTR\tKey: %s", prefx, src->key); break; case OPAL_ENVAR: - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_ENVAR\tKey: %s\tName: %s\tValue: %s\tSeparator: %c", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_ENVAR\tKey: %s\tName: %s\tValue: %s\tSeparator: %c", prefx, src->key, (NULL == src->data.envar.envar) ? "NULL" : src->data.envar.envar, (NULL == src->data.envar.value) ? "NULL" : src->data.envar.value, ('\0' == src->data.envar.separator) ? ' ' : src->data.envar.separator); break; default: - asprintf(output, "%sOPAL_VALUE: Data type: UNKNOWN\tKey: %s\tValue: UNPRINTABLE", + opal_asprintf(output, "%sOPAL_VALUE: Data type: UNKNOWN\tKey: %s\tValue: UNPRINTABLE", prefx, src->key); break; } @@ -839,10 +841,10 @@ int opal_dss_print_name(char **output, char *prefix, opal_process_name_t *name, *output = NULL; if (NULL == name) { - asprintf(output, "%sData type: ORTE_PROCESS_NAME\tData Value: NULL", + opal_asprintf(output, "%sData type: ORTE_PROCESS_NAME\tData Value: NULL", (NULL == prefix ? " " : prefix)); } else { - asprintf(output, "%sData type: ORTE_PROCESS_NAME\tData Value: [%d,%d]", + opal_asprintf(output, "%sData type: ORTE_PROCESS_NAME\tData Value: [%d,%d]", (NULL == prefix ? " " : prefix), name->jobid, name->vpid); } @@ -859,11 +861,11 @@ int opal_dss_print_jobid(char **output, char *prefix, /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_JOBID\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_JOBID\tValue: NULL pointer", prefx); return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_JOBID\tValue: %s", prefx, opal_jobid_print(src->jobid)); + opal_asprintf(output, "%sData type: OPAL_JOBID\tValue: %s", prefx, opal_jobid_print(src->jobid)); return OPAL_SUCCESS; } @@ -877,11 +879,11 @@ int opal_dss_print_vpid(char **output, char *prefix, /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_VPID\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_VPID\tValue: NULL pointer", prefx); return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_VPID\tValue: %s", prefx, opal_vpid_print(src->vpid)); + opal_asprintf(output, "%sData type: OPAL_VPID\tValue: %s", prefx, opal_vpid_print(src->vpid)); return OPAL_SUCCESS; } @@ -895,11 +897,11 @@ int opal_dss_print_status(char **output, char *prefix, /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_STATUS\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_STATUS\tValue: NULL pointer", prefx); return OPAL_SUCCESS; } - asprintf(output, "%sData type: OPAL_STATUS\tValue: %s", prefx, opal_strerror(*src)); + opal_asprintf(output, "%sData type: OPAL_STATUS\tValue: %s", prefx, opal_strerror(*src)); return OPAL_SUCCESS; } @@ -914,11 +916,11 @@ int opal_dss_print_envar(char **output, char *prefix, /* if src is NULL, just print data type and return */ if (NULL == src) { - asprintf(output, "%sData type: OPAL_ENVAR\tValue: NULL pointer", prefx); + opal_asprintf(output, "%sData type: OPAL_ENVAR\tValue: NULL pointer", prefx); return OPAL_SUCCESS; } - asprintf(output, "%sOPAL_VALUE: Data type: OPAL_ENVAR\tName: %s\tValue: %s\tSeparator: %c", + opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_ENVAR\tName: %s\tValue: %s\tSeparator: %c", prefx, (NULL == src->envar) ? "NULL" : src->envar, (NULL == src->value) ? "NULL" : src->value, ('\0' == src->separator) ? ' ' : src->separator); diff --git a/opal/mca/base/mca_base_cmd_line.c b/opal/mca/base/mca_base_cmd_line.c index fd299cbf70..dae1dac3e5 100644 --- a/opal/mca/base/mca_base_cmd_line.c +++ b/opal/mca/base/mca_base_cmd_line.c @@ -11,6 +11,7 @@ * All rights reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved. * Copyright (c) 2014-2015 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -27,6 +28,7 @@ #include "opal/util/argv.h" #include "opal/util/opal_environ.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "opal/mca/base/base.h" #include "opal/constants.h" @@ -231,7 +233,7 @@ void mca_base_cmd_line_wrap_args(char **args) return; } i += 2; - asprintf(&tstr, "\"%s\"", args[i]); + opal_asprintf(&tstr, "\"%s\"", args[i]); free(args[i]); args[i] = tstr; } diff --git a/opal/mca/base/mca_base_component_compare.c b/opal/mca/base/mca_base_component_compare.c index aeec7bc715..ee385ad57a 100644 --- a/opal/mca/base/mca_base_component_compare.c +++ b/opal/mca/base/mca_base_component_compare.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -22,7 +23,7 @@ #include "opal/mca/mca.h" #include "opal/mca/base/base.h" - +#include "opal/util/printf.h" /* * Function for comparing two mca_base_component_priority_t structs so @@ -142,7 +143,7 @@ int mca_base_component_compatible( */ char * mca_base_component_to_string(const mca_base_component_t *a) { char * str = NULL; - if(0 > asprintf(&str, "%s.%s.%d.%d", a->mca_type_name, + if(0 > opal_asprintf(&str, "%s.%s.%d.%d", a->mca_type_name, a->mca_component_name, a->mca_component_major_version, a->mca_component_minor_version)) { return NULL; diff --git a/opal/mca/base/mca_base_component_repository.c b/opal/mca/base/mca_base_component_repository.c index 99e217d32a..7c677ea186 100644 --- a/opal/mca/base/mca_base_component_repository.c +++ b/opal/mca/base/mca_base_component_repository.c @@ -16,6 +16,7 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -44,6 +45,7 @@ #include "opal/class/opal_hash_table.h" #include "opal/util/basename.h" #include "opal/util/string_copy.h" +#include "opal/util/printf.h" #if OPAL_HAVE_DL_SUPPORT @@ -185,7 +187,7 @@ static int file_exists(const char *filename, const char *ext) return access (filename, F_OK) == 0; } - ret = asprintf(&final, "%s.%s", filename, ext); + ret = opal_asprintf(&final, "%s.%s", filename, ext); if (0 > ret || NULL == final) { return 0; } @@ -433,7 +435,7 @@ int mca_base_component_repository_open (mca_base_framework_t *framework, if( mca_base_component_track_load_errors ) { mca_base_failed_component_t *f_comp = OBJ_NEW(mca_base_failed_component_t); f_comp->comp = ri; - asprintf(&(f_comp->error_msg), "%s", err_msg); + opal_asprintf(&(f_comp->error_msg), "%s", err_msg); opal_list_append(&framework->framework_failed_components, &f_comp->super); } @@ -444,7 +446,7 @@ int mca_base_component_repository_open (mca_base_framework_t *framework, Malloc out enough space for it. */ do { - ret = asprintf (&struct_name, "mca_%s_%s_component", ri->ri_type, ri->ri_name); + ret = opal_asprintf (&struct_name, "mca_%s_%s_component", ri->ri_type, ri->ri_name); if (0 > ret) { ret = OPAL_ERR_OUT_OF_RESOURCE; break; diff --git a/opal/mca/base/mca_base_framework.c b/opal/mca/base/mca_base_framework.c index 9bd968319e..3bcc79b76c 100644 --- a/opal/mca/base/mca_base_framework.c +++ b/opal/mca/base/mca_base_framework.c @@ -4,6 +4,7 @@ * reserved. * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -15,6 +16,7 @@ #include "opal/include/opal/constants.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "mca_base_framework.h" #include "mca_base_var.h" @@ -82,7 +84,7 @@ int mca_base_framework_register (struct mca_base_framework_t *framework, return ret; } - asprintf (&desc, "Default selection set of components for the %s framework (" + opal_asprintf (&desc, "Default selection set of components for the %s framework (" " means use all components that can be found)", framework->framework_name); ret = mca_base_var_register (framework->framework_project, framework->framework_name, NULL, NULL, desc, MCA_BASE_VAR_TYPE_STRING, NULL, 0, @@ -94,7 +96,7 @@ int mca_base_framework_register (struct mca_base_framework_t *framework, } /* register a verbosity variable for this framework */ - ret = asprintf (&desc, "Verbosity level for the %s framework (default: 0)", + ret = opal_asprintf (&desc, "Verbosity level for the %s framework (default: 0)", framework->framework_name); if (0 > ret) { return OPAL_ERR_OUT_OF_RESOURCE; diff --git a/opal/mca/base/mca_base_open.c b/opal/mca/base/mca_base_open.c index 684117c932..cced80b526 100644 --- a/opal/mca/base/mca_base_open.c +++ b/opal/mca/base/mca_base_open.c @@ -14,6 +14,7 @@ * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -79,16 +80,16 @@ int mca_base_open(void) /* define the system and user default paths */ #if OPAL_WANT_HOME_CONFIG_FILES mca_base_system_default_path = strdup(opal_install_dirs.opallibdir); - asprintf(&mca_base_user_default_path, "%s"OPAL_PATH_SEP".openmpi"OPAL_PATH_SEP"components", opal_home_directory()); + opal_asprintf(&mca_base_user_default_path, "%s"OPAL_PATH_SEP".openmpi"OPAL_PATH_SEP"components", opal_home_directory()); #else - asprintf(&mca_base_system_default_path, "%s", opal_install_dirs.opallibdir); + opal_asprintf(&mca_base_system_default_path, "%s", opal_install_dirs.opallibdir); #endif /* see if the user wants to override the defaults */ if (NULL == mca_base_user_default_path) { value = strdup(mca_base_system_default_path); } else { - asprintf(&value, "%s%c%s", mca_base_system_default_path, + opal_asprintf(&value, "%s%c%s", mca_base_system_default_path, OPAL_ENV_SEP, mca_base_user_default_path); } @@ -156,7 +157,7 @@ int mca_base_open(void) set_defaults(&lds); } gethostname(hostname, sizeof(hostname)); - asprintf(&lds.lds_prefix, "[%s:%05d] ", hostname, getpid()); + opal_asprintf(&lds.lds_prefix, "[%s:%05d] ", hostname, getpid()); opal_output_reopen(0, &lds); opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, 0, "mca: base: opening components"); free(lds.lds_prefix); diff --git a/opal/mca/base/mca_base_pvar.c b/opal/mca/base/mca_base_pvar.c index 01f95e82a1..0efe919d13 100644 --- a/opal/mca/base/mca_base_pvar.c +++ b/opal/mca/base/mca_base_pvar.c @@ -8,6 +8,7 @@ * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -24,6 +25,7 @@ #include "opal/class/opal_pointer_array.h" #include "opal/class/opal_hash_table.h" +#include "opal/util/printf.h" static opal_hash_table_t mca_base_pvar_index_hash; static opal_pointer_array_t registered_pvars; @@ -845,16 +847,16 @@ int mca_base_pvar_dump(int index, char ***out, mca_base_var_dump_type_t output_t } /* build the message*/ - (void)asprintf(&tmp, "mca:%s:%s:pvar:%s:", framework, component, full_name); + (void)opal_asprintf(&tmp, "mca:%s:%s:pvar:%s:", framework, component, full_name); - (void)asprintf(out[0] + line++, "%sclass:%s", tmp, pvar_class_names[pvar->var_class]); - (void)asprintf(out[0] + line++, "%sread-only:%s", tmp, mca_base_pvar_is_readonly(pvar) ? "true" : "false"); - (void)asprintf(out[0] + line++, "%scontinuous:%s", tmp, mca_base_pvar_is_continuous(pvar) ? "true" : "false"); - (void)asprintf(out[0] + line++, "%satomic:%s", tmp, mca_base_pvar_is_atomic(pvar) ? "true" : "false"); + (void)opal_asprintf(out[0] + line++, "%sclass:%s", tmp, pvar_class_names[pvar->var_class]); + (void)opal_asprintf(out[0] + line++, "%sread-only:%s", tmp, mca_base_pvar_is_readonly(pvar) ? "true" : "false"); + (void)opal_asprintf(out[0] + line++, "%scontinuous:%s", tmp, mca_base_pvar_is_continuous(pvar) ? "true" : "false"); + (void)opal_asprintf(out[0] + line++, "%satomic:%s", tmp, mca_base_pvar_is_atomic(pvar) ? "true" : "false"); /* if it has a help message, output the help message */ if (pvar->description) { - (void)asprintf(out[0] + line++, "%shelp:%s", tmp, pvar->description); + (void)opal_asprintf(out[0] + line++, "%shelp:%s", tmp, pvar->description); } if (NULL != pvar->enumerator) { @@ -868,11 +870,11 @@ int mca_base_pvar_dump(int index, char ***out, mca_base_var_dump_type_t output_t continue; } - (void)asprintf(out[0] + line++, "%senumerator:value:%d:%s", tmp, enum_value, enum_string); + (void)opal_asprintf(out[0] + line++, "%senumerator:value:%d:%s", tmp, enum_value, enum_string); } } - (void)asprintf(out[0] + line++, "%stype:%s", tmp, ompi_var_type_names[pvar->type]); + (void)opal_asprintf(out[0] + line++, "%stype:%s", tmp, ompi_var_type_names[pvar->type]); free(tmp); // release tmp storage } else { /* there will be at most three lines in the pretty print case */ @@ -881,11 +883,11 @@ int mca_base_pvar_dump(int index, char ***out, mca_base_var_dump_type_t output_t return OPAL_ERR_OUT_OF_RESOURCE; } - (void)asprintf (out[0] + line++, "performance \"%s\" (type: %s, class: %s)", full_name, + (void)opal_asprintf (out[0] + line++, "performance \"%s\" (type: %s, class: %s)", full_name, ompi_var_type_names[pvar->type], pvar_class_names[pvar->var_class]); if (pvar->description) { - (void)asprintf(out[0] + line++, "%s", pvar->description); + (void)opal_asprintf(out[0] + line++, "%s", pvar->description); } if (NULL != pvar->enumerator) { @@ -893,7 +895,7 @@ int mca_base_pvar_dump(int index, char ***out, mca_base_var_dump_type_t output_t ret = pvar->enumerator->dump(pvar->enumerator, &values); if (OPAL_SUCCESS == ret) { - (void)asprintf (out[0] + line++, "Values: %s", values); + (void)opal_asprintf (out[0] + line++, "Values: %s", values); free (values); } } diff --git a/opal/mca/base/mca_base_var.c b/opal/mca/base/mca_base_var.c index 090416b628..e6b361b01b 100644 --- a/opal/mca/base/mca_base_var.c +++ b/opal/mca/base/mca_base_var.c @@ -17,6 +17,7 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -386,7 +387,7 @@ static void resolve_relative_paths(char **file_prefix, char *file_path, bool rel } else { /* Prepend the files to the search list */ - asprintf(&tmp_str, "%s%c%s", *file_prefix, sep, *files); + opal_asprintf(&tmp_str, "%s%c%s", *file_prefix, sep, *files); free (*files); *files = tmp_str; } @@ -409,11 +410,11 @@ int mca_base_var_cache_files(bool rel_path_search) } #if OPAL_WANT_HOME_CONFIG_FILES - asprintf(&mca_base_var_files, "%s"OPAL_PATH_SEP".openmpi" OPAL_PATH_SEP + opal_asprintf(&mca_base_var_files, "%s"OPAL_PATH_SEP".openmpi" OPAL_PATH_SEP "mca-params.conf%c%s" OPAL_PATH_SEP "openmpi-mca-params.conf", home, ',', opal_install_dirs.sysconfdir); #else - asprintf(&mca_base_var_files, "%s" OPAL_PATH_SEP "openmpi-mca-params.conf", + opal_asprintf(&mca_base_var_files, "%s" OPAL_PATH_SEP "openmpi-mca-params.conf", opal_install_dirs.sysconfdir); #endif @@ -434,7 +435,7 @@ int mca_base_var_cache_files(bool rel_path_search) (void) mca_base_var_register_synonym (ret, "opal", "mca", NULL, "param_files", MCA_BASE_VAR_SYN_FLAG_DEPRECATED); - ret = asprintf(&mca_base_var_override_file, "%s" OPAL_PATH_SEP "openmpi-mca-params-override.conf", + ret = opal_asprintf(&mca_base_var_override_file, "%s" OPAL_PATH_SEP "openmpi-mca-params-override.conf", opal_install_dirs.sysconfdir); if (0 > ret) { return OPAL_ERR_OUT_OF_RESOURCE; @@ -488,7 +489,7 @@ int mca_base_var_cache_files(bool rel_path_search) return ret; } - ret = asprintf(&mca_base_param_file_path, "%s" OPAL_PATH_SEP "amca-param-sets%c%s", + ret = opal_asprintf(&mca_base_param_file_path, "%s" OPAL_PATH_SEP "amca-param-sets%c%s", opal_install_dirs.opaldatadir, OPAL_ENV_SEP, cwd); if (0 > ret) { return OPAL_ERR_OUT_OF_RESOURCE; @@ -517,7 +518,7 @@ int mca_base_var_cache_files(bool rel_path_search) if (NULL != mca_base_param_file_path) { char *tmp_str = mca_base_param_file_path; - asprintf(&mca_base_param_file_path, "%s%c%s", force_agg_path, OPAL_ENV_SEP, tmp_str); + opal_asprintf(&mca_base_param_file_path, "%s%c%s", force_agg_path, OPAL_ENV_SEP, tmp_str); free(tmp_str); } else { mca_base_param_file_path = strdup(force_agg_path); @@ -598,7 +599,7 @@ static int var_set_string (mca_base_var_t *var, char *value) in the future. */ if (0 == strncmp (value, "~/", 2)) { if (NULL != home) { - ret = asprintf (&value, "%s/%s", home, value + 2); + ret = opal_asprintf (&value, "%s/%s", home, value + 2); if (0 > ret) { return OPAL_ERROR; } @@ -617,7 +618,7 @@ static int var_set_string (mca_base_var_t *var, char *value) tmp[0] = '\0'; tmp += 3; - ret = asprintf (&tmp, "%s:%s%s%s", value, + ret = opal_asprintf (&tmp, "%s:%s%s%s", value, home ? home : "", home ? "/" : "", tmp); free (value); @@ -894,7 +895,7 @@ int mca_base_var_env_name(const char *param_name, assert (NULL != env_name); - ret = asprintf(env_name, "%s%s", mca_prefix, param_name); + ret = opal_asprintf(env_name, "%s%s", mca_prefix, param_name); if (0 > ret) { return OPAL_ERR_OUT_OF_RESOURCE; } @@ -1049,7 +1050,7 @@ int mca_base_var_build_env(char ***env, int *num_env, bool internal) goto cleanup; } - ret = asprintf (&str, "%s%s=%s", mca_prefix, var->mbv_full_name, + ret = opal_asprintf (&str, "%s%s=%s", mca_prefix, var->mbv_full_name, value_string); free (value_string); if (0 > ret) { @@ -1062,11 +1063,11 @@ int mca_base_var_build_env(char ***env, int *num_env, bool internal) switch (var->mbv_source) { case MCA_BASE_VAR_SOURCE_FILE: case MCA_BASE_VAR_SOURCE_OVERRIDE: - asprintf (&str, "%sSOURCE_%s=FILE:%s", mca_prefix, var->mbv_full_name, + opal_asprintf (&str, "%sSOURCE_%s=FILE:%s", mca_prefix, var->mbv_full_name, mca_base_var_source_file (var)); break; case MCA_BASE_VAR_SOURCE_COMMAND_LINE: - asprintf (&str, "%sSOURCE_%s=COMMAND_LINE", mca_prefix, var->mbv_full_name); + opal_asprintf (&str, "%sSOURCE_%s=COMMAND_LINE", mca_prefix, var->mbv_full_name); break; case MCA_BASE_VAR_SOURCE_ENV: case MCA_BASE_VAR_SOURCE_SET: @@ -1916,12 +1917,12 @@ static char *source_name(mca_base_var_t *var) int rc; if (fv) { - rc = asprintf(&ret, "file (%s:%d)", fv->mbvfv_file, fv->mbvfv_lineno); + rc = opal_asprintf(&ret, "file (%s:%d)", fv->mbvfv_file, fv->mbvfv_lineno); } else { - rc = asprintf(&ret, "file (%s)", var->mbv_source_file); + rc = opal_asprintf(&ret, "file (%s)", var->mbv_source_file); } - /* some compilers will warn if the return code of asprintf is not checked (even if it is cast to void) */ + /* some compilers will warn if the return code of opal_asprintf is not checked (even if it is cast to void) */ if (0 > rc) { return NULL; } @@ -1944,7 +1945,7 @@ static int var_value_string (mca_base_var_t *var, char **value_string) * as "unset" by default. */ if ((var->mbv_flags & MCA_BASE_VAR_FLAG_DEF_UNSET) && (MCA_BASE_VAR_SOURCE_DEFAULT == var->mbv_source)){ - asprintf (value_string, "%s", "unset"); + opal_asprintf (value_string, "%s", "unset"); return OPAL_SUCCESS; } @@ -1956,45 +1957,45 @@ static int var_value_string (mca_base_var_t *var, char **value_string) if (NULL == var->mbv_enumerator) { switch (var->mbv_type) { case MCA_BASE_VAR_TYPE_INT: - ret = asprintf (value_string, "%d", value->intval); + ret = opal_asprintf (value_string, "%d", value->intval); break; case MCA_BASE_VAR_TYPE_INT32_T: - ret = asprintf (value_string, "%" PRId32, value->int32tval); + ret = opal_asprintf (value_string, "%" PRId32, value->int32tval); break; case MCA_BASE_VAR_TYPE_UINT32_T: - ret = asprintf (value_string, "%" PRIu32, value->uint32tval); + ret = opal_asprintf (value_string, "%" PRIu32, value->uint32tval); break; case MCA_BASE_VAR_TYPE_INT64_T: - ret = asprintf (value_string, "%" PRId64, value->int64tval); + ret = opal_asprintf (value_string, "%" PRId64, value->int64tval); break; case MCA_BASE_VAR_TYPE_UINT64_T: - ret = asprintf (value_string, "%" PRIu64, value->uint64tval); + ret = opal_asprintf (value_string, "%" PRIu64, value->uint64tval); break; case MCA_BASE_VAR_TYPE_LONG: - ret = asprintf (value_string, "%ld", value->longval); + ret = opal_asprintf (value_string, "%ld", value->longval); break; case MCA_BASE_VAR_TYPE_UNSIGNED_INT: - ret = asprintf (value_string, "%u", value->uintval); + ret = opal_asprintf (value_string, "%u", value->uintval); break; case MCA_BASE_VAR_TYPE_UNSIGNED_LONG: - ret = asprintf (value_string, "%lu", value->ulval); + ret = opal_asprintf (value_string, "%lu", value->ulval); break; case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG: - ret = asprintf (value_string, "%llu", value->ullval); + ret = opal_asprintf (value_string, "%llu", value->ullval); break; case MCA_BASE_VAR_TYPE_SIZE_T: - ret = asprintf (value_string, "%" PRIsize_t, value->sizetval); + ret = opal_asprintf (value_string, "%" PRIsize_t, value->sizetval); break; case MCA_BASE_VAR_TYPE_STRING: case MCA_BASE_VAR_TYPE_VERSION_STRING: - ret = asprintf (value_string, "%s", + ret = opal_asprintf (value_string, "%s", value->stringval ? value->stringval : ""); break; case MCA_BASE_VAR_TYPE_BOOL: - ret = asprintf (value_string, "%d", value->boolval); + ret = opal_asprintf (value_string, "%d", value->boolval); break; case MCA_BASE_VAR_TYPE_DOUBLE: - ret = asprintf (value_string, "%lf", value->lfval); + ret = opal_asprintf (value_string, "%lf", value->lfval); break; default: ret = -1; @@ -2138,30 +2139,30 @@ int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_type_t output_typ } /* build the message*/ - asprintf(&tmp, "mca:%s:%s:param:%s:", framework, component, + opal_asprintf(&tmp, "mca:%s:%s:param:%s:", framework, component, full_name); /* Output the value */ char *colon = strchr(value_string, ':'); if (NULL != colon) { - asprintf(out[0] + line++, "%svalue:\"%s\"", tmp, value_string); + opal_asprintf(out[0] + line++, "%svalue:\"%s\"", tmp, value_string); } else { - asprintf(out[0] + line++, "%svalue:%s", tmp, value_string); + opal_asprintf(out[0] + line++, "%svalue:%s", tmp, value_string); } /* Output the source */ - asprintf(out[0] + line++, "%ssource:%s", tmp, source_string); + opal_asprintf(out[0] + line++, "%ssource:%s", tmp, source_string); /* Output whether it's read only or writable */ - asprintf(out[0] + line++, "%sstatus:%s", tmp, - VAR_IS_SETTABLE(var[0]) ? "writeable" : "read-only"); + opal_asprintf(out[0] + line++, "%sstatus:%s", tmp, + VAR_IS_SETTABLE(var[0]) ? "writeable" : "read-only"); /* Output the info level of this parametere */ - asprintf(out[0] + line++, "%slevel:%d", tmp, var->mbv_info_lvl + 1); + opal_asprintf(out[0] + line++, "%slevel:%d", tmp, var->mbv_info_lvl + 1); /* If it has a help message, output the help message */ if (var->mbv_description) { - asprintf(out[0] + line++, "%shelp:%s", tmp, var->mbv_description); + opal_asprintf(out[0] + line++, "%shelp:%s", tmp, var->mbv_description); } if (NULL != var->mbv_enumerator) { @@ -2175,18 +2176,18 @@ int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_type_t output_typ continue; } - asprintf(out[0] + line++, "%senumerator:value:%d:%s", tmp, enum_value, enum_string); + opal_asprintf(out[0] + line++, "%senumerator:value:%d:%s", tmp, enum_value, enum_string); } } /* Is this variable deprecated? */ - asprintf(out[0] + line++, "%sdeprecated:%s", tmp, VAR_IS_DEPRECATED(var[0]) ? "yes" : "no"); + opal_asprintf(out[0] + line++, "%sdeprecated:%s", tmp, VAR_IS_DEPRECATED(var[0]) ? "yes" : "no"); - asprintf(out[0] + line++, "%stype:%s", tmp, ompi_var_type_names[var->mbv_type]); + opal_asprintf(out[0] + line++, "%stype:%s", tmp, ompi_var_type_names[var->mbv_type]); /* Does this parameter have any synonyms or is it a synonym? */ if (VAR_IS_SYNONYM(var[0])) { - asprintf(out[0] + line++, "%ssynonym_of:name:%s", tmp, original->mbv_full_name); + opal_asprintf(out[0] + line++, "%ssynonym_of:name:%s", tmp, original->mbv_full_name); } else if (opal_value_array_get_size(&var->mbv_synonyms)) { for (i = 0 ; i < synonym_count ; ++i) { mca_base_var_t *synonym; @@ -2196,7 +2197,7 @@ int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_type_t output_typ continue; } - asprintf(out[0] + line++, "%ssynonym:name:%s", tmp, synonym->mbv_full_name); + opal_asprintf(out[0] + line++, "%ssynonym:name:%s", tmp, synonym->mbv_full_name); } } @@ -2210,24 +2211,24 @@ int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_type_t output_typ return OPAL_ERR_OUT_OF_RESOURCE; } - asprintf (out[0], "%s \"%s\" (current value: \"%s\", data source: %s, level: %d %s, type: %s", + opal_asprintf (out[0], "%s \"%s\" (current value: \"%s\", data source: %s, level: %d %s, type: %s", VAR_IS_DEFAULT_ONLY(var[0]) ? "informational" : "parameter", full_name, value_string, source_string, var->mbv_info_lvl + 1, info_lvl_strings[var->mbv_info_lvl], ompi_var_type_names[var->mbv_type]); tmp = out[0][0]; if (VAR_IS_DEPRECATED(var[0])) { - asprintf (out[0], "%s, deprecated", tmp); + opal_asprintf (out[0], "%s, deprecated", tmp); free (tmp); tmp = out[0][0]; } /* Does this parameter have any synonyms or is it a synonym? */ if (VAR_IS_SYNONYM(var[0])) { - asprintf(out[0], "%s, synonym of: %s)", tmp, original->mbv_full_name); + opal_asprintf(out[0], "%s, synonym of: %s)", tmp, original->mbv_full_name); free (tmp); } else if (synonym_count) { - asprintf(out[0], "%s, synonyms: ", tmp); + opal_asprintf(out[0], "%s, synonyms: ", tmp); free (tmp); for (i = 0 ; i < synonym_count ; ++i) { @@ -2240,21 +2241,21 @@ int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_type_t output_typ tmp = out[0][0]; if (synonym_count == i+1) { - asprintf(out[0], "%s%s)", tmp, synonym->mbv_full_name); + opal_asprintf(out[0], "%s%s)", tmp, synonym->mbv_full_name); } else { - asprintf(out[0], "%s%s, ", tmp, synonym->mbv_full_name); + opal_asprintf(out[0], "%s%s, ", tmp, synonym->mbv_full_name); } free(tmp); } } else { - asprintf(out[0], "%s)", tmp); + opal_asprintf(out[0], "%s)", tmp); free(tmp); } line++; if (var->mbv_description) { - asprintf(out[0] + line++, "%s", var->mbv_description); + opal_asprintf(out[0] + line++, "%s", var->mbv_description); } if (NULL != var->mbv_enumerator) { @@ -2262,7 +2263,7 @@ int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_type_t output_typ ret = var->mbv_enumerator->dump(var->mbv_enumerator, &values); if (OPAL_SUCCESS == ret) { - asprintf (out[0] + line++, "Valid values: %s", values); + opal_asprintf (out[0] + line++, "Valid values: %s", values); free (values); } } @@ -2274,7 +2275,7 @@ int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_type_t output_typ return OPAL_ERR_OUT_OF_RESOURCE; } - asprintf(out[0], "%s=%s (%s)", var->mbv_full_name, value_string, source_string); + opal_asprintf(out[0], "%s=%s (%s)", var->mbv_full_name, value_string, source_string); } free (value_string); diff --git a/opal/mca/base/mca_base_var_enum.c b/opal/mca/base/mca_base_var_enum.c index 626a8db295..67aa875f5f 100644 --- a/opal/mca/base/mca_base_var_enum.c +++ b/opal/mca/base/mca_base_var_enum.c @@ -16,6 +16,7 @@ * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,6 +30,7 @@ #include "opal/mca/base/mca_base_vari.h" #include "opal/mca/base/base.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include #include @@ -277,7 +279,7 @@ static int mca_base_var_enum_verbose_sfv (mca_base_var_enum_t *self, const int v } if (string_value) { - ret = asprintf (string_value, "%d", value); + ret = opal_asprintf (string_value, "%d", value); if (0 > ret) { return OPAL_ERR_OUT_OF_RESOURCE; } @@ -296,7 +298,7 @@ static int mca_base_var_enum_verbose_dump (mca_base_var_enum_t *self, char **out return ret; } - ret = asprintf (&tmp, "%s, 0 - 100", *out); + ret = opal_asprintf (&tmp, "%s, 0 - 100", *out); free (*out); if (0 > ret) { *out = NULL; @@ -419,7 +421,7 @@ static int enum_dump (mca_base_var_enum_t *self, char **out) tmp = NULL; for (i = 0; i < self->enum_value_count && self->enum_values[i].string ; ++i) { - ret = asprintf (out, "%s%s%d:\"%s\"", tmp ? tmp : "", tmp ? ", " : "", self->enum_values[i].value, + ret = opal_asprintf (out, "%s%s%d:\"%s\"", tmp ? tmp : "", tmp ? ", " : "", self->enum_values[i].value, self->enum_values[i].string); if (tmp) free (tmp); if (0 > ret) { @@ -646,7 +648,7 @@ static int enum_string_from_value_flag (mca_base_var_enum_t *self, const int val tmp = out; - ret = asprintf (&out, "%s%s%s", tmp ? tmp : "", tmp ? "," : "", flag_enum->enum_flags[i].string); + ret = opal_asprintf (&out, "%s%s%s", tmp ? tmp : "", tmp ? "," : "", flag_enum->enum_flags[i].string); free (tmp); if (0 > ret) { @@ -695,7 +697,7 @@ static int enum_dump_flag (mca_base_var_enum_t *self, char **out) for (int i = 0; i < self->enum_value_count ; ++i) { tmp = *out; - ret = asprintf (out, "%s%s0x%x:\"%s\"", tmp, i ? ", " : " ", flag_enum->enum_flags[i].flag, + ret = opal_asprintf (out, "%s%s0x%x:\"%s\"", tmp, i ? ", " : " ", flag_enum->enum_flags[i].flag, flag_enum->enum_flags[i].string); free (tmp); if (0 > ret) { diff --git a/opal/mca/btl/base/btl_base_error.c b/opal/mca/btl/base/btl_base_error.c index 9b525c3239..3be2a3a8e0 100644 --- a/opal/mca/btl/base/btl_base_error.c +++ b/opal/mca/btl/base/btl_base_error.c @@ -13,6 +13,7 @@ * Copyright (c) 2012 Los Alamos National Security, LLC. * All rights reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -27,6 +28,7 @@ #include "opal/util/show_help.h" #include "opal/util/proc.h" +#include "opal/util/printf.h" #include "base.h" #include "btl_base_error.h" @@ -63,7 +65,7 @@ void mca_btl_base_error_no_nics(const char* transport, char *procid; if (mca_btl_base_warn_component_unused) { /* print out no-nic warning if user told us to */ - asprintf(&procid, "%s", OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); + opal_asprintf(&procid, "%s", OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); opal_show_help("help-mpi-btl-base.txt", "btl:no-nics", true, procid, transport, opal_process_info.nodename, diff --git a/opal/mca/btl/ofi/btl_ofi_component.c b/opal/mca/btl/ofi/btl_ofi_component.c index d1e03fc2d7..c57b5040b6 100644 --- a/opal/mca/btl/ofi/btl_ofi_component.c +++ b/opal/mca/btl/ofi/btl_ofi_component.c @@ -14,6 +14,7 @@ * reserved. * Copyright (c) 2018 Intel, Inc, All rights reserved * + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -24,6 +25,8 @@ #include "opal_config.h" +#include "opal/util/printf.h" + #include "opal/mca/btl/btl.h" #include "opal/mca/btl/base/base.h" #include "opal/mca/hwloc/base/base.h" @@ -88,7 +91,7 @@ static int mca_btl_ofi_component_register(void) char *msg; mca_btl_ofi_module_t *module = &mca_btl_ofi_module_template; - asprintf(&msg, "BTL OFI mode of operation. Valid values are: %d = One-Sided only, %d=Two-Sided only, " + opal_asprintf(&msg, "BTL OFI mode of operation. Valid values are: %d = One-Sided only, %d=Two-Sided only, " "%d = Both one and two sided. BTL OFI is only optimized for one-sided communication", MCA_BTL_OFI_MODE_ONE_SIDED, MCA_BTL_OFI_MODE_TWO_SIDED, diff --git a/opal/mca/btl/ofi/btl_ofi_module.c b/opal/mca/btl/ofi/btl_ofi_module.c index f9ae6421a5..95a77d1f59 100644 --- a/opal/mca/btl/ofi/btl_ofi_module.c +++ b/opal/mca/btl/ofi/btl_ofi_module.c @@ -14,6 +14,7 @@ * reserved. * Copyright (c) 2018 Intel, Inc, All rights reserved * + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -24,6 +25,7 @@ #include "opal_config.h" #include #include "opal/class/opal_bitmap.h" +#include "opal/util/printf.h" #include "opal/mca/btl/btl.h" #include "opal/datatype/opal_convertor.h" #include "opal/mca/mpool/base/base.h" @@ -138,7 +140,7 @@ void mca_btl_ofi_rcache_init (mca_btl_ofi_module_t *module) mca_rcache_base_resources_t rcache_resources; char *tmp; - (void) asprintf (&tmp, "ofi.%s", module->linux_device_name); + (void) opal_asprintf (&tmp, "ofi.%s", module->linux_device_name); rcache_resources.cache_name = tmp; rcache_resources.reg_data = (void *) module; diff --git a/opal/mca/btl/openib/btl_openib.c b/opal/mca/btl/openib/btl_openib.c index dc279df834..053f4a4e9d 100644 --- a/opal/mca/btl/openib/btl_openib.c +++ b/opal/mca/btl/openib/btl_openib.c @@ -22,6 +22,7 @@ * Copyright (c) 2014-2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Bull SAS. All rights reserved + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -36,6 +37,7 @@ #include "opal/util/output.h" #include "opal/util/arch.h" #include "opal/util/proc.h" +#include "opal/util/printf.h" #include "opal/include/opal_stdint.h" #include "opal/util/show_help.h" #include "opal/mca/btl/btl.h" @@ -144,11 +146,11 @@ void mca_btl_openib_show_init_error(const char *file, int line, ret = -1; #endif if (0 != ret) { - asprintf(&str_limit, "Unknown"); + opal_asprintf(&str_limit, "Unknown"); } else if (limit.rlim_cur == RLIM_INFINITY) { - asprintf(&str_limit, "unlimited"); + opal_asprintf(&str_limit, "unlimited"); } else { - asprintf(&str_limit, "%ld", (long)limit.rlim_cur); + opal_asprintf(&str_limit, "%ld", (long)limit.rlim_cur); } opal_show_help("help-mpi-btl-openib.txt", "init-fail-no-mem", diff --git a/opal/mca/btl/openib/btl_openib_component.c b/opal/mca/btl/openib/btl_openib_component.c index f8bf75cb1d..1775441819 100644 --- a/opal/mca/btl/openib/btl_openib_component.c +++ b/opal/mca/btl/openib/btl_openib_component.c @@ -22,6 +22,7 @@ * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Bull SAS. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -64,6 +65,7 @@ #include "opal/mca/installdirs/installdirs.h" #include "opal_stdint.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "opal/mca/btl/btl.h" #include "opal/mca/btl/base/base.h" #include "opal/mca/mpool/base/base.h" @@ -1861,7 +1863,7 @@ static int init_one_device(opal_list_t *btl_list, struct ibv_device* ib_dev) "eager RDMA and progress threads", true); } - asprintf (&rcache_resources.cache_name, "verbs.%" PRIu64, device->ib_dev_attr.node_guid); + opal_asprintf (&rcache_resources.cache_name, "verbs.%" PRIu64, device->ib_dev_attr.node_guid); rcache_resources.reg_data = (void*)device; rcache_resources.sizeof_reg = sizeof(mca_btl_openib_reg_t); rcache_resources.register_mem = openib_reg_mr; diff --git a/opal/mca/btl/openib/btl_openib_mca.c b/opal/mca/btl/openib/btl_openib_mca.c index 54b4777714..7896287c62 100644 --- a/opal/mca/btl/openib/btl_openib_mca.c +++ b/opal/mca/btl/openib/btl_openib_mca.c @@ -20,6 +20,7 @@ * Copyright (c) 2014-2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -31,6 +32,7 @@ #include #include "opal/util/bit_ops.h" +#include "opal/util/printf.h" #include "opal/mca/common/verbs/common_verbs.h" #include "opal/mca/installdirs/installdirs.h" #include "opal/util/os_dirpath.h" @@ -267,7 +269,7 @@ int btl_openib_register_mca_params(void) MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT, &mca_btl_openib_component.cq_poll_batch, REGINT_GE_ONE)); - asprintf(&str, "%s/mca-btl-openib-device-params.ini", + opal_asprintf(&str, "%s/mca-btl-openib-device-params.ini", opal_install_dirs.opaldatadir); if (NULL == str) { return OPAL_ERR_OUT_OF_RESOURCE; @@ -369,7 +371,7 @@ int btl_openib_register_mca_params(void) "(must be >= 0)", 4, &mca_btl_openib_component.ib_qp_ous_rd_atom, 0)); - asprintf(&msg, "OpenFabrics MTU, in bytes (if not specified in INI files). Valid values are: %d=256 bytes, %d=512 bytes, %d=1024 bytes, %d=2048 bytes, %d=4096 bytes", + opal_asprintf(&msg, "OpenFabrics MTU, in bytes (if not specified in INI files). Valid values are: %d=256 bytes, %d=512 bytes, %d=1024 bytes, %d=2048 bytes, %d=4096 bytes", IBV_MTU_256, IBV_MTU_512, IBV_MTU_1024, @@ -645,7 +647,7 @@ int btl_openib_register_mca_params(void) mid_qp_size = 1024; } - asprintf(&default_qps, + opal_asprintf(&default_qps, "S,128,256,192,128:S,%u,1024,1008,64:S,%u,1024,1008,64:S,%u,1024,1008,64", mid_qp_size, (uint32_t)mca_btl_openib_module.super.btl_eager_limit, diff --git a/opal/mca/btl/openib/btl_openib_xrc.c b/opal/mca/btl/openib/btl_openib_xrc.c index 0b3322ba1d..df88aa78eb 100644 --- a/opal/mca/btl/openib/btl_openib_xrc.c +++ b/opal/mca/btl/openib/btl_openib_xrc.c @@ -8,6 +8,7 @@ * Copyright (c) 2014 Bull SAS. All rights reserved. * Copyright (c) 2016 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -28,6 +29,7 @@ #include #include "opal/mca/btl/base/base.h" +#include "opal/util/printf.h" #include "btl_openib_xrc.h" #include "btl_openib.h" @@ -53,7 +55,7 @@ int mca_btl_openib_open_xrc_domain(struct mca_btl_openib_device_t *device) #endif dev_name = ibv_get_device_name(device->ib_dev); - len = asprintf(&xrc_file_name, + len = opal_asprintf(&xrc_file_name, "%s"OPAL_PATH_SEP"openib_xrc_domain_%s", opal_process_info.job_session_dir, dev_name); if (0 > len) { diff --git a/opal/mca/btl/openib/connect/btl_openib_connect_base.c b/opal/mca/btl/openib/connect/btl_openib_connect_base.c index 7f1f75c6d9..0db8c62b83 100644 --- a/opal/mca/btl/openib/connect/btl_openib_connect_base.c +++ b/opal/mca/btl/openib/connect/btl_openib_connect_base.c @@ -8,6 +8,7 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -31,6 +32,7 @@ #include "opal/util/output.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "opal/util/sys_limits.h" #include "opal/align.h" @@ -90,7 +92,7 @@ int opal_btl_openib_connect_base_register(void) } all_cpc_names = opal_argv_join(temp, ','); opal_argv_free(temp); - asprintf(&string, + opal_asprintf(&string, "Method used to select OpenFabrics connections (valid values: %s)", all_cpc_names); @@ -102,7 +104,7 @@ int opal_btl_openib_connect_base_register(void) &btl_openib_cpc_include); free(string); - asprintf(&string, + opal_asprintf(&string, "Method used to exclude OpenFabrics connections (valid values: %s)", all_cpc_names); diff --git a/opal/mca/btl/openib/connect/btl_openib_connect_rdmacm.c b/opal/mca/btl/openib/connect/btl_openib_connect_rdmacm.c index 5fa407dd5f..4312becfe5 100644 --- a/opal/mca/btl/openib/connect/btl_openib_connect_rdmacm.c +++ b/opal/mca/btl/openib/connect/btl_openib_connect_rdmacm.c @@ -12,6 +12,7 @@ * of Tennessee Research Foundation. All rights * reserved. * + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -55,6 +56,7 @@ #include "opal/util/error.h" #include "opal/util/show_help.h" #include "opal/util/proc.h" +#include "opal/util/printf.h" #include "opal/runtime/opal_progress_threads.h" #include "btl_openib_proc.h" @@ -351,7 +353,7 @@ static void rdmacm_component_register(void) static char *stringify(uint32_t addr) { char *line = (char *) malloc(64); - asprintf(&line, "%d.%d.%d.%d (0x%x)", + opal_asprintf(&line, "%d.%d.%d.%d (0x%x)", #if defined(WORDS_BIGENDIAN) (addr >> 24), (addr >> 16) & 0xff, diff --git a/opal/mca/btl/smcuda/btl_smcuda_component.c b/opal/mca/btl/smcuda/btl_smcuda_component.c index d77398a996..df07df06f1 100644 --- a/opal/mca/btl/smcuda/btl_smcuda_component.c +++ b/opal/mca/btl/smcuda/btl_smcuda_component.c @@ -16,6 +16,7 @@ * reserved. * Copyright (c) 2011-2015 NVIDIA Corporation. All rights reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -46,6 +47,7 @@ #include "opal/util/bit_ops.h" #include "opal/util/output.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "opal/mca/mpool/base/base.h" #include "opal/mca/common/sm/common_sm.h" @@ -438,28 +440,28 @@ set_uniq_paths_for_init_rndv(mca_btl_smcuda_component_t *comp_ptr) comp_ptr->sm_ctl_file_name = NULL; comp_ptr->sm_rndv_file_name = NULL; - if (asprintf(&comp_ptr->sm_mpool_ctl_file_name, + if (opal_asprintf(&comp_ptr->sm_mpool_ctl_file_name, "%s"OPAL_PATH_SEP"shared_mem_cuda_pool.%s", opal_process_info.job_session_dir, opal_process_info.nodename) < 0) { /* rc set */ goto out; } - if (asprintf(&comp_ptr->sm_mpool_rndv_file_name, + if (opal_asprintf(&comp_ptr->sm_mpool_rndv_file_name, "%s"OPAL_PATH_SEP"shared_mem_cuda_pool_rndv.%s", opal_process_info.job_session_dir, opal_process_info.nodename) < 0) { /* rc set */ goto out; } - if (asprintf(&comp_ptr->sm_ctl_file_name, + if (opal_asprintf(&comp_ptr->sm_ctl_file_name, "%s"OPAL_PATH_SEP"shared_mem_cuda_btl_module.%s", opal_process_info.job_session_dir, opal_process_info.nodename) < 0) { /* rc set */ goto out; } - if (asprintf(&comp_ptr->sm_rndv_file_name, + if (opal_asprintf(&comp_ptr->sm_rndv_file_name, "%s"OPAL_PATH_SEP"shared_mem_cuda_btl_rndv.%s", opal_process_info.job_session_dir, opal_process_info.nodename) < 0) { diff --git a/opal/mca/btl/tcp/btl_tcp_component.c b/opal/mca/btl/tcp/btl_tcp_component.c index d068aecb22..bf06552e61 100644 --- a/opal/mca/btl/tcp/btl_tcp_component.c +++ b/opal/mca/btl/tcp/btl_tcp_component.c @@ -19,6 +19,7 @@ * Copyright (c) 2014-2015 Intel, Inc. All rights reserved. * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -68,6 +69,7 @@ #include "opal/util/net.h" #include "opal/util/fd.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "opal/constants.h" #include "opal/mca/btl/btl.h" #include "opal/mca/btl/base/base.h" @@ -278,7 +280,7 @@ static int mca_btl_tcp_component_register(void) "The minimum port where the TCP BTL will try to bind (default 1024)", 1024, OPAL_INFO_LVL_2, &mca_btl_tcp_component.tcp_port_min); - asprintf( &message, + opal_asprintf( &message, "The number of ports where the TCP BTL will try to bind (default %d)." " This parameter together with the port min, define a range of ports" " where Open MPI will open sockets.", @@ -291,7 +293,7 @@ static int mca_btl_tcp_component_register(void) mca_btl_tcp_param_register_int( "port_min_v6", "The minimum port where the TCP BTL will try to bind (default 1024)", 1024, OPAL_INFO_LVL_2, & mca_btl_tcp_component.tcp6_port_min ); - asprintf( &message, + opal_asprintf( &message, "The number of ports where the TCP BTL will try to bind (default %d)." " This parameter together with the port min, define a range of ports" " where Open MPI will open sockets.", diff --git a/opal/mca/btl/tcp/btl_tcp_endpoint.c b/opal/mca/btl/tcp/btl_tcp_endpoint.c index 99fcd7610e..c9dc90b5a4 100644 --- a/opal/mca/btl/tcp/btl_tcp_endpoint.c +++ b/opal/mca/btl/tcp/btl_tcp_endpoint.c @@ -14,6 +14,7 @@ * Copyright (c) 2014 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -54,6 +55,7 @@ #include "opal/util/net.h" #include "opal/util/show_help.h" #include "opal/util/proc.h" +#include "opal/util/printf.h" #include "opal/mca/btl/base/btl_base_error.h" #include "btl_tcp.h" @@ -850,7 +852,7 @@ static int mca_btl_tcp_endpoint_complete_connect(mca_btl_base_endpoint_t* btl_en } if(so_error != 0) { char *msg; - asprintf(&msg, "connect() to %s:%d failed", + opal_asprintf(&msg, "connect() to %s:%d failed", opal_net_get_hostname((struct sockaddr*) &endpoint_addr), ntohs(((struct sockaddr_in*) &endpoint_addr)->sin_port)); opal_show_help("help-mpi-btl-tcp.txt", "client connect fail", diff --git a/opal/mca/btl/tcp/btl_tcp_proc.c b/opal/mca/btl/tcp/btl_tcp_proc.c index c7ee66bb25..0d7864afe1 100644 --- a/opal/mca/btl/tcp/btl_tcp_proc.c +++ b/opal/mca/btl/tcp/btl_tcp_proc.c @@ -17,6 +17,7 @@ * Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2015-2018 Cisco Systems, Inc. All rights reserved + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -42,6 +43,7 @@ #include "opal/util/net.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "btl_tcp.h" #include "btl_tcp_proc.h" @@ -914,9 +916,9 @@ void mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t* btl_proc, struct sockaddr* addr (void*) &(btl_endpoint->endpoint_addr->addr_inet), ip, sizeof(ip) - 1); if (NULL == addr_str) { - (void)asprintf(&tmp, "\n\t%s", ip); + opal_asprintf(&tmp, "\n\t%s", ip); } else { - (void)asprintf(&tmp, "%s\n\t%s", addr_str, ip); + opal_asprintf(&tmp, "%s\n\t%s", addr_str, ip); free(addr_str); } addr_str = tmp; diff --git a/opal/mca/btl/uct/btl_uct_component.c b/opal/mca/btl/uct/btl_uct_component.c index 58da56dd5a..0f97d18404 100644 --- a/opal/mca/btl/uct/btl_uct_component.c +++ b/opal/mca/btl/uct/btl_uct_component.c @@ -14,6 +14,7 @@ * reserved. * Copyright (c) 2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -28,6 +29,7 @@ #include "opal/mca/btl/base/base.h" #include "opal/mca/hwloc/base/base.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include @@ -349,7 +351,7 @@ static int mca_btl_uct_component_process_uct_md (uct_md_resource_desc_t *md_desc /* NTH: a registration cache shouldn't be necessary when using UCT but there are measurable * performance benefits to using rcache/grdma instead of assuming UCT will do the right * thing. */ - (void) asprintf (&tmp, "uct.%s", module->md_name); + (void) opal_asprintf (&tmp, "uct.%s", module->md_name); rcache_resources.cache_name = tmp; rcache_resources.reg_data = (void *) module; diff --git a/opal/mca/btl/ugni/btl_ugni_component.c b/opal/mca/btl/ugni/btl_ugni_component.c index 6d77548e08..04795ec401 100644 --- a/opal/mca/btl/ugni/btl_ugni_component.c +++ b/opal/mca/btl/ugni/btl_ugni_component.c @@ -4,6 +4,7 @@ * reserved. * Copyright (c) 2011 UT-Battelle, LLC. All rights reserved. * Copyright (c) 2017 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -17,6 +18,7 @@ #include "btl_ugni_smsg.h" #include "opal/util/sys_limits.h" +#include "opal/util/printf.h" #include #include @@ -378,7 +380,7 @@ static int btl_ugni_component_register(void) OBJ_RELEASE(new_enum); if (mca_btl_ugni_ugni_page_size) { - rc = asprintf (&mpool_hints_tmp, "page_size=%lu", mca_btl_ugni_ugni_page_size); + rc = opal_asprintf (&mpool_hints_tmp, "page_size=%lu", mca_btl_ugni_ugni_page_size); if (rc < 0) { return OPAL_ERR_OUT_OF_RESOURCE; } diff --git a/opal/mca/btl/usnic/btl_usnic_cagent.c b/opal/mca/btl/usnic/btl_usnic_cagent.c index bd9cac55e3..b265d37f35 100644 --- a/opal/mca/btl/usnic/btl_usnic_cagent.c +++ b/opal/mca/btl/usnic/btl_usnic_cagent.c @@ -2,6 +2,7 @@ * Copyright (c) 2014-2016 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -28,6 +29,7 @@ #include "opal/util/output.h" #include "opal/util/fd.h" #include "opal/util/string_copy.h" +#include "opal/util/printf.h" #include "btl_usnic.h" #include "btl_usnic_connectivity.h" @@ -319,7 +321,7 @@ static void agent_sendto(int fd, char *buffer, ssize_t numbytes, } char *msg; - asprintf(&msg, "Unexpected sendto() error: errno=%d (%s)", + opal_asprintf(&msg, "Unexpected sendto() error: errno=%d (%s)", errno, strerror(errno)); ABORT(msg); /* Will not return */ @@ -1176,7 +1178,7 @@ int opal_btl_usnic_connectivity_agent_init(void) /* Will not return */ } - asprintf(&ipc_filename, "%s/%s", + opal_asprintf(&ipc_filename, "%s/%s", opal_process_info.job_session_dir, CONNECTIVITY_SOCK_NAME); if (NULL == ipc_filename) { OPAL_ERROR_LOG(OPAL_ERR_IN_ERRNO); diff --git a/opal/mca/btl/usnic/btl_usnic_cclient.c b/opal/mca/btl/usnic/btl_usnic_cclient.c index 4027057d15..d1498d9224 100644 --- a/opal/mca/btl/usnic/btl_usnic_cclient.c +++ b/opal/mca/btl/usnic/btl_usnic_cclient.c @@ -2,6 +2,7 @@ * Copyright (c) 2014-2016 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,6 +30,7 @@ #include "opal/util/output.h" #include "opal/util/fd.h" #include "opal/util/string_copy.h" +#include "opal/util/printf.h" #include "btl_usnic.h" #include "btl_usnic_module.h" @@ -62,7 +64,7 @@ int opal_btl_usnic_connectivity_client_init(void) } char *ipc_filename = NULL; - asprintf(&ipc_filename, "%s/%s", + opal_asprintf(&ipc_filename, "%s/%s", opal_process_info.job_session_dir, CONNECTIVITY_SOCK_NAME); if (NULL == ipc_filename) { OPAL_ERROR_LOG(OPAL_ERR_IN_ERRNO); diff --git a/opal/mca/btl/usnic/btl_usnic_component.c b/opal/mca/btl/usnic/btl_usnic_component.c index 25a64a25d2..71ba1a09e8 100644 --- a/opal/mca/btl/usnic/btl_usnic_component.c +++ b/opal/mca/btl/usnic/btl_usnic_component.c @@ -18,6 +18,7 @@ * Copyright (c) 2014 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -56,6 +57,7 @@ #include "opal/util/argv.h" #include "opal/util/net.h" #include "opal/util/if.h" +#include "opal/util/printf.h" #include "opal/mca/base/mca_base_var.h" #include "opal/mca/memchecker/base/base.h" #include "opal/util/show_help.h" @@ -298,10 +300,10 @@ static int check_reg_mem_basics(void) limit.rlim_cur == RLIM_INFINITY) { return OPAL_SUCCESS; } else { - asprintf(&str_limit, "%ld", (long)limit.rlim_cur); + opal_asprintf(&str_limit, "%ld", (long)limit.rlim_cur); } } else { - asprintf(&str_limit, "Unknown"); + opal_asprintf(&str_limit, "Unknown"); } opal_show_help("help-mpi-btl-usnic.txt", "check_reg_mem_basics fail", diff --git a/opal/mca/btl/usnic/btl_usnic_map.c b/opal/mca/btl/usnic/btl_usnic_map.c index c9cbd8a83c..9be2ed2522 100644 --- a/opal/mca/btl/usnic/btl_usnic_map.c +++ b/opal/mca/btl/usnic/btl_usnic_map.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2013-2016 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -15,6 +16,7 @@ #include #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "btl_usnic_compat.h" #include "btl_usnic.h" @@ -242,7 +244,7 @@ void opal_btl_usnic_connectivity_map(void) /* Filename is of the form: -....txt */ - asprintf(&filename, "%s-%s.pid%d.job%d.mcwrank%d.txt", + opal_asprintf(&filename, "%s-%s.pid%d.job%d.mcwrank%d.txt", mca_btl_usnic_component.connectivity_map_prefix, opal_get_proc_hostname(opal_proc_local_get()), getpid(), diff --git a/opal/mca/btl/usnic/btl_usnic_module.c b/opal/mca/btl/usnic/btl_usnic_module.c index ba0442c43c..7f166b0cce 100644 --- a/opal/mca/btl/usnic/btl_usnic_module.c +++ b/opal/mca/btl/usnic/btl_usnic_module.c @@ -16,6 +16,7 @@ * Copyright (c) 2014-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -37,6 +38,7 @@ #include "opal/util/output.h" #include "opal/datatype/opal_convertor.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "opal/mca/memchecker/base/base.h" #if BTL_IN_OPAL @@ -2204,7 +2206,7 @@ static int init_mpool(opal_btl_usnic_module_t *module) module->super.btl_mpool = mca_mpool_base_module_lookup (mca_btl_usnic_component.usnic_mpool_hints); #else - asprintf(&mpool_resources.pool_name, "%s", + opal_asprintf(&mpool_resources.pool_name, "%s", module->linux_device_name); module->super.btl_mpool = mca_mpool_base_module_create(mca_btl_usnic_component.usnic_mpool_name, diff --git a/opal/mca/btl/usnic/btl_usnic_stats.c b/opal/mca/btl/usnic/btl_usnic_stats.c index 5e5bcf72b7..c345962002 100644 --- a/opal/mca/btl/usnic/btl_usnic_stats.c +++ b/opal/mca/btl/usnic/btl_usnic_stats.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2013-2017 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -13,6 +14,7 @@ #include #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal/mca/base/mca_base_var.h" #include "opal/mca/base/mca_base_pvar.h" @@ -410,7 +412,7 @@ static void setup_mpit_pvars_enum(void) c = (unsigned char*) &sin->sin_addr.s_addr; devices[i].value = i; - rc = asprintf(&str, "%s,%hhu.%hhu.%hhu.%hhu/%" PRIu32, + rc = opal_asprintf(&str, "%s,%hhu.%hhu.%hhu.%hhu/%" PRIu32, m->linux_device_name, c[0], c[1], c[2], c[3], usnic_netmask_to_cidrlen(sin->sin_addr.s_addr)); diff --git a/opal/mca/btl/vader/btl_vader_component.c b/opal/mca/btl/vader/btl_vader_component.c index 115bceb081..0cd6efba17 100644 --- a/opal/mca/btl/vader/btl_vader_component.c +++ b/opal/mca/btl/vader/btl_vader_component.c @@ -18,6 +18,7 @@ * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -28,6 +29,7 @@ #include "opal/util/output.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "opal/threads/mutex.h" #include "opal/mca/btl/base/btl_base_error.h" @@ -528,7 +530,7 @@ static mca_btl_base_module_t **mca_btl_vader_component_init (int *num_btls, if (MCA_BTL_VADER_XPMEM != mca_btl_vader_component.single_copy_mechanism) { char *sm_file; - rc = asprintf(&sm_file, "%s" OPAL_PATH_SEP "vader_segment.%s.%x.%d", mca_btl_vader_component.backing_directory, + rc = opal_asprintf(&sm_file, "%s" OPAL_PATH_SEP "vader_segment.%s.%x.%d", mca_btl_vader_component.backing_directory, opal_process_info.nodename, OPAL_PROC_MY_NAME.jobid, MCA_BTL_VADER_LOCAL_RANK); if (0 > rc) { free (btls); diff --git a/opal/mca/common/cuda/common_cuda.c b/opal/mca/common/cuda/common_cuda.c index b8689dbf9c..a90d160856 100644 --- a/opal/mca/common/cuda/common_cuda.c +++ b/opal/mca/common/cuda/common_cuda.c @@ -13,6 +13,7 @@ * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -37,6 +38,7 @@ #include "opal/util/show_help.h" #include "opal/util/proc.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "opal/mca/rcache/base/base.h" #include "opal/runtime/opal_params.h" @@ -388,7 +390,7 @@ int mca_common_cuda_stage_one_init(void) /* If there's a non-empty search path, prepend it to the library filename */ if (strlen(searchpaths[j]) > 0) { - asprintf(&filename, "%s/%s", searchpaths[j], cudalibs[i]); + opal_asprintf(&filename, "%s/%s", searchpaths[j], cudalibs[i]); } else { filename = strdup(cudalibs[i]); } diff --git a/opal/mca/common/sm/common_sm_mpool.c b/opal/mca/common/sm/common_sm_mpool.c index be59ec1d64..03366426ad 100644 --- a/opal/mca/common/sm/common_sm_mpool.c +++ b/opal/mca/common/sm/common_sm_mpool.c @@ -14,6 +14,7 @@ * All rights reserved. * Copyright (c) 2011-2014 NVIDIA Corporation. All rights reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -23,6 +24,7 @@ #include "opal_config.h" #include +#include "opal/util/printf.h" #include "common_sm_mpool.h" #include "opal/mca/common/sm/common_sm.h" #include "opal/mca/common/cuda/common_cuda.h" @@ -222,7 +224,7 @@ int mca_common_sm_mpool_ft_event(int state) { if(OPAL_CRS_CHECKPOINT == state) { /* Record the shared memory filename */ - asprintf( &file_name, "%s"OPAL_PATH_SEP"shared_mem_pool.%s", + opal_asprintf( &file_name, "%s"OPAL_PATH_SEP"shared_mem_pool.%s", opal_process_info.job_session_dir, opal_proc_local_get()->proc_hostname ); /* Disabled to get FT code compiled again diff --git a/opal/mca/common/verbs/common_verbs_basics.c b/opal/mca/common/verbs/common_verbs_basics.c index bd23f08ea3..74ac0aca1e 100644 --- a/opal/mca/common/verbs/common_verbs_basics.c +++ b/opal/mca/common/verbs/common_verbs_basics.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2012-2016 Cisco Systems, Inc. All rights reserved. * + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -42,6 +43,7 @@ const char *ibv_get_sysfs_path(void); #include "opal/runtime/opal_params.h" #include "opal/util/show_help.h" #include "opal/util/proc.h" +#include "opal/util/printf.h" /***********************************************************************/ @@ -53,7 +55,7 @@ bool opal_common_verbs_check_basics(void) struct stat s; /* Check to see if $sysfsdir/class/infiniband/ exists */ - asprintf(&file, "%s/class/infiniband", ibv_get_sysfs_path()); + opal_asprintf(&file, "%s/class/infiniband", ibv_get_sysfs_path()); if (NULL == file) { return false; } diff --git a/opal/mca/compress/base/compress_base_fns.c b/opal/mca/compress/base/compress_base_fns.c index 1187d8ee39..7e8c9264c4 100644 --- a/opal/mca/compress/base/compress_base_fns.c +++ b/opal/mca/compress/base/compress_base_fns.c @@ -4,6 +4,7 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -34,6 +35,7 @@ #include "opal/util/os_dirpath.h" #include "opal/util/output.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "opal/mca/compress/compress.h" #include "opal/mca/compress/base/base.h" @@ -54,12 +56,12 @@ int opal_compress_base_tar_create(char ** target) pid_t child_pid = 0; int status = 0; - asprintf(&tar_target, "%s.tar", *target); + opal_asprintf(&tar_target, "%s.tar", *target); child_pid = fork(); if( 0 == child_pid ) { /* Child */ char *cmd; - asprintf(&cmd, "tar -cf %s %s", tar_target, *target); + opal_asprintf(&cmd, "tar -cf %s %s", tar_target, *target); argv = opal_argv_split(cmd, ' '); status = execvp(argv[0], argv); @@ -101,7 +103,7 @@ int opal_compress_base_tar_extract(char ** target) child_pid = fork(); if( 0 == child_pid ) { /* Child */ char *cmd; - asprintf(&cmd, "tar -xf %s", *target); + opal_asprintf(&cmd, "tar -xf %s", *target); argv = opal_argv_split(cmd, ' '); status = execvp(argv[0], argv); diff --git a/opal/mca/compress/bzip/compress_bzip_module.c b/opal/mca/compress/bzip/compress_bzip_module.c index 96a2fb39ef..7cc4e825fc 100644 --- a/opal/mca/compress/bzip/compress_bzip_module.c +++ b/opal/mca/compress/bzip/compress_bzip_module.c @@ -6,6 +6,7 @@ * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -27,6 +28,7 @@ #include "opal/util/output.h" #include "opal/util/argv.h" #include "opal/util/opal_environ.h" +#include "opal/util/printf.h" #include "opal/constants.h" #include "opal/util/basename.h" @@ -90,15 +92,15 @@ int opal_compress_bzip_compress_nb(char * fname, char **cname, char **postfix, p if( is_dir ) { #if 0 opal_compress_base_tar_create(&base_fname); - asprintf(cname, "%s.bz2", base_fname); - asprintf(&cmd, "bzip2 %s", base_fname); + opal_asprintf(cname, "%s.bz2", base_fname); + opal_asprintf(&cmd, "bzip2 %s", base_fname); #else - asprintf(cname, "%s.tar.bz2", base_fname); - asprintf(&cmd, "tar -jcf %s %s", *cname, base_fname); + opal_asprintf(cname, "%s.tar.bz2", base_fname); + opal_asprintf(&cmd, "tar -jcf %s %s", *cname, base_fname); #endif } else { - asprintf(cname, "%s.bz2", base_fname); - asprintf(&cmd, "bzip2 %s", base_fname); + opal_asprintf(cname, "%s.bz2", base_fname); + opal_asprintf(&cmd, "bzip2 %s", base_fname); } opal_output_verbose(10, mca_compress_bzip_component.super.output_handle, @@ -120,7 +122,7 @@ int opal_compress_bzip_compress_nb(char * fname, char **cname, char **postfix, p } else { *postfix = strdup(".bz2"); } - asprintf(cname, "%s%s", fname, *postfix); + opal_asprintf(cname, "%s%s", fname, *postfix); } else { return OPAL_ERROR; @@ -181,7 +183,7 @@ int opal_compress_bzip_decompress_nb(char * cname, char **fname, pid_t *child_pi loc_pid = fork(); if( loc_pid == 0 ) { /* Child */ char * cmd; - asprintf(&cmd, "bunzip2 %s", cname); + opal_asprintf(&cmd, "bunzip2 %s", cname); opal_output_verbose(10, mca_compress_bzip_component.super.output_handle, "compress:bzip: decompress_nb() command [%s]", diff --git a/opal/mca/compress/gzip/compress_gzip_module.c b/opal/mca/compress/gzip/compress_gzip_module.c index a9003f80c9..bbaabc772a 100644 --- a/opal/mca/compress/gzip/compress_gzip_module.c +++ b/opal/mca/compress/gzip/compress_gzip_module.c @@ -6,6 +6,7 @@ * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -27,6 +28,7 @@ #include "opal/util/output.h" #include "opal/util/argv.h" #include "opal/util/opal_environ.h" +#include "opal/util/printf.h" #include "opal/constants.h" #include "opal/util/basename.h" @@ -90,15 +92,15 @@ int opal_compress_gzip_compress_nb(char * fname, char **cname, char **postfix, p if( is_dir ) { #if 0 opal_compress_base_tar_create(&base_fname); - asprintf(cname, "%s.gz", base_fname); - asprintf(&cmd, "gzip %s", base_fname); + opal_asprintf(cname, "%s.gz", base_fname); + opal_asprintf(&cmd, "gzip %s", base_fname); #else - asprintf(cname, "%s.tar.gz", base_fname); - asprintf(&cmd, "tar -zcf %s %s", *cname, base_fname); + opal_asprintf(cname, "%s.tar.gz", base_fname); + opal_asprintf(&cmd, "tar -zcf %s %s", *cname, base_fname); #endif } else { - asprintf(cname, "%s.gz", base_fname); - asprintf(&cmd, "gzip %s", base_fname); + opal_asprintf(cname, "%s.gz", base_fname); + opal_asprintf(&cmd, "gzip %s", base_fname); } opal_output_verbose(10, mca_compress_gzip_component.super.output_handle, @@ -120,7 +122,7 @@ int opal_compress_gzip_compress_nb(char * fname, char **cname, char **postfix, p } else { *postfix = strdup(".gz"); } - asprintf(cname, "%s%s", fname, *postfix); + opal_asprintf(cname, "%s%s", fname, *postfix); } else { @@ -184,7 +186,7 @@ int opal_compress_gzip_decompress_nb(char * cname, char **fname, pid_t *child_pi /* Fork(gunzip) */ loc_pid = fork(); if( loc_pid == 0 ) { /* Child */ - asprintf(&cmd, "gunzip %s", cname); + opal_asprintf(&cmd, "gunzip %s", cname); opal_output_verbose(10, mca_compress_gzip_component.super.output_handle, "compress:gzip: decompress_nb() command [%s]", diff --git a/opal/mca/crs/blcr/crs_blcr_module.c b/opal/mca/crs/blcr/crs_blcr_module.c index c84e79bfbe..c6ee170459 100644 --- a/opal/mca/crs/blcr/crs_blcr_module.c +++ b/opal/mca/crs/blcr/crs_blcr_module.c @@ -11,6 +11,7 @@ * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. * * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -33,6 +34,7 @@ #include "opal/util/show_help.h" #include "opal/util/output.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "opal/constants.h" #include "opal/mca/base/mca_base_var.h" @@ -369,7 +371,7 @@ int opal_crs_blcr_checkpoint(pid_t pid, if( opal_crs_blcr_dev_null ) { loc_fname = strdup("/dev/null"); } else { - asprintf(&loc_fname, "%s/%s", snapshot->super.snapshot_directory, snapshot->context_filename); + opal_asprintf(&loc_fname, "%s/%s", snapshot->super.snapshot_directory, snapshot->context_filename); } #if OPAL_ENABLE_CRDEBUG == 1 @@ -711,7 +713,7 @@ static int opal_crs_blcr_restart_cmd(char *fname, char **cmd) return OPAL_CRS_ERROR; } - asprintf(cmd, "%s %s", blcr_restart_cmd, fname); + opal_asprintf(cmd, "%s %s", blcr_restart_cmd, fname); return OPAL_SUCCESS; } @@ -721,7 +723,7 @@ static int blcr_get_checkpoint_filename(char **fname, pid_t pid) opal_output_verbose(10, mca_crs_blcr_component.super.output_handle, "crs:blcr: get_checkpoint_filename(--, %d)", pid); - asprintf(fname, "ompi_blcr_context.%d", pid); + opal_asprintf(fname, "ompi_blcr_context.%d", pid); return OPAL_SUCCESS; } @@ -779,7 +781,7 @@ static int blcr_cold_start(opal_crs_blcr_snapshot_t *snapshot) { exit_status = OPAL_ERROR; goto cleanup; } - asprintf(&snapshot->context_filename, "%s/%s", snapshot->super.snapshot_directory, tmp_argv[0]); + opal_asprintf(&snapshot->context_filename, "%s/%s", snapshot->super.snapshot_directory, tmp_argv[0]); /* * Reset the cold_start flag diff --git a/opal/mca/crs/dmtcp/crs_dmtcp_module.c b/opal/mca/crs/dmtcp/crs_dmtcp_module.c index e18626ff57..856599b3c2 100644 --- a/opal/mca/crs/dmtcp/crs_dmtcp_module.c +++ b/opal/mca/crs/dmtcp/crs_dmtcp_module.c @@ -4,6 +4,7 @@ * Copyright (c) 2010-2011 Alex Brick . * All rights reserved. * + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -26,6 +27,7 @@ #include "opal/util/output.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "opal/constants.h" #include "opal/mca/base/mca_base_var.h" @@ -158,7 +160,7 @@ int opal_crs_dmtcp_module_init(void) * sleep_between_ckpt callback. */ - asprintf(&temp_checkpoint_name, "checkpoint.dmtcp.%ld", syscall(SYS_getpid)); + opal_asprintf(&temp_checkpoint_name, "checkpoint.dmtcp.%ld", syscall(SYS_getpid)); mtcp_init(temp_checkpoint_name, 0, 1); mtcp_ok(); @@ -527,7 +529,7 @@ static int dmtcp_cold_start(opal_crs_dmtcp_snapshot_t *snapshot) { goto cleanup; } - asprintf(&(snapshot->context_filename), "%s/%s", snapshot->super.snapshot_directory, tmp_argv[0]); + opal_asprintf(&(snapshot->context_filename), "%s/%s", snapshot->super.snapshot_directory, tmp_argv[0]); opal_output_verbose(10, mca_crs_dmtcp_component.super.output_handle, "crs:dmtcp: cold_start(%s)", snapshot->context_filename); @@ -559,11 +561,11 @@ static int dmtcp_cold_start(opal_crs_dmtcp_snapshot_t *snapshot) { static int dmtcp_generate_full_ckpt_path(opal_crs_dmtcp_snapshot_t *snapshot) { int retval; - retval = asprintf(&(snapshot->context_filename), "ompi_dmtcp_context.%ld", syscall(SYS_getpid)); + retval = opal_asprintf(&(snapshot->context_filename), "ompi_dmtcp_context.%ld", syscall(SYS_getpid)); if(retval == -1) return -1; - return asprintf(&full_ckpt_path, "%s/%s", snapshot->super.snapshot_directory, snapshot->context_filename); + return opal_asprintf(&full_ckpt_path, "%s/%s", snapshot->super.snapshot_directory, snapshot->context_filename); } /** diff --git a/opal/mca/crs/self/crs_self_module.c b/opal/mca/crs/self/crs_self_module.c index 7c6d66f49f..e4f1730fa2 100644 --- a/opal/mca/crs/self/crs_self_module.c +++ b/opal/mca/crs/self/crs_self_module.c @@ -11,6 +11,7 @@ * reserved. * Copyright (c) 2007 Evergrid, Inc. All rights reserved. * + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -34,6 +35,7 @@ #include "opal/util/show_help.h" #include "opal/util/argv.h" #include "opal/util/opal_environ.h" +#include "opal/util/printf.h" #include "opal/constants.h" #include "opal/mca/base/mca_base_var.h" @@ -565,7 +567,7 @@ static int crs_self_find_function(char *prefix, char *suffix, "crs:self: crs_self_find_function(--, %s, %s)", prefix, suffix); - asprintf(&func_to_find, "%s_%s", prefix, suffix); + opal_asprintf(&func_to_find, "%s_%s", prefix, suffix); /* The RTLD_DEFAULT is a special handle that searches the default libraries * including the current application for the indicated symbol. This allows @@ -654,7 +656,7 @@ static int opal_crs_self_restart_cmd(opal_crs_self_snapshot_t *snapshot, char ** * add_args = strdup("-mca crs self -mca crs_self_do_restart 1"); */ - asprintf(cmd, "%s", snapshot->cmd_line); + opal_asprintf(cmd, "%s", snapshot->cmd_line); return OPAL_SUCCESS; } @@ -713,7 +715,7 @@ static int self_cold_start(opal_crs_self_snapshot_t *snapshot) { exit_status = OPAL_ERROR; goto cleanup; } - asprintf(&snapshot->cmd_line, "%s", tmp_argv[0]); + opal_asprintf(&snapshot->cmd_line, "%s", tmp_argv[0]); /* * Reset the cold_start flag diff --git a/opal/mca/dl/dlopen/dl_dlopen_module.c b/opal/mca/dl/dlopen/dl_dlopen_module.c index 192e7af440..57f392fe04 100644 --- a/opal/mca/dl/dlopen/dl_dlopen_module.c +++ b/opal/mca/dl/dlopen/dl_dlopen_module.c @@ -4,6 +4,7 @@ * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -23,6 +24,7 @@ #include "opal/constants.h" #include "opal/mca/dl/dl.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "dl_dlopen.h" @@ -74,7 +76,7 @@ static int dlopen_open(const char *fname, bool use_ext, bool private_namespace, ext = mca_dl_dlopen_component.filename_suffixes[++i]) { char *name; - asprintf(&name, "%s%s", fname, ext); + opal_asprintf(&name, "%s%s", fname, ext); if (NULL == name) { return OPAL_ERR_IN_ERRNO; } @@ -182,7 +184,7 @@ static int dlopen_foreachfile(const char *search_path, /* Make the absolute path name */ char *abs_name = NULL; - asprintf(&abs_name, "%s/%s", dirs[i], de->d_name); + opal_asprintf(&abs_name, "%s/%s", dirs[i], de->d_name); if (NULL == abs_name) { ret = OPAL_ERR_IN_ERRNO; goto error; diff --git a/opal/mca/event/external/event_external_component.c b/opal/mca/event/external/event_external_component.c index aa0ebe0f24..e039eb52ca 100644 --- a/opal/mca/event/external/event_external_component.c +++ b/opal/mca/event/external/event_external_component.c @@ -6,6 +6,7 @@ * Copyright (c) 2017 IBM Corporation. All rights reserved. * * Copyright (c) 2017 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -21,6 +22,7 @@ #include "event.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" /* * Public string showing the sysinfo ompi_linux component version number @@ -88,7 +90,7 @@ static int event_external_register (void) { #endif avail = opal_argv_join((char**)all_available_eventops, ','); - asprintf( &help_msg, + opal_asprintf( &help_msg, "Comma-delimited list of libevent subsystems " "to use (%s -- available on your platform)", avail ); diff --git a/opal/mca/event/libevent2022/libevent2022_component.c b/opal/mca/event/libevent2022/libevent2022_component.c index 6c8171dcf8..cfdda2b270 100644 --- a/opal/mca/event/libevent2022/libevent2022_component.c +++ b/opal/mca/event/libevent2022/libevent2022_component.c @@ -5,6 +5,7 @@ * Copyright (c) 2015 Intel, Inc. All rights reserved. * * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -20,6 +21,7 @@ #include "opal_config.h" #include "opal/constants.h" +#include "opal/util/printf.h" #include "opal/mca/event/event.h" #include "libevent2022.h" @@ -171,7 +173,7 @@ static int libevent2022_register (void) ompi_event_module_include = "poll"; #endif - asprintf( &help_msg, + opal_asprintf( &help_msg, "Comma-delimited list of libevent subsystems " "to use (%s -- available on your platform)", available_eventops ); diff --git a/opal/mca/hwloc/base/hwloc_base_dt.c b/opal/mca/hwloc/base/hwloc_base_dt.c index 0840ee13f1..0eb401f2a4 100644 --- a/opal/mca/hwloc/base/hwloc_base_dt.c +++ b/opal/mca/hwloc/base/hwloc_base_dt.c @@ -3,6 +3,7 @@ * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -12,6 +13,7 @@ #include "opal/constants.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal/dss/dss.h" #include "opal/mca/hwloc/base/base.h" @@ -243,13 +245,13 @@ static void print_hwloc_obj(char **output, char *prefix, /* print the object type */ hwloc_obj_type_snprintf(string, 1024, obj, 1); - asprintf(&pfx, "\n%s\t", (NULL == prefix) ? "" : prefix); - asprintf(&tmp, "%sType: %s Number of child objects: %u%sName=%s", + opal_asprintf(&pfx, "\n%s\t", (NULL == prefix) ? "" : prefix); + opal_asprintf(&tmp, "%sType: %s Number of child objects: %u%sName=%s", (NULL == prefix) ? "" : prefix, string, obj->arity, pfx, (NULL == obj->name) ? "NULL" : obj->name); if (0 < hwloc_obj_attr_snprintf(string, 1024, obj, pfx, 1)) { /* print the attributes */ - asprintf(&tmp2, "%s%s%s", tmp, pfx, string); + opal_asprintf(&tmp2, "%s%s%s", tmp, pfx, string); free(tmp); tmp = tmp2; } @@ -258,28 +260,28 @@ static void print_hwloc_obj(char **output, char *prefix, */ if (NULL != obj->cpuset) { hwloc_bitmap_snprintf(string, OPAL_HWLOC_MAX_STRING, obj->cpuset); - asprintf(&tmp2, "%s%sCpuset: %s", tmp, pfx, string); + opal_asprintf(&tmp2, "%s%sCpuset: %s", tmp, pfx, string); free(tmp); tmp = tmp2; } if (HWLOC_OBJ_MACHINE == obj->type) { /* root level object - add support values */ support = (struct hwloc_topology_support*)hwloc_topology_get_support(topo); - asprintf(&tmp2, "%s%sBind CPU proc: %s%sBind CPU thread: %s", tmp, pfx, + opal_asprintf(&tmp2, "%s%sBind CPU proc: %s%sBind CPU thread: %s", tmp, pfx, (support->cpubind->set_thisproc_cpubind) ? "TRUE" : "FALSE", pfx, (support->cpubind->set_thisthread_cpubind) ? "TRUE" : "FALSE"); free(tmp); tmp = tmp2; - asprintf(&tmp2, "%s%sBind MEM proc: %s%sBind MEM thread: %s", tmp, pfx, + opal_asprintf(&tmp2, "%s%sBind MEM proc: %s%sBind MEM thread: %s", tmp, pfx, (support->membind->set_thisproc_membind) ? "TRUE" : "FALSE", pfx, (support->membind->set_thisthread_membind) ? "TRUE" : "FALSE"); free(tmp); tmp = tmp2; } - asprintf(&tmp2, "%s%s\n", (NULL == *output) ? "" : *output, tmp); + opal_asprintf(&tmp2, "%s%s\n", (NULL == *output) ? "" : *output, tmp); free(tmp); free(pfx); - asprintf(&pfx, "%s\t", (NULL == prefix) ? "" : prefix); + opal_asprintf(&pfx, "%s\t", (NULL == prefix) ? "" : prefix); for (i=0; i < obj->arity; i++) { obj2 = obj->children[i]; /* print the object */ diff --git a/opal/mca/hwloc/base/hwloc_base_util.c b/opal/mca/hwloc/base/hwloc_base_util.c index f2daf2c82a..eb7eece810 100644 --- a/opal/mca/hwloc/base/hwloc_base_util.c +++ b/opal/mca/hwloc/base/hwloc_base_util.c @@ -18,6 +18,7 @@ * and Technology (RIST). All rights reserved. * Copyright (C) 2018 Mellanox Technologies, Ltd. * All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -51,6 +52,7 @@ #include "opal/util/output.h" #include "opal/util/os_dirpath.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "opal/threads/tsd.h" #include "opal/mca/pmix/pmix.h" @@ -2061,7 +2063,7 @@ char* opal_hwloc_base_get_topo_signature(hwloc_topology_t topo) endian = "unknown"; #endif - asprintf(&sig, "%dN:%dS:%dL3:%dL2:%dL1:%dC:%dH:%s:%s", + opal_asprintf(&sig, "%dN:%dS:%dL3:%dL2:%dL1:%dC:%dH:%s:%s", nnuma, nsocket, nl3, nl2, nl1, ncore, nhwt, arch, endian); return sig; } @@ -2137,14 +2139,14 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo, hwloc_bitmap_list_asprintf(&tmp, result); switch(obj->type) { case HWLOC_OBJ_NODE: - asprintf(&t2, "%sNM%s:", (NULL == locality) ? "" : locality, tmp); + opal_asprintf(&t2, "%sNM%s:", (NULL == locality) ? "" : locality, tmp); if (NULL != locality) { free(locality); } locality = t2; break; case HWLOC_OBJ_SOCKET: - asprintf(&t2, "%sSK%s:", (NULL == locality) ? "" : locality, tmp); + opal_asprintf(&t2, "%sSK%s:", (NULL == locality) ? "" : locality, tmp); if (NULL != locality) { free(locality); } @@ -2153,21 +2155,21 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo, #if HWLOC_API_VERSION < 0x20000 case HWLOC_OBJ_CACHE: if (3 == obj->attr->cache.depth) { - asprintf(&t2, "%sL3%s:", (NULL == locality) ? "" : locality, tmp); + opal_asprintf(&t2, "%sL3%s:", (NULL == locality) ? "" : locality, tmp); if (NULL != locality) { free(locality); } locality = t2; break; } else if (2 == obj->attr->cache.depth) { - asprintf(&t2, "%sL2%s:", (NULL == locality) ? "" : locality, tmp); + opal_asprintf(&t2, "%sL2%s:", (NULL == locality) ? "" : locality, tmp); if (NULL != locality) { free(locality); } locality = t2; break; } else { - asprintf(&t2, "%sL1%s:", (NULL == locality) ? "" : locality, tmp); + opal_asprintf(&t2, "%sL1%s:", (NULL == locality) ? "" : locality, tmp); if (NULL != locality) { free(locality); } @@ -2177,21 +2179,21 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo, break; #else case HWLOC_OBJ_L3CACHE: - asprintf(&t2, "%sL3%s:", (NULL == locality) ? "" : locality, tmp); + opal_asprintf(&t2, "%sL3%s:", (NULL == locality) ? "" : locality, tmp); if (NULL != locality) { free(locality); } locality = t2; break; case HWLOC_OBJ_L2CACHE: - asprintf(&t2, "%sL2%s:", (NULL == locality) ? "" : locality, tmp); + opal_asprintf(&t2, "%sL2%s:", (NULL == locality) ? "" : locality, tmp); if (NULL != locality) { free(locality); } locality = t2; break; case HWLOC_OBJ_L1CACHE: - asprintf(&t2, "%sL1%s:", (NULL == locality) ? "" : locality, tmp); + opal_asprintf(&t2, "%sL1%s:", (NULL == locality) ? "" : locality, tmp); if (NULL != locality) { free(locality); } @@ -2199,14 +2201,14 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo, break; #endif case HWLOC_OBJ_CORE: - asprintf(&t2, "%sCR%s:", (NULL == locality) ? "" : locality, tmp); + opal_asprintf(&t2, "%sCR%s:", (NULL == locality) ? "" : locality, tmp); if (NULL != locality) { free(locality); } locality = t2; break; case HWLOC_OBJ_PU: - asprintf(&t2, "%sHT%s:", (NULL == locality) ? "" : locality, tmp); + opal_asprintf(&t2, "%sHT%s:", (NULL == locality) ? "" : locality, tmp); if (NULL != locality) { free(locality); } diff --git a/opal/mca/installdirs/base/installdirs_base_expand.c b/opal/mca/installdirs/base/installdirs_base_expand.c index 139ec229a0..8c3d132479 100644 --- a/opal/mca/installdirs/base/installdirs_base_expand.c +++ b/opal/mca/installdirs/base/installdirs_base_expand.c @@ -4,6 +4,7 @@ * Copyright (c) 2007-2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007 Sun Microsystem, Inc. All rights reserved. * Copyright (c) 2010 Sandia National Laboratories. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -17,6 +18,7 @@ #include #include "opal/util/os_path.h" +#include "opal/util/printf.h" #include "opal/mca/installdirs/base/base.h" #include "opal/mca/installdirs/installdirs.h" @@ -32,7 +34,7 @@ tmp = retval; \ *start_pos = '\0'; \ end_pos = start_pos + strlen("${" #fieldname "}"); \ - asprintf(&retval, "%s%s%s", tmp, \ + opal_asprintf(&retval, "%s%s%s", tmp, \ opal_install_dirs.ompiname + destdir_offset, \ end_pos); \ free(tmp); \ @@ -41,7 +43,7 @@ tmp = retval; \ *start_pos = '\0'; \ end_pos = start_pos + strlen("@{" #fieldname "}"); \ - asprintf(&retval, "%s%s%s", tmp, \ + opal_asprintf(&retval, "%s%s%s", tmp, \ opal_install_dirs.ompiname + destdir_offset, \ end_pos); \ free(tmp); \ diff --git a/opal/mca/mpool/base/mpool_base_tree.c b/opal/mca/mpool/base/mpool_base_tree.c index 5f30620062..5d7adc25e7 100644 --- a/opal/mca/mpool/base/mpool_base_tree.c +++ b/opal/mca/mpool/base/mpool_base_tree.c @@ -17,6 +17,7 @@ * All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,6 +30,7 @@ #include "opal/mca/mca.h" #include "opal/util/show_help.h" #include "opal/util/proc.h" +#include "opal/util/printf.h" #include "opal/class/opal_rb_tree.h" #include "mpool_base_tree.h" @@ -221,11 +223,11 @@ static void action(void *key, void *value) successive items if we're supposed to catenate more notices. */ if (NULL == leak_msg) { - asprintf(&leak_msg, " %lu bytes at address 0x%lx", + opal_asprintf(&leak_msg, " %lu bytes at address 0x%lx", (unsigned long) item->num_bytes, (unsigned long) key); } else { - asprintf(&tmp, "%s\n %lu bytes at address 0x%lx", + opal_asprintf(&tmp, "%s\n %lu bytes at address 0x%lx", leak_msg, (unsigned long) item->num_bytes, (unsigned long) key); free(leak_msg); diff --git a/opal/mca/mpool/hugepage/mpool_hugepage_module.c b/opal/mca/mpool/hugepage/mpool_hugepage_module.c index e174614b61..4bbcc16d7a 100644 --- a/opal/mca/mpool/hugepage/mpool_hugepage_module.c +++ b/opal/mca/mpool/hugepage/mpool_hugepage_module.c @@ -19,6 +19,7 @@ * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -39,6 +40,7 @@ #include "opal/runtime/opal_params.h" #include "opal/include/opal_stdint.h" #include "opal/mca/allocator/base/base.h" +#include "opal/util/printf.h" #include #include @@ -133,7 +135,7 @@ void *mca_mpool_hugepage_seg_alloc (void *ctx, size_t *sizep) count = opal_atomic_add_fetch_32 (&huge_page->count, 1); - rc = asprintf (&path, "%s/hugepage.openmpi.%d.%d", huge_page->path, + rc = opal_asprintf (&path, "%s/hugepage.openmpi.%d.%d", huge_page->path, getpid (), count); if (0 > rc) { return NULL; diff --git a/opal/runtime/opal_cr.c b/opal/runtime/opal_cr.c index 27e32c5fdd..11f938edd9 100644 --- a/opal/runtime/opal_cr.c +++ b/opal/runtime/opal_cr.c @@ -16,6 +16,7 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -55,6 +56,7 @@ #include "opal/util/keyval_parse.h" #include "opal/util/opal_environ.h" #include "opal/util/argv.h" +#include "opal/util/printf.h" #include "opal/memoryhooks/memory.h" #include "opal/mca/base/base.h" @@ -934,7 +936,7 @@ int opal_cr_refresh_environ(int prev_pid) { * 1) We have already executed this function, and * 2) The file has been deleted on the previous round. */ - asprintf(&file_name, "%s/%s-%d", opal_tmp_directory(), OPAL_CR_BASE_ENV_NAME, prev_pid); + opal_asprintf(&file_name, "%s/%s-%d", opal_tmp_directory(), OPAL_CR_BASE_ENV_NAME, prev_pid); if (NULL == file_name) { return OPAL_ERR_OUT_OF_RESOURCE; } diff --git a/opal/runtime/opal_info_support.c b/opal/runtime/opal_info_support.c index 2912d0b646..0d876f322f 100644 --- a/opal/runtime/opal_info_support.c +++ b/opal/runtime/opal_info_support.c @@ -16,6 +16,7 @@ * Copyright (c) 2011-2012 University of Houston. All rights reserved. * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -42,6 +43,7 @@ #include "opal/util/error.h" #include "opal/util/argv.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "opal/runtime/opal.h" #include "opal/dss/dss.h" #include "opal/mca/base/mca_base_pvar.h" @@ -351,7 +353,7 @@ void opal_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); opal_info_out(pretty, path, value); free(pretty); free(path); @@ -601,7 +603,7 @@ void opal_info_do_type(opal_cmd_line_t *opal_info_cmd_line) (void) mca_base_var_group_get(var->mbv_group_index, &group); for (j = 0 ; strings[j] ; ++j) { if (0 == j && opal_info_pretty) { - asprintf (&message, "MCA %s", group->group_framework); + opal_asprintf (&message, "MCA %s", group->group_framework); opal_info_out(message, message, strings[j]); free(message); } else { @@ -661,7 +663,7 @@ static void opal_info_show_mca_group_params(const mca_base_var_group_t *group, m const mca_base_var_group_t *curr_group = NULL; char *component_msg = NULL; - asprintf(&component_msg, " %s", group_component); + opal_asprintf(&component_msg, " %s", group_component); for (i = 0 ; i < count ; ++i) { ret = mca_base_var_get(variables[i], &var); @@ -672,7 +674,7 @@ static void opal_info_show_mca_group_params(const mca_base_var_group_t *group, m } if (opal_info_pretty && curr_group != group) { - asprintf(&message, "MCA%s %s%s", requested ? "" : " (-)", + opal_asprintf(&message, "MCA%s %s%s", requested ? "" : " (-)", group->group_framework, component_msg ? component_msg : ""); opal_info_out(message, message, "---------------------------------------------------"); @@ -687,7 +689,7 @@ static void opal_info_show_mca_group_params(const mca_base_var_group_t *group, m for (j = 0 ; strings[j] ; ++j) { if (0 == j && opal_info_pretty) { - asprintf (&message, "MCA%s %s%s", requested ? "" : " (-)", + opal_asprintf (&message, "MCA%s %s%s", requested ? "" : " (-)", group->group_framework, component_msg ? component_msg : ""); opal_info_out(message, message, strings[j]); @@ -700,7 +702,7 @@ static void opal_info_show_mca_group_params(const mca_base_var_group_t *group, m if (!opal_info_pretty) { /* generate an entry indicating whether this variable is disabled or not. if the * format in mca_base_var/pvar.c changes this needs to be changed as well */ - asprintf (&message, "mca:%s:%s:param:%s:disabled:%s", group->group_framework, + opal_asprintf (&message, "mca:%s:%s:param:%s:disabled:%s", group->group_framework, group_component, var->mbv_full_name, requested ? "false" : "true"); opal_info_out("", "", message); free (message); @@ -718,7 +720,7 @@ static void opal_info_show_mca_group_params(const mca_base_var_group_t *group, m } if (opal_info_pretty && curr_group != group) { - asprintf(&message, "MCA%s %s%s", requested ? "" : " (-)", + opal_asprintf(&message, "MCA%s %s%s", requested ? "" : " (-)", group->group_framework, component_msg ? component_msg : ""); opal_info_out(message, message, "---------------------------------------------------"); @@ -733,7 +735,7 @@ static void opal_info_show_mca_group_params(const mca_base_var_group_t *group, m for (j = 0 ; strings[j] ; ++j) { if (0 == j && opal_info_pretty) { - asprintf (&message, "MCA%s %s%s", requested ? "" : " (-)", + opal_asprintf (&message, "MCA%s %s%s", requested ? "" : " (-)", group->group_framework, component_msg ? component_msg : ""); opal_info_out(message, message, strings[j]); @@ -746,7 +748,7 @@ static void opal_info_show_mca_group_params(const mca_base_var_group_t *group, m if (!opal_info_pretty) { /* generate an entry indicating whether this variable is disabled or not. if the * format in mca_base_var/pvar.c changes this needs to be changed as well */ - asprintf (&message, "mca:%s:%s:pvar:%s:disabled:%s", group->group_framework, + opal_asprintf (&message, "mca:%s:%s:pvar:%s:disabled:%s", group->group_framework, group_component, pvar->name, requested ? "false" : "true"); opal_info_out("", "", message); free (message); @@ -897,7 +899,7 @@ void opal_info_out(const char *pretty_message, const char *plain_message, const if (opal_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(""); @@ -911,9 +913,9 @@ void opal_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; @@ -923,7 +925,7 @@ void opal_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 @@ -1005,7 +1007,7 @@ void opal_info_out_int(const char *pretty_message, { char *valstr; - asprintf(&valstr, "%d", (int)value); + opal_asprintf(&valstr, "%d", (int)value); opal_info_out(pretty_message, plain_message, valstr); free(valstr); } @@ -1093,16 +1095,16 @@ static void opal_info_show_failed_component(const mca_base_component_repository_ char *message, *content; if (opal_info_pretty) { - asprintf(&message, "MCA %s", ri->ri_type); - asprintf(&content, "%s (failed to load) %s", ri->ri_name, error_msg); + opal_asprintf(&message, "MCA %s", ri->ri_type); + opal_asprintf(&content, "%s (failed to load) %s", ri->ri_name, error_msg); opal_info_out(message, NULL, content); free(message); free(content); } else { - asprintf(&message, "mca:%s:%s:failed", ri->ri_type, ri->ri_name); - asprintf(&content, "%s", error_msg); + opal_asprintf(&message, "mca:%s:%s:failed", ri->ri_type, ri->ri_name); + opal_asprintf(&content, "%s", error_msg); opal_info_out(NULL, message, content); @@ -1155,12 +1157,12 @@ void opal_info_show_mca_version(const mca_base_component_t* component, component->mca_component_release_version, "", ""); if (opal_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; @@ -1168,11 +1170,11 @@ void opal_info_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; @@ -1180,17 +1182,17 @@ void opal_info_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 { tmp = NULL; @@ -1203,19 +1205,19 @@ void opal_info_show_mca_version(const mca_base_component_t* component, } } 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); opal_info_out(NULL, message, tmp); free(tmp); } if (want_type) { - asprintf(&tmp, "api:%s", api_version); + opal_asprintf(&tmp, "api:%s", api_version); opal_info_out(NULL, message, tmp); free(tmp); } if (want_component) { - asprintf(&tmp, "component:%s", component_version); + opal_asprintf(&tmp, "component:%s", component_version); opal_info_out(NULL, message, tmp); free(tmp); } @@ -1248,7 +1250,7 @@ char *opal_info_make_version_str(const char *scope, snprintf(temp, BUFSIZ - 1, "%d.%d.%d", major, minor, release); str = strdup(temp); if (NULL != greek) { - asprintf(&tmp, "%s%s", str, greek); + opal_asprintf(&tmp, "%s%s", str, greek); free(str); str = tmp; } @@ -1275,7 +1277,7 @@ void opal_info_show_opal_version(const char *scope) { char *tmp, *tmp2; - asprintf(&tmp, "%s:version:full", opal_info_type_opal); + opal_asprintf(&tmp, "%s:version:full", opal_info_type_opal); tmp2 = opal_info_make_version_str(scope, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION, OPAL_RELEASE_VERSION, @@ -1284,10 +1286,10 @@ void opal_info_show_opal_version(const char *scope) opal_info_out("OPAL", tmp, tmp2); free(tmp); free(tmp2); - asprintf(&tmp, "%s:version:repo", opal_info_type_opal); + opal_asprintf(&tmp, "%s:version:repo", opal_info_type_opal); opal_info_out("OPAL repo revision", tmp, OPAL_REPO_REV); free(tmp); - asprintf(&tmp, "%s:version:release_date", opal_info_type_opal); + opal_asprintf(&tmp, "%s:version:release_date", opal_info_type_opal); opal_info_out("OPAL release date", tmp, OPAL_RELEASE_DATE); free(tmp); } diff --git a/opal/runtime/opal_params.c b/opal/runtime/opal_params.c index a7e2e0f3ef..5015effad8 100644 --- a/opal/runtime/opal_params.c +++ b/opal/runtime/opal_params.c @@ -22,6 +22,7 @@ * Copyright (c) 2015 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -47,6 +48,7 @@ #include "opal/util/opal_environ.h" #include "opal/util/show_help.h" #include "opal/util/timings.h" +#include "opal/util/printf.h" char *opal_signal_string = NULL; char *opal_stacktrace_output_filename = NULL; @@ -109,10 +111,10 @@ int opal_register_params(void) }; for (j = 0 ; signals[j] != -1 ; ++j) { if (j == 0) { - asprintf(&string, "%d", signals[j]); + opal_asprintf(&string, "%d", signals[j]); } else { char *tmp; - asprintf(&tmp, "%s,%d", string, signals[j]); + opal_asprintf(&tmp, "%s,%d", string, signals[j]); free(string); string = tmp; } diff --git a/opal/tools/opal-checkpoint/opal-checkpoint.c b/opal/tools/opal-checkpoint/opal-checkpoint.c index a472f4685b..dddb8ef796 100644 --- a/opal/tools/opal-checkpoint/opal-checkpoint.c +++ b/opal/tools/opal-checkpoint/opal-checkpoint.c @@ -13,6 +13,7 @@ * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -58,6 +59,7 @@ #include "opal/util/opal_environ.h" #include "opal/util/error.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "opal/mca/base/base.h" #include "opal/runtime/opal.h" @@ -374,11 +376,11 @@ notify_process_for_checkpoint(pid_t pid, char **fname, int term, opal_crs_state_ int value; /* A string copy of the pid */ - asprintf(&tmp_pid, "%d", pid); + opal_asprintf(&tmp_pid, "%d", pid); /* Flip the read/write files for bi-directionality */ - asprintf(&prog_named_pipe_w, "%s/%s.%s", opal_cr_pipe_dir, OPAL_CR_NAMED_PROG_R, tmp_pid); - asprintf(&prog_named_pipe_r, "%s/%s.%s", opal_cr_pipe_dir, OPAL_CR_NAMED_PROG_W, tmp_pid); + opal_asprintf(&prog_named_pipe_w, "%s/%s.%s", opal_cr_pipe_dir, OPAL_CR_NAMED_PROG_R, tmp_pid); + opal_asprintf(&prog_named_pipe_r, "%s/%s.%s", opal_cr_pipe_dir, OPAL_CR_NAMED_PROG_W, tmp_pid); /* * Signal the application telling it that we wish to checkpoint diff --git a/opal/tools/opal-restart/opal-restart.c b/opal/tools/opal-restart/opal-restart.c index 7f9dfc042a..5ca93be571 100644 --- a/opal/tools/opal-restart/opal-restart.c +++ b/opal/tools/opal-restart/opal-restart.c @@ -16,6 +16,7 @@ * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2014 Hochschule Esslingen. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -62,6 +63,7 @@ #include "opal/util/opal_environ.h" #include "opal/util/error.h" #include "opal/util/basename.h" +#include "opal/util/printf.h" #include "opal/mca/base/base.h" #include "opal/runtime/opal.h" @@ -210,7 +212,7 @@ main(int argc, char *argv[]) char * full_metadata_path = NULL; FILE * metadata = NULL; - asprintf(&full_metadata_path, "%s/%s/%s", + opal_asprintf(&full_metadata_path, "%s/%s/%s", opal_restart_globals.snapshot_loc, opal_restart_globals.snapshot_ref, opal_restart_globals.snapshot_metadata); @@ -293,10 +295,10 @@ main(int argc, char *argv[]) snapshot = OBJ_NEW(opal_crs_base_snapshot_t); snapshot->cold_start = true; - asprintf(&(snapshot->snapshot_directory), "%s/%s", + opal_asprintf(&(snapshot->snapshot_directory), "%s/%s", opal_restart_globals.snapshot_loc, opal_restart_globals.snapshot_ref); - asprintf(&(snapshot->metadata_filename), "%s/%s", + opal_asprintf(&(snapshot->metadata_filename), "%s/%s", snapshot->snapshot_directory, opal_restart_globals.snapshot_metadata); @@ -421,7 +423,7 @@ static int initialize(int argc, char *argv[]) free(tmp_env_var); tmp_env_var = NULL; - asprintf(&zip_dir, "%s/%s%s", + opal_asprintf(&zip_dir, "%s/%s%s", opal_restart_globals.snapshot_loc, opal_restart_globals.snapshot_ref, opal_restart_globals.snapshot_compress_postfix); @@ -599,7 +601,7 @@ static int check_file(void) /* * Check for the existance of the snapshot handle in the snapshot directory */ - asprintf(&path_to_check, "%s/%s", + opal_asprintf(&path_to_check, "%s/%s", opal_restart_globals.snapshot_loc, opal_restart_globals.snapshot_ref); @@ -642,8 +644,8 @@ static int post_env_vars(int prev_pid, opal_crs_base_snapshot_t *snapshot) * This is needed so we can pass the previous environment to the restarted * application process. */ - asprintf(&proc_file, "%s/%s-%d", opal_tmp_directory(), OPAL_CR_BASE_ENV_NAME, prev_pid); - asprintf(&command, "env | grep OMPI_ > %s", proc_file); + opal_asprintf(&proc_file, "%s/%s-%d", opal_tmp_directory(), OPAL_CR_BASE_ENV_NAME, prev_pid); + opal_asprintf(&command, "env | grep OMPI_ > %s", proc_file); opal_output_verbose(5, opal_restart_globals.output, "post_env_vars: Execute: <%s>", command); @@ -671,7 +673,7 @@ static int post_env_vars(int prev_pid, opal_crs_base_snapshot_t *snapshot) free(command); command = NULL; } - asprintf(&command, "mkdir -p %s", loc_mkdir[i]); + opal_asprintf(&command, "mkdir -p %s", loc_mkdir[i]); opal_output_verbose(5, opal_restart_globals.output, "post_env_vars: Execute: <%s>", command); @@ -696,7 +698,7 @@ static int post_env_vars(int prev_pid, opal_crs_base_snapshot_t *snapshot) free(command); command = NULL; } - asprintf(&command, "touch %s", loc_touch[i]); + opal_asprintf(&command, "touch %s", loc_touch[i]); opal_output_verbose(5, opal_restart_globals.output, "post_env_vars: Execute: <%s>", command); diff --git a/opal/tools/wrappers/opal_wrapper.c b/opal/tools/wrappers/opal_wrapper.c index 4c4374cd61..f880d26149 100644 --- a/opal/tools/wrappers/opal_wrapper.c +++ b/opal/tools/wrappers/opal_wrapper.c @@ -15,6 +15,7 @@ * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -53,6 +54,7 @@ #include "opal/util/few.h" #include "opal/util/basename.h" #include "opal/util/os_path.h" +#include "opal/util/printf.h" #define OPAL_INCLUDE_FLAG "-I" #define OPAL_LIBDIR_FLAG "-L" @@ -320,7 +322,7 @@ data_callback(const char *key, const char *value) if (0 != strcmp(options_data[parse_options_idx].path_includedir, "/usr/include") || 0 == strncmp(options_data[parse_options_idx].language, "Fortran", strlen("Fortran"))) { char *line; - asprintf(&line, OPAL_INCLUDE_FLAG"%s", + opal_asprintf(&line, OPAL_INCLUDE_FLAG"%s", options_data[parse_options_idx].path_includedir); opal_argv_append_nosize(&options_data[parse_options_idx].preproc_flags, line); free(line); @@ -331,7 +333,7 @@ data_callback(const char *key, const char *value) opal_install_dirs_expand(value); if (0 != strcmp(options_data[parse_options_idx].path_libdir, "/usr/lib")) { char *line; - asprintf(&line, OPAL_LIBDIR_FLAG"%s", + opal_asprintf(&line, OPAL_LIBDIR_FLAG"%s", options_data[parse_options_idx].path_libdir); opal_argv_append_nosize(&options_data[parse_options_idx].link_flags, line); free(line); @@ -344,7 +346,7 @@ data_callback(const char *key, const char *value) if (0 != strcmp(options_data[parse_options_idx].path_opalincludedir, "/usr/include") || 0 == strncmp(options_data[parse_options_idx].language, "Fortran", strlen("Fortran"))) { char *line; - asprintf(&line, OPAL_INCLUDE_FLAG"%s", + opal_asprintf(&line, OPAL_INCLUDE_FLAG"%s", options_data[parse_options_idx].path_opalincludedir); opal_argv_append_nosize(&options_data[parse_options_idx].preproc_flags, line); free(line); @@ -355,7 +357,7 @@ data_callback(const char *key, const char *value) opal_install_dirs_expand(value); if (0 != strcmp(options_data[parse_options_idx].path_opallibdir, "/usr/lib")) { char *line; - asprintf(&line, OPAL_LIBDIR_FLAG"%s", + opal_asprintf(&line, OPAL_LIBDIR_FLAG"%s", options_data[parse_options_idx].path_opallibdir); opal_argv_append_nosize(&options_data[parse_options_idx].link_flags, line); free(line); @@ -371,7 +373,7 @@ data_init(const char *appname) char *datafile; /* now load the data */ - asprintf(&datafile, "%s%s%s-wrapper-data.txt", + opal_asprintf(&datafile, "%s%s%s-wrapper-data.txt", opal_install_dirs.opaldatadir, OPAL_PATH_SEP, appname); if (NULL == datafile) return OPAL_ERR_TEMP_OUT_OF_RESOURCE; @@ -425,10 +427,10 @@ load_env_data(const char *project, const char *flag, char **data) if (NULL == project || NULL == flag) return; - asprintf(&envname, "%s_MPI%s", project, flag); + opal_asprintf(&envname, "%s_MPI%s", project, flag); if (NULL == (envvalue = getenv(envname))) { free(envname); - asprintf(&envname, "%s_%s", project, flag); + opal_asprintf(&envname, "%s_%s", project, flag); if (NULL == (envvalue = getenv(envname))) { free(envname); return; @@ -449,10 +451,10 @@ load_env_data_argv(const char *project, const char *flag, char ***data) if (NULL == project || NULL == flag) return; - asprintf(&envname, "%s_MPI%s", project, flag); + opal_asprintf(&envname, "%s_MPI%s", project, flag); if (NULL == (envvalue = getenv(envname))) { free(envname); - asprintf(&envname, "%s_%s", project, flag); + opal_asprintf(&envname, "%s_%s", project, flag); if (NULL == (envvalue = getenv(envname))) { free(envname); return; diff --git a/opal/util/error.c b/opal/util/error.c index d8021b63ea..25a49faa56 100644 --- a/opal/util/error.c +++ b/opal/util/error.c @@ -16,6 +16,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2017 FUJITSU LIMITED. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -35,6 +36,7 @@ #include "opal/util/string_copy.h" #include "opal/constants.h" #include "opal/util/proc.h" +#include "opal/util/printf.h" #include "opal/runtime/opal_params.h" #define MAX_CONVERTERS 5 @@ -82,7 +84,7 @@ opal_strerror_unknown(int errnum, char **str) if (0 != converters[i].init) { if (errnum < converters[i].err_base && errnum > converters[i].err_max) { - asprintf(str, "Unknown error: %d (%s error %d)", + opal_asprintf(str, "Unknown error: %d (%s error %d)", errnum, converters[i].project, errnum - converters[i].err_base); return OPAL_SUCCESS; @@ -90,7 +92,7 @@ opal_strerror_unknown(int errnum, char **str) } } - asprintf(str, "Unknown error: %d", errnum); + opal_asprintf(str, "Unknown error: %d", errnum); return OPAL_SUCCESS; } diff --git a/opal/util/opal_environ.c b/opal/util/opal_environ.c index f1df671b53..5f01756bcf 100644 --- a/opal/util/opal_environ.c +++ b/opal/util/opal_environ.c @@ -13,6 +13,7 @@ * Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -102,9 +103,9 @@ int opal_setenv(const char *name, const char *value, bool overwrite, if (NULL == value) { value = ""; - asprintf(&newvalue, "%s=", name); + opal_asprintf(&newvalue, "%s=", name); } else { - asprintf(&newvalue, "%s=%s", name, value); + opal_asprintf(&newvalue, "%s=%s", name, value); } if (NULL == newvalue) { return OPAL_ERR_OUT_OF_RESOURCE; @@ -162,7 +163,7 @@ int opal_setenv(const char *name, const char *value, bool overwrite, /* Make something easy to compare to */ - asprintf(&compare, "%s=", name); + opal_asprintf(&compare, "%s=", name); if (NULL == compare) { free(newvalue); return OPAL_ERR_OUT_OF_RESOURCE; @@ -218,7 +219,7 @@ int opal_unsetenv(const char *name, char ***env) /* Make something easy to compare to */ - asprintf(&compare, "%s=", name); + opal_asprintf(&compare, "%s=", name); if (NULL == compare) { return OPAL_ERR_OUT_OF_RESOURCE; } diff --git a/opal/util/output.c b/opal/util/output.c index eabd8cd393..5ef24bfdf8 100644 --- a/opal/util/output.c +++ b/opal/util/output.c @@ -17,6 +17,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2017-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -44,6 +45,7 @@ #include "opal/util/opal_environ.h" #include "opal/util/output.h" #include "opal/util/string_copy.h" +#include "opal/util/printf.h" #include "opal/threads/mutex.h" #include "opal/constants.h" #include "opal/mca/pmix/pmix.h" @@ -189,7 +191,7 @@ bool opal_output_init(void) } } gethostname(hostname, sizeof(hostname)); - asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid()); + opal_asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid()); for (i = 0; i < OPAL_OUTPUT_MAX_STREAMS; ++i) { info[i].ldi_used = false; @@ -210,7 +212,7 @@ bool opal_output_init(void) /* Set some defaults */ - asprintf(&output_prefix, "output-pid%d-", getpid()); + opal_asprintf(&output_prefix, "output-pid%d-", getpid()); output_dir = strdup(opal_tmp_directory()); /* Open the default verbose stream */ @@ -279,7 +281,7 @@ void opal_output_reopen_all(void) free(verbose.lds_prefix); verbose.lds_prefix = NULL; } - asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid()); + opal_asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid()); #if 0 int i; opal_output_stream_t lds; @@ -864,7 +866,7 @@ static int make_string(char **no_newline_string, output_desc_t *ldi, /* Make the formatted string */ - vasprintf(no_newline_string, format, arglist); + opal_vasprintf(no_newline_string, format, arglist); total_len = len = strlen(*no_newline_string); if ('\n' != (*no_newline_string)[len - 1]) { want_newline = true; diff --git a/opal/util/printf.c b/opal/util/printf.c index 9dcb44a50a..fad3d94915 100644 --- a/opal/util/printf.c +++ b/opal/util/printf.c @@ -10,6 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007-2014 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -32,6 +33,7 @@ #include +#ifndef HAVE_VASPRINTF /* * Make a good guess about how long a printf-style varargs formatted * string will be once all the % escapes are filled in. We don't @@ -192,7 +194,7 @@ static int guess_strlen(const char *fmt, va_list ap) return len; #endif } - +#endif /* #ifndef HAVE_VASPRINTF */ int opal_asprintf(char **ptr, const char *fmt, ...) { @@ -210,15 +212,18 @@ int opal_asprintf(char **ptr, const char *fmt, ...) int opal_vasprintf(char **ptr, const char *fmt, va_list ap) { - int length; - va_list ap2; - #ifdef HAVE_VASPRINTF + int length; + length = vasprintf(ptr, fmt, ap); if (length < 0) { *ptr = NULL; } + + return length; #else + int length; + va_list ap2; /* va_list might have pointer to internal state and using it twice is a bad idea. So make a copy for the second @@ -254,9 +259,9 @@ int opal_vasprintf(char **ptr, const char *fmt, va_list ap) errno = ENOMEM; return -1; } -#endif return length; +#endif } diff --git a/opal/util/show_help.c b/opal/util/show_help.c index b05fd19231..1b736580da 100644 --- a/opal/util/show_help.c +++ b/opal/util/show_help.c @@ -12,6 +12,7 @@ * Copyright (c) 2008-2018 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -160,11 +161,11 @@ static int open_file(const char *base, const char *topic) filename = opal_os_path( false, search_dirs[i], base, NULL ); opal_show_help_yyin = fopen(filename, "r"); if (NULL == opal_show_help_yyin) { - asprintf(&err_msg, "%s: %s", filename, strerror(errno)); + opal_asprintf(&err_msg, "%s: %s", filename, strerror(errno)); base_len = strlen(base); if (4 > base_len || 0 != strcmp(base + base_len - 4, ".txt")) { free(filename); - asprintf(&filename, "%s%s%s.txt", search_dirs[i], OPAL_PATH_SEP, base); + opal_asprintf(&filename, "%s%s%s.txt", search_dirs[i], OPAL_PATH_SEP, base); opal_show_help_yyin = fopen(filename, "r"); } } @@ -308,7 +309,7 @@ char *opal_show_help_vstring(const char *filename, const char *topic, if (OPAL_SUCCESS == rc) { /* Apply the formatting to make the final output string */ - vasprintf(&output, single_string, arglist); + opal_vasprintf(&output, single_string, arglist); free(single_string); } diff --git a/opal/util/uri.c b/opal/util/uri.c index f679b9a3c9..1e1e154b97 100644 --- a/opal/util/uri.c +++ b/opal/util/uri.c @@ -3,6 +3,7 @@ * All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -22,6 +23,7 @@ #include "opal/util/output.h" #include "opal/util/path.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" #include "opal/util/uri.h" @@ -59,7 +61,7 @@ char *opal_filename_to_uri(const char *filename, * the scheme can either be missing or given as "localhost" */ if (NULL == hostname) { - asprintf(&uri, "file://%s", filename); + opal_asprintf(&uri, "file://%s", filename); return uri; } @@ -96,7 +98,7 @@ char *opal_filename_to_uri(const char *filename, * ensure it was absolute, so the required separator should * already be present */ - asprintf(&uri, "file://%s%s", hostname, fn); + opal_asprintf(&uri, "file://%s%s", hostname, fn); free(fn); return uri; } diff --git a/oshmem/info/info.c b/oshmem/info/info.c index 59fafdfec9..909db31f93 100644 --- a/oshmem/info/info.c +++ b/oshmem/info/info.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2015 Mellanox Technologies, Inc. * All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -19,6 +20,7 @@ #include "opal/util/opal_environ.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #include "oshmem/version.h" #include "oshmem/constants.h" @@ -262,7 +264,7 @@ static int oshmem_info_get_heap_size(char *value, size_t *interp) char *tmp = p; if(!p) { - asprintf(&tmp, "%lld", size * factor); + opal_asprintf(&tmp, "%lld", size * factor); } if (tmp) { diff --git a/oshmem/mca/scoll/fca/scoll_fca_component.c b/oshmem/mca/scoll/fca/scoll_fca_component.c index 4efbe49d01..42b4dfff5d 100644 --- a/oshmem/mca/scoll/fca/scoll_fca_component.c +++ b/oshmem/mca/scoll/fca/scoll_fca_component.c @@ -6,6 +6,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -35,6 +36,7 @@ #include "scoll_fca.h" #include "opal/runtime/opal_progress.h" +#include "opal/util/printf.h" #include "oshmem/proc/proc.h" #include "oshmem/mca/memheap/memheap.h" /* @@ -200,10 +202,10 @@ static char *mca_scoll_fca_check_file(char *file) static char *mca_scoll_fca_get_spec_file(void) { char *file; - asprintf(&file, "%s/etc/fca_mpi_spec.ini", COLL_FCA_HOME); + opal_asprintf(&file, "%s/etc/fca_mpi_spec.ini", COLL_FCA_HOME); if (NULL == mca_scoll_fca_check_file(file)) { free(file); - asprintf(&file, "%s/../fca/etc/fca_mpi_spec.ini", opal_install_dirs.prefix); + opal_asprintf(&file, "%s/../fca/etc/fca_mpi_spec.ini", opal_install_dirs.prefix); if (NULL == mca_scoll_fca_check_file(file)) { free(file); return NULL; diff --git a/oshmem/mca/spml/ikrit/spml_ikrit_component.c b/oshmem/mca/spml/ikrit/spml_ikrit_component.c index 846d749490..527fb71854 100644 --- a/oshmem/mca/spml/ikrit/spml_ikrit_component.c +++ b/oshmem/mca/spml/ikrit/spml_ikrit_component.c @@ -4,6 +4,7 @@ * All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -16,6 +17,7 @@ #include #include +#include "opal/util/printf.h" #include "oshmem_config.h" #include "orte/util/show_help.h" #include "shmem.h" @@ -70,7 +72,7 @@ static inline int check_mxm_tls(char *var) } if (NULL != strstr(str, "shm")) { - if (0 < asprintf(&str, + if (0 < opal_asprintf(&str, "%s=%s", var, getenv(var) )) { diff --git a/oshmem/runtime/oshmem_info_support.c b/oshmem/runtime/oshmem_info_support.c index 5c2ddddc3e..f3f8677eb3 100644 --- a/oshmem/runtime/oshmem_info_support.c +++ b/oshmem/runtime/oshmem_info_support.c @@ -3,6 +3,7 @@ * All rights reserved. * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2016-2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -22,6 +23,8 @@ #include "ompi/runtime/ompi_info_support.h" #include "oshmem/runtime/oshmem_info_support.h" #include "opal/util/show_help.h" +#include "opal/util/printf.h" +#include "opal/util/printf.h" #include "ompi/include/ompi/constants.h" const char *oshmem_info_type_oshmem = "oshmem"; @@ -82,7 +85,7 @@ void oshmem_info_show_oshmem_version(const char *scope) { char *tmp, *tmp2; - if (0 < asprintf(&tmp, "%s:version:full", oshmem_info_type_oshmem)) { + if (0 < opal_asprintf(&tmp, "%s:version:full", oshmem_info_type_oshmem)) { tmp2 = opal_info_make_version_str(scope, OSHMEM_MAJOR_VERSION, OSHMEM_MINOR_VERSION, OSHMEM_RELEASE_VERSION, @@ -92,11 +95,11 @@ void oshmem_info_show_oshmem_version(const char *scope) free(tmp); free(tmp2); } - if(0 < asprintf(&tmp, "%s:version:repo", oshmem_info_type_oshmem)) { + if(0 < opal_asprintf(&tmp, "%s:version:repo", oshmem_info_type_oshmem)) { opal_info_out("Open SHMEM repo revision", tmp, OSHMEM_REPO_REV); free(tmp); } - if (0 < asprintf(&tmp, "%s:version:release_date", oshmem_info_type_oshmem)) { + if (0 < opal_asprintf(&tmp, "%s:version:release_date", oshmem_info_type_oshmem)) { opal_info_out("Open SHMEM release date", tmp, OSHMEM_RELEASE_DATE); free(tmp); } diff --git a/oshmem/tools/oshmem_info/param.c b/oshmem/tools/oshmem_info/param.c index 502c4f52ed..1ea2e953f6 100644 --- a/oshmem/tools/oshmem_info/param.c +++ b/oshmem/tools/oshmem_info/param.c @@ -6,6 +6,7 @@ * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016-2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -129,7 +130,7 @@ void oshmem_info_do_config(bool want_all) /* setup strings that require allocation */ if (OMPI_BUILD_FORTRAN_BINDINGS >= OMPI_FORTRAN_MPIFH_BINDINGS) { - (void)asprintf(&fortran, "yes (%s)", + (void)opal_asprintf(&fortran, "yes (%s)", (OPAL_HAVE_WEAK_SYMBOLS ? "all" : (OMPI_FORTRAN_CAPS ? "caps" : (OMPI_FORTRAN_PLAIN ? "lower case" : @@ -139,17 +140,17 @@ void oshmem_info_do_config(bool want_all) } #if OMPI_RTE_ORTE - (void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, ORTE progress: yes, Event lib: yes)", + (void)opal_asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, ORTE progress: yes, Event lib: yes)", "posix", OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no"); #else - (void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, Event lib: yes)", + (void)opal_asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, Event lib: yes)", "posix", OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no"); #endif - (void)asprintf(&ft_support, "%s (checkpoint thread: %s)", + (void)opal_asprintf(&ft_support, "%s (checkpoint thread: %s)", OPAL_ENABLE_FT ? "yes" : "no", OPAL_ENABLE_FT_THREAD ? "yes" : "no"); - (void)asprintf(&crdebug_support, "%s", + (void)opal_asprintf(&crdebug_support, "%s", OPAL_ENABLE_CRDEBUG ? "yes" : "no"); /* output values */ diff --git a/oshmem/util/oshmem_util.c b/oshmem/util/oshmem_util.c index ac64d42a0a..89c2e5ac16 100644 --- a/oshmem/util/oshmem_util.c +++ b/oshmem/util/oshmem_util.c @@ -2,6 +2,7 @@ * Copyright (c) 2014 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -13,6 +14,8 @@ #include #include +#include "opal/util/printf.h" + #include "oshmem/constants.h" #include "oshmem/util/oshmem_util.h" @@ -28,10 +31,10 @@ void oshmem_output_verbose(int level, int output_id, const char* prefix, va_start(args, format); - ret = vasprintf(&str, format, args); + ret = opal_vasprintf(&str, format, args); assert(-1 != ret); - ret = asprintf(&buff, "%s %s", prefix, str); + ret = opal_asprintf(&buff, "%s %s", prefix, str); assert(-1 != ret); opal_output(output_id, buff, file, line, function); @@ -55,10 +58,10 @@ void oshmem_output(int output_id, const char* prefix, const char* file, va_start(args, format); - ret = vasprintf(&str, format, args); + ret = opal_vasprintf(&str, format, args); assert(-1 != ret); - ret = asprintf(&buff, "%s %s", prefix, str); + ret = opal_asprintf(&buff, "%s %s", prefix, str); assert(-1 != ret); opal_output(output_id, buff, file, line, function); diff --git a/test/dss/dss_buffer.c b/test/dss/dss_buffer.c index 5dbbb64fb8..55877c748e 100644 --- a/test/dss/dss_buffer.c +++ b/test/dss/dss_buffer.c @@ -11,6 +11,7 @@ * All rights reserved. * Copyright (c) 2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -32,6 +33,7 @@ #include "opal/runtime/opal.h" #include "opal/dss/dss.h" +#include "opal/util/printf.h" #define NUM_ITERS 100 #define NUM_ELEMS 1024 @@ -432,7 +434,7 @@ static bool test6(void) char* dst[NUM_ELEMS]; for(i=0; ibytes), "%d", i); + opal_asprintf((char**)&(src[i]->bytes), "%d", i); src[i]->size = strlen((char*)(src[i]->bytes)) + 1; } @@ -628,11 +630,11 @@ static bool test9(void) for(i=0; ibytes), "%d", i+100); + opal_asprintf((char**)&(srco[i]->bytes), "%d", i+100); srco[i]->size = strlen((char*)(srco[i]->bytes)) + 1; /* strings +200 */ - asprintf(&srcs[i], "%d", i+200); + opal_asprintf(&srcs[i], "%d", i+200); /* bool */ srcb[i] = ((i % 2) == 0) ? true : false; diff --git a/test/util/opal_basename.c b/test/util/opal_basename.c index bd68e191d0..e76a656448 100644 --- a/test/util/opal_basename.c +++ b/test/util/opal_basename.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -24,6 +25,7 @@ #include "support.h" #include "opal/util/basename.h" +#include "opal/util/printf.h" static void test(const char* in, const char* out); @@ -56,7 +58,7 @@ void test(const char* in, const char* out) if (0 == strcmp(ret, out)) { test_success(); } else { - asprintf(&msg, "Mismatch: input \"%s\", expected \"%s\", got \"%s\"\n", + opal_asprintf(&msg, "Mismatch: input \"%s\", expected \"%s\", got \"%s\"\n", in, out, ret); test_failure(msg); free(msg); diff --git a/test/util/opal_bit_ops.c b/test/util/opal_bit_ops.c index fc3c5df8aa..b915b2b242 100644 --- a/test/util/opal_bit_ops.c +++ b/test/util/opal_bit_ops.c @@ -10,6 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -25,6 +26,7 @@ #include "support.h" #include "opal/util/bit_ops.h" #include "opal/util/output.h" +#include "opal/util/printf.h" /* #define DEBUG @@ -99,7 +101,7 @@ static int test_hibit(int value, int start) return 1; } else { char * msg; - asprintf(&msg, "Mismatch for hibit (w/ start:%d): value:%d, expected:%d got:%d\n", + opal_asprintf(&msg, "Mismatch for hibit (w/ start:%d): value:%d, expected:%d got:%d\n", start, value, bit, out); test_failure(msg); free(msg); @@ -133,7 +135,7 @@ static int test_cube_dim(int value) return 1; } else { char * msg; - asprintf(&msg, "Mismatch for cube_dim: value:%d, expected:%d got:%d\n", + opal_asprintf(&msg, "Mismatch for cube_dim: value:%d, expected:%d got:%d\n", value, dim, out); test_failure(msg); free(msg); @@ -168,7 +170,7 @@ static int test_next_poweroftwo(int value) return 1; } else { char * msg; - asprintf(&msg, "Mismatch for power-of-two: value:%d, expected:%d got:%d\n", + opal_asprintf(&msg, "Mismatch for power-of-two: value:%d, expected:%d got:%d\n", value, power2, out); test_failure(msg); free(msg); @@ -204,7 +206,7 @@ static int test_next_poweroftwo_inclusive(int value) return 1; } else { char * msg; - asprintf(&msg, "Mismatch for power-of-two-inclusive: value:%d, expected:%d got:%d\n", + opal_asprintf(&msg, "Mismatch for power-of-two-inclusive: value:%d, expected:%d got:%d\n", value, power2, out); test_failure(msg); free(msg); diff --git a/test/util/opal_path_nfs.c b/test/util/opal_path_nfs.c index fe5768c00e..5e31e82990 100644 --- a/test/util/opal_path_nfs.c +++ b/test/util/opal_path_nfs.c @@ -18,6 +18,7 @@ * reserved. * Copyright (c) 2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -46,6 +47,7 @@ #include "support.h" #include "opal/util/path.h" #include "opal/util/output.h" +#include "opal/util/printf.h" #define DEBUG @@ -127,7 +129,7 @@ void test(char* file, bool expect) test_success(); } else { char * msg; - asprintf(&msg, "Mismatch: input \"%s\", expected:%d got:%d\n", + opal_asprintf(&msg, "Mismatch: input \"%s\", expected:%d got:%d\n", file, expect, !expect); test_failure(msg); free(msg);