Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ompi/info/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ opal_pointer_array_t ompi_info_f_to_c_table = {{0}};
*/
int ompi_info_init(void)
{
char val[MPI_MAX_INFO_VAL];
char val[OPAL_MAXHOSTNAMELEN];
char *cptr;

/* initialize table */
Expand Down Expand Up @@ -134,7 +134,7 @@ int ompi_info_init(void)
}

/* local host name */
gethostname(val, MPI_MAX_INFO_VAL);
gethostname(val, sizeof(val));
ompi_info_set(&ompi_mpi_info_env.info, "host", val);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is limited by MPI_MAX_INFO_KEY.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I will look into changing this occurrence.


/* architecture name */
Expand Down
4 changes: 2 additions & 2 deletions ompi/mca/pml/v/pml_v_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

int pml_v_output_open(char *output, int verbosity) {
opal_output_stream_t lds;
char hostname[32] = "NA";
char hostname[OPAL_MAXHOSTNAMELEN] = "NA";

OBJ_CONSTRUCT(&lds, opal_output_stream_t);
if(!output) {
Expand All @@ -40,7 +40,7 @@ int pml_v_output_open(char *output, int verbosity) {
lds.lds_file_suffix = output;
}
lds.lds_is_debugging = true;
gethostname(hostname, 32);
gethostname(hostname, sizeof(hostname));
asprintf(&lds.lds_prefix, "[%s:%05d] pml_v: ", hostname, getpid());
lds.lds_verbose_level = verbosity;
mca_pml_v.output = opal_output_open(&lds);
Expand Down
2 changes: 1 addition & 1 deletion ompi/mpi/c/get_processor_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int MPI_Get_processor_name(char *name, int *resultlen)
Guard against gethostname() returning a *really long* hostname
and not null-terminating the string. The Fortran API version
will pad to the right if necessary. */
gethostname(name, MPI_MAX_PROCESSOR_NAME - 1);
gethostname(name, (MPI_MAX_PROCESSOR_NAME - 1));
name[MPI_MAX_PROCESSOR_NAME - 1] = '\0';
*resultlen = (int) strlen(name);

Expand Down
2 changes: 1 addition & 1 deletion ompi/runtime/ompi_mpi_abort.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int
ompi_mpi_abort(struct ompi_communicator_t* comm,
int errcode)
{
char *msg, *host, hostname[MAXHOSTNAMELEN];
char *msg, *host, hostname[OPAL_MAXHOSTNAMELEN];
pid_t pid = 0;

/* Protection for recursive invocation */
Expand Down
2 changes: 1 addition & 1 deletion ompi/runtime/ompi_mpi_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ int ompi_mpi_finalize(void)
/* Note that if we're not initialized or already finalized, we
cannot raise an MPI exception. The best that we can do is
write something to stderr. */
char hostname[MAXHOSTNAMELEN];
char hostname[OPAL_MAXHOSTNAMELEN];
pid_t pid = getpid();
gethostname(hostname, sizeof(hostname));

Expand Down
12 changes: 6 additions & 6 deletions ompi/tools/mpisync/sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main(int argc, char **argv)
MPI_Comm comm = MPI_COMM_WORLD;
int rank, commsize;
double offs = 0, rtt = 0;
char hname[1024];
char hname[OPAL_MAXHOSTNAMELEN];

MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &commsize);
Expand All @@ -98,7 +98,7 @@ int main(int argc, char **argv)
exit(1);
}

if( gethostname(hname, 1024) ){
if( gethostname(hname, sizeof(hname)) ){
perror("Cannot get hostname. Abort");
MPI_Abort(MPI_COMM_WORLD, 1);
}
Expand Down Expand Up @@ -129,13 +129,13 @@ int main(int argc, char **argv)
fprintf(stderr, "Fail to allocate memory. Abort\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
char *hnames = malloc(1024*commsize);
char *hnames = malloc(OPAL_MAXHOSTNAMELEN * commsize);
if( hnames == NULL ){
fprintf(stderr, "Fail to allocate memory. Abort\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}

MPI_Gather(hname,1024,MPI_CHAR,hnames,1024,MPI_CHAR, 0, MPI_COMM_WORLD);
MPI_Gather(hname,sizeof(hname),MPI_CHAR,hnames,sizeof(hname),MPI_CHAR, 0, MPI_COMM_WORLD);
MPI_Gather(send,2,MPI_DOUBLE,measure,2, MPI_DOUBLE, 0, MPI_COMM_WORLD);
char tmpname[128];
FILE *fp = fopen(filename,"w");
Expand All @@ -144,15 +144,15 @@ int main(int argc, char **argv)
MPI_Abort(MPI_COMM_WORLD, 1);
}
double (*m)[2] = (void*)measure;
char (*h)[1024] = (void*)hnames;
char (*h)[OPAL_MAXHOSTNAMELEN] = (void*)hnames;
int i;
fprintf(fp, "# Used algorithm: %s\n", (alg ? "binary tree" : "linear"));
for(i=0; i<commsize;i++){
fprintf(fp, "%s %lf %lf\n", h[i], m[i][0], m[i][1]);
}
fclose(fp);
} else {
MPI_Gather(hname,1024, MPI_CHAR, NULL, 1024, MPI_CHAR, 0, MPI_COMM_WORLD);
MPI_Gather(hname, sizeof(hname), MPI_CHAR, NULL, sizeof(hname), MPI_CHAR, 0, MPI_COMM_WORLD);
MPI_Gather(send,2, MPI_DOUBLE, NULL, 2, MPI_DOUBLE, 0, MPI_COMM_WORLD);
}

Expand Down
13 changes: 8 additions & 5 deletions opal/include/opal_config_bottom.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ typedef OPAL_PTRDIFF_TYPE ptrdiff_t;
#define OPAL_PATH_SEP "/"
#define OPAL_ENV_SEP ':'

#if defined(MAXHOSTNAMELEN)
#define OPAL_MAXHOSTNAMELEN (MAXHOSTNAMELEN + 1)
#elif defined(HOST_NAME_MAX)
#define OPAL_MAXHOSTNAMELEN (HOST_NAME_MAX + 1)
#else
/* SUSv2 guarantees that "Host names are limited to 255 bytes". */
#define OPAL_MAXHOSTNAMELEN (255 + 1)
#endif

/*
* Do we want memory debugging?
Expand Down Expand Up @@ -489,14 +497,9 @@ static inline uint16_t ntohs(uint16_t netvar) { return netvar; }
#ifdef HAVE_HOSTLIB_H
/* gethostname() */
#include <hostLib.h>

#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif
#endif

#endif

/* If we're in C++, then just undefine restrict and then define it to
nothing. "restrict" is not part of the C++ language, and we don't
have a corresponding AC_CXX_RESTRICT to figure out what the C++
Expand Down
2 changes: 1 addition & 1 deletion opal/mca/base/mca_base_component_find.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ static int component_find_check (mca_base_framework_t *framework, char **request
}

if (!found) {
char h[MAXHOSTNAMELEN];
char h[OPAL_MAXHOSTNAMELEN];
gethostname(h, sizeof(h));
opal_show_help("help-mca-base.txt",
"find-available:not-valid", true,
Expand Down
4 changes: 2 additions & 2 deletions opal/mca/base/mca_base_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int mca_base_open(void)
{
char *value;
opal_output_stream_t lds;
char hostname[64];
char hostname[OPAL_MAXHOSTNAMELEN];
int var_id;

if (mca_base_opened++) {
Expand Down Expand Up @@ -137,7 +137,7 @@ int mca_base_open(void)
} else {
set_defaults(&lds);
}
gethostname(hostname, 64);
gethostname(hostname, sizeof(hostname));
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");
Expand Down
8 changes: 3 additions & 5 deletions opal/mca/event/libevent2022/libevent/evdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
* Version: 0.1b
*/

#include "opal_config.h"

#include <sys/types.h>
#include "event2/event-config.h"

Expand Down Expand Up @@ -121,10 +123,6 @@
#define EVDNS_LOG_WARN 1
#define EVDNS_LOG_MSG 2

#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 255
#endif

#include <stdio.h>

#undef MIN
Expand Down Expand Up @@ -3108,7 +3106,7 @@ evdns_search_ndots_set(const int ndots) {

static void
search_set_from_hostname(struct evdns_base *base) {
char hostname[HOST_NAME_MAX + 1], *domainname;
char hostname[OPAL_MAXHOSTNAMELEN], *domainname;

ASSERT_LOCKED(base);
search_postfix_clear(base);
Expand Down
2 changes: 1 addition & 1 deletion opal/mca/hwloc/base/hwloc_base_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ int opal_hwloc_base_report_bind_failure(const char *file,

if (!already_reported &&
OPAL_HWLOC_BASE_MBFA_SILENT != opal_hwloc_base_mbfa) {
char hostname[64];
char hostname[OPAL_MAXHOSTNAMELEN];
gethostname(hostname, sizeof(hostname));

opal_show_help("help-opal-hwloc-base.txt", "mbind failure", true,
Expand Down
4 changes: 2 additions & 2 deletions opal/mca/pmix/pmix114/pmix/examples/dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ int main(int argc, char **argv)
uint32_t nprocs;
char nsp2[PMIX_MAX_NSLEN+1];
pmix_app_t *app;
char hostname[1024], dir[1024];
char hostname[PMIX_MAXHOSTNAMELEN], dir[1024];
pmix_proc_t *peers;
size_t npeers, ntmp=0;
char *nodelist;

gethostname(hostname, 1024);
gethostname(hostname, sizeof(hostname));
getcwd(dir, 1024);

/* init us */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ typedef PMIX_PTRDIFF_TYPE ptrdiff_t;
#define PMIX_PATH_MAX 256
#endif

#if defined(MAXHOSTNAMELEN)
#define PMIX_MAXHOSTNAMELEN (MAXHOSTNAMELEN + 1)
#elif defined(HOST_NAME_MAX)
#define PMIX_MAXHOSTNAMELEN (HOST_NAME_MAX + 1)
#else
/* SUSv2 guarantees that "Host names are limited to 255 bytes". */
#define PMIX_MAXHOSTNAMELEN (255 + 1)
#endif

/*
* Set the compile-time path-separator on this system and variable separator
*/
Expand Down Expand Up @@ -387,12 +396,7 @@ typedef PMIX_PTRDIFF_TYPE ptrdiff_t;
#ifdef HAVE_HOSTLIB_H
/* gethostname() */
#include <hostLib.h>

#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif
#endif

#endif

/* If we're in C++, then just undefine restrict and then define it to
Expand Down
4 changes: 2 additions & 2 deletions opal/mca/pmix/pmix114/pmix/src/util/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ PMIX_CLASS_INSTANCE(pmix_output_stream_t, pmix_object_t, construct, NULL);
bool pmix_output_init(void)
{
int i;
char hostname[32];
char hostname[PMIX_MAXHOSTNAMELEN];
char *str;

if (initialized) {
Expand Down Expand Up @@ -250,7 +250,7 @@ bool pmix_output_switch(int output_id, bool enable)
void pmix_output_reopen_all(void)
{
char *str;
char hostname[32];
char hostname[PMIX_MAXHOSTNAMELEN];

str = getenv("PMIX_OUTPUT_STDERR_FD");
if (NULL != str) {
Expand Down
4 changes: 2 additions & 2 deletions opal/mca/pmix/pmix114/pmix/test/simple/simpdyn.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ int main(int argc, char **argv)
uint32_t nprocs;
char nsp2[PMIX_MAX_NSLEN+1];
pmix_app_t *app;
char hostname[1024];
char hostname[PMIX_MAXHOSTNAMELEN];
pmix_proc_t *peers;
size_t npeers, ntmp=0;
char *nodelist;

gethostname(hostname, 1024);
gethostname(hostname, sizeof(hostname));

/* init us */
if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc))) {
Expand Down
4 changes: 2 additions & 2 deletions opal/mca/pmix/pmix114/pmix/test/simple/simptest.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ static void set_namespace(int nprocs, char *ranks, char *nspace,
pmix_op_cbfunc_t cbfunc, myxfer_t *x)
{
char *regex, *ppn;
char hostname[1024];
char hostname[PMIX_MAXHOSTNAMELEN];

gethostname(hostname, 1024);
gethostname(hostname, sizeof(hostname));
x->ninfo = 6;

PMIX_INFO_CREATE(x->info, x->ninfo);
Expand Down
4 changes: 2 additions & 2 deletions opal/mca/pstat/test/pstat_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static int query(pid_t pid,
opal_node_stats_t *nstats)
{
double dtime;
char hostname[128];
char hostname[OPAL_MAXHOSTNAMELEN];

if (NULL != stats) {
/* record the time of this sample */
Expand All @@ -83,7 +83,7 @@ static int query(pid_t pid,
}

if (NULL != stats) {
gethostname(hostname, 128);
gethostname(hostname, sizeof(hostname));
strncpy(stats->node, hostname, OPAL_PSTAT_MAX_STRING_LEN);

stats->pid = pid;
Expand Down
Loading