1
1

Merge pull request #1552 from kmroz/wip-hostname-len-cleanup-1

ompi/opal/orte/oshmem/test: max hostname length cleanup
Этот коммит содержится в:
Jeff Squyres 2016-05-02 09:44:18 -04:00
родитель 45f9a47d77 941f2c1e0b
Коммит 265e5b9795
45 изменённых файлов: 166 добавлений и 167 удалений

Просмотреть файл

@ -95,7 +95,7 @@ opal_pointer_array_t ompi_info_f_to_c_table = {{0}};
*/ */
int ompi_info_init(void) int ompi_info_init(void)
{ {
char val[MPI_MAX_INFO_VAL]; char val[OPAL_MAXHOSTNAMELEN];
char *cptr; char *cptr;
/* initialize table */ /* initialize table */
@ -134,7 +134,7 @@ int ompi_info_init(void)
} }
/* local host name */ /* local host name */
gethostname(val, MPI_MAX_INFO_VAL); gethostname(val, sizeof(val));
ompi_info_set(&ompi_mpi_info_env.info, "host", val); ompi_info_set(&ompi_mpi_info_env.info, "host", val);
/* architecture name */ /* architecture name */

Просмотреть файл

@ -21,7 +21,7 @@
int pml_v_output_open(char *output, int verbosity) { int pml_v_output_open(char *output, int verbosity) {
opal_output_stream_t lds; opal_output_stream_t lds;
char hostname[32] = "NA"; char hostname[OPAL_MAXHOSTNAMELEN] = "NA";
OBJ_CONSTRUCT(&lds, opal_output_stream_t); OBJ_CONSTRUCT(&lds, opal_output_stream_t);
if(!output) { if(!output) {
@ -40,7 +40,7 @@ int pml_v_output_open(char *output, int verbosity) {
lds.lds_file_suffix = output; lds.lds_file_suffix = output;
} }
lds.lds_is_debugging = true; lds.lds_is_debugging = true;
gethostname(hostname, 32); gethostname(hostname, sizeof(hostname));
asprintf(&lds.lds_prefix, "[%s:%05d] pml_v: ", hostname, getpid()); asprintf(&lds.lds_prefix, "[%s:%05d] pml_v: ", hostname, getpid());
lds.lds_verbose_level = verbosity; lds.lds_verbose_level = verbosity;
mca_pml_v.output = opal_output_open(&lds); mca_pml_v.output = opal_output_open(&lds);

Просмотреть файл

@ -66,7 +66,7 @@ int MPI_Get_processor_name(char *name, int *resultlen)
Guard against gethostname() returning a *really long* hostname Guard against gethostname() returning a *really long* hostname
and not null-terminating the string. The Fortran API version and not null-terminating the string. The Fortran API version
will pad to the right if necessary. */ 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'; name[MPI_MAX_PROCESSOR_NAME - 1] = '\0';
*resultlen = (int) strlen(name); *resultlen = (int) strlen(name);

Просмотреть файл

@ -119,7 +119,7 @@ int
ompi_mpi_abort(struct ompi_communicator_t* comm, ompi_mpi_abort(struct ompi_communicator_t* comm,
int errcode) int errcode)
{ {
char *msg, *host, hostname[MAXHOSTNAMELEN]; char *msg, *host, hostname[OPAL_MAXHOSTNAMELEN];
pid_t pid = 0; pid_t pid = 0;
/* Protection for recursive invocation */ /* Protection for recursive invocation */

Просмотреть файл

@ -120,7 +120,7 @@ int ompi_mpi_finalize(void)
/* Note that if we're not initialized or already finalized, we /* Note that if we're not initialized or already finalized, we
cannot raise an MPI exception. The best that we can do is cannot raise an MPI exception. The best that we can do is
write something to stderr. */ write something to stderr. */
char hostname[MAXHOSTNAMELEN]; char hostname[OPAL_MAXHOSTNAMELEN];
pid_t pid = getpid(); pid_t pid = getpid();
gethostname(hostname, sizeof(hostname)); gethostname(hostname, sizeof(hostname));

Просмотреть файл

@ -74,7 +74,7 @@ int main(int argc, char **argv)
MPI_Comm comm = MPI_COMM_WORLD; MPI_Comm comm = MPI_COMM_WORLD;
int rank, commsize; int rank, commsize;
double offs = 0, rtt = 0; double offs = 0, rtt = 0;
char hname[1024]; char hname[OPAL_MAXHOSTNAMELEN];
MPI_Comm_rank(comm, &rank); MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &commsize); MPI_Comm_size(comm, &commsize);
@ -98,7 +98,7 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
if( gethostname(hname, 1024) ){ if( gethostname(hname, sizeof(hname)) ){
perror("Cannot get hostname. Abort"); perror("Cannot get hostname. Abort");
MPI_Abort(MPI_COMM_WORLD, 1); MPI_Abort(MPI_COMM_WORLD, 1);
} }
@ -129,13 +129,13 @@ int main(int argc, char **argv)
fprintf(stderr, "Fail to allocate memory. Abort\n"); fprintf(stderr, "Fail to allocate memory. Abort\n");
MPI_Abort(MPI_COMM_WORLD, 1); MPI_Abort(MPI_COMM_WORLD, 1);
} }
char *hnames = malloc(1024*commsize); char *hnames = malloc(OPAL_MAXHOSTNAMELEN * commsize);
if( hnames == NULL ){ if( hnames == NULL ){
fprintf(stderr, "Fail to allocate memory. Abort\n"); fprintf(stderr, "Fail to allocate memory. Abort\n");
MPI_Abort(MPI_COMM_WORLD, 1); 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); MPI_Gather(send,2,MPI_DOUBLE,measure,2, MPI_DOUBLE, 0, MPI_COMM_WORLD);
char tmpname[128]; char tmpname[128];
FILE *fp = fopen(filename,"w"); FILE *fp = fopen(filename,"w");
@ -144,7 +144,7 @@ int main(int argc, char **argv)
MPI_Abort(MPI_COMM_WORLD, 1); MPI_Abort(MPI_COMM_WORLD, 1);
} }
double (*m)[2] = (void*)measure; double (*m)[2] = (void*)measure;
char (*h)[1024] = (void*)hnames; char (*h)[OPAL_MAXHOSTNAMELEN] = (void*)hnames;
int i; int i;
fprintf(fp, "# Used algorithm: %s\n", (alg ? "binary tree" : "linear")); fprintf(fp, "# Used algorithm: %s\n", (alg ? "binary tree" : "linear"));
for(i=0; i<commsize;i++){ for(i=0; i<commsize;i++){
@ -152,7 +152,7 @@ int main(int argc, char **argv)
} }
fclose(fp); fclose(fp);
} else { } 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); MPI_Gather(send,2, MPI_DOUBLE, NULL, 2, MPI_DOUBLE, 0, MPI_COMM_WORLD);
} }

Просмотреть файл

@ -285,6 +285,14 @@ typedef OPAL_PTRDIFF_TYPE ptrdiff_t;
#define OPAL_PATH_SEP "/" #define OPAL_PATH_SEP "/"
#define OPAL_ENV_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? * Do we want memory debugging?
@ -489,14 +497,9 @@ static inline uint16_t ntohs(uint16_t netvar) { return netvar; }
#ifdef HAVE_HOSTLIB_H #ifdef HAVE_HOSTLIB_H
/* gethostname() */ /* gethostname() */
#include <hostLib.h> #include <hostLib.h>
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif #endif
#endif #endif
#endif
/* If we're in C++, then just undefine restrict and then define it to /* 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 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++ have a corresponding AC_CXX_RESTRICT to figure out what the C++

Просмотреть файл

@ -330,7 +330,7 @@ static int component_find_check (mca_base_framework_t *framework, char **request
} }
if (!found) { if (!found) {
char h[MAXHOSTNAMELEN]; char h[OPAL_MAXHOSTNAMELEN];
gethostname(h, sizeof(h)); gethostname(h, sizeof(h));
opal_show_help("help-mca-base.txt", opal_show_help("help-mca-base.txt",
"find-available:not-valid", true, "find-available:not-valid", true,

Просмотреть файл

@ -66,7 +66,7 @@ int mca_base_open(void)
{ {
char *value; char *value;
opal_output_stream_t lds; opal_output_stream_t lds;
char hostname[64]; char hostname[OPAL_MAXHOSTNAMELEN];
int var_id; int var_id;
if (mca_base_opened++) { if (mca_base_opened++) {
@ -137,7 +137,7 @@ int mca_base_open(void)
} else { } else {
set_defaults(&lds); set_defaults(&lds);
} }
gethostname(hostname, 64); gethostname(hostname, sizeof(hostname));
asprintf(&lds.lds_prefix, "[%s:%05d] ", hostname, getpid()); asprintf(&lds.lds_prefix, "[%s:%05d] ", hostname, getpid());
opal_output_reopen(0, &lds); opal_output_reopen(0, &lds);
opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, 0, "mca: base: opening components"); opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, 0, "mca: base: opening components");

Просмотреть файл

@ -48,6 +48,8 @@
* Version: 0.1b * Version: 0.1b
*/ */
#include "opal_config.h"
#include <sys/types.h> #include <sys/types.h>
#include "event2/event-config.h" #include "event2/event-config.h"
@ -121,10 +123,6 @@
#define EVDNS_LOG_WARN 1 #define EVDNS_LOG_WARN 1
#define EVDNS_LOG_MSG 2 #define EVDNS_LOG_MSG 2
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 255
#endif
#include <stdio.h> #include <stdio.h>
#undef MIN #undef MIN
@ -3108,7 +3106,7 @@ evdns_search_ndots_set(const int ndots) {
static void static void
search_set_from_hostname(struct evdns_base *base) { search_set_from_hostname(struct evdns_base *base) {
char hostname[HOST_NAME_MAX + 1], *domainname; char hostname[OPAL_MAXHOSTNAMELEN], *domainname;
ASSERT_LOCKED(base); ASSERT_LOCKED(base);
search_postfix_clear(base); search_postfix_clear(base);

Просмотреть файл

@ -399,7 +399,7 @@ int opal_hwloc_base_report_bind_failure(const char *file,
if (!already_reported && if (!already_reported &&
OPAL_HWLOC_BASE_MBFA_SILENT != opal_hwloc_base_mbfa) { OPAL_HWLOC_BASE_MBFA_SILENT != opal_hwloc_base_mbfa) {
char hostname[64]; char hostname[OPAL_MAXHOSTNAMELEN];
gethostname(hostname, sizeof(hostname)); gethostname(hostname, sizeof(hostname));
opal_show_help("help-opal-hwloc-base.txt", "mbind failure", true, opal_show_help("help-opal-hwloc-base.txt", "mbind failure", true,

Просмотреть файл

@ -45,12 +45,12 @@ int main(int argc, char **argv)
uint32_t nprocs; uint32_t nprocs;
char nsp2[PMIX_MAX_NSLEN+1]; char nsp2[PMIX_MAX_NSLEN+1];
pmix_app_t *app; pmix_app_t *app;
char hostname[1024], dir[1024]; char hostname[PMIX_MAXHOSTNAMELEN], dir[1024];
pmix_proc_t *peers; pmix_proc_t *peers;
size_t npeers, ntmp=0; size_t npeers, ntmp=0;
char *nodelist; char *nodelist;
gethostname(hostname, 1024); gethostname(hostname, sizeof(hostname));
getcwd(dir, 1024); getcwd(dir, 1024);
/* init us */ /* init us */

Просмотреть файл

@ -258,6 +258,15 @@ typedef PMIX_PTRDIFF_TYPE ptrdiff_t;
#define PMIX_PATH_MAX 256 #define PMIX_PATH_MAX 256
#endif #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 * Set the compile-time path-separator on this system and variable separator
*/ */
@ -387,14 +396,9 @@ typedef PMIX_PTRDIFF_TYPE ptrdiff_t;
#ifdef HAVE_HOSTLIB_H #ifdef HAVE_HOSTLIB_H
/* gethostname() */ /* gethostname() */
#include <hostLib.h> #include <hostLib.h>
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif #endif
#endif #endif
#endif
/* If we're in C++, then just undefine restrict and then define it to /* 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 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++ have a corresponding AC_CXX_RESTRICT to figure out what the C++

Просмотреть файл

@ -125,7 +125,7 @@ PMIX_CLASS_INSTANCE(pmix_output_stream_t, pmix_object_t, construct, NULL);
bool pmix_output_init(void) bool pmix_output_init(void)
{ {
int i; int i;
char hostname[32]; char hostname[PMIX_MAXHOSTNAMELEN];
char *str; char *str;
if (initialized) { if (initialized) {
@ -250,7 +250,7 @@ bool pmix_output_switch(int output_id, bool enable)
void pmix_output_reopen_all(void) void pmix_output_reopen_all(void)
{ {
char *str; char *str;
char hostname[32]; char hostname[PMIX_MAXHOSTNAMELEN];
str = getenv("PMIX_OUTPUT_STDERR_FD"); str = getenv("PMIX_OUTPUT_STDERR_FD");
if (NULL != str) { if (NULL != str) {

Просмотреть файл

@ -49,12 +49,12 @@ int main(int argc, char **argv)
uint32_t nprocs; uint32_t nprocs;
char nsp2[PMIX_MAX_NSLEN+1]; char nsp2[PMIX_MAX_NSLEN+1];
pmix_app_t *app; pmix_app_t *app;
char hostname[1024]; char hostname[PMIX_MAXHOSTNAMELEN];
pmix_proc_t *peers; pmix_proc_t *peers;
size_t npeers, ntmp=0; size_t npeers, ntmp=0;
char *nodelist; char *nodelist;
gethostname(hostname, 1024); gethostname(hostname, sizeof(hostname));
/* init us */ /* init us */
if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc))) { if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc))) {

Просмотреть файл

@ -316,9 +316,9 @@ static void set_namespace(int nprocs, char *ranks, char *nspace,
pmix_op_cbfunc_t cbfunc, myxfer_t *x) pmix_op_cbfunc_t cbfunc, myxfer_t *x)
{ {
char *regex, *ppn; char *regex, *ppn;
char hostname[1024]; char hostname[PMIX_MAXHOSTNAMELEN];
gethostname(hostname, 1024); gethostname(hostname, sizeof(hostname));
x->ninfo = 6; x->ninfo = 6;
PMIX_INFO_CREATE(x->info, x->ninfo); PMIX_INFO_CREATE(x->info, x->ninfo);

Просмотреть файл

@ -65,7 +65,7 @@ static int query(pid_t pid,
opal_node_stats_t *nstats) opal_node_stats_t *nstats)
{ {
double dtime; double dtime;
char hostname[128]; char hostname[OPAL_MAXHOSTNAMELEN];
if (NULL != stats) { if (NULL != stats) {
/* record the time of this sample */ /* record the time of this sample */
@ -83,7 +83,7 @@ static int query(pid_t pid,
} }
if (NULL != stats) { if (NULL != stats) {
gethostname(hostname, 128); gethostname(hostname, sizeof(hostname));
strncpy(stats->node, hostname, OPAL_PSTAT_MAX_STRING_LEN); strncpy(stats->node, hostname, OPAL_PSTAT_MAX_STRING_LEN);
stats->pid = pid; stats->pid = pid;

Просмотреть файл

@ -365,9 +365,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
* a network filesystem, the user may see a shared memory performance hit. * a network filesystem, the user may see a shared memory performance hit.
*/ */
if (opal_shmem_mmap_nfs_warning && opal_path_nfs(real_file_name, NULL)) { if (opal_shmem_mmap_nfs_warning && opal_path_nfs(real_file_name, NULL)) {
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "mmap on nfs", 1, hn, opal_show_help("help-opal-shmem-mmap.txt", "mmap on nfs", 1, hn,
real_file_name); real_file_name);
} }
@ -382,9 +381,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
goto out; goto out;
} }
if (!space_available) { if (!space_available) {
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
rc = OPAL_ERR_OUT_OF_RESOURCE; rc = OPAL_ERR_OUT_OF_RESOURCE;
opal_show_help("help-opal-shmem-mmap.txt", "target full", 1, opal_show_help("help-opal-shmem-mmap.txt", "target full", 1,
real_file_name, hn, (unsigned long)real_size, real_file_name, hn, (unsigned long)real_size,
@ -394,9 +392,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
/* enough space is available, so create the segment */ /* enough space is available, so create the segment */
if (-1 == (ds_buf->seg_id = open(real_file_name, O_CREAT | O_RDWR, 0600))) { if (-1 == (ds_buf->seg_id = open(real_file_name, O_CREAT | O_RDWR, 0600))) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
"open(2)", "", strerror(err), err); "open(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;
@ -405,9 +402,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
/* size backing file - note the use of real_size here */ /* size backing file - note the use of real_size here */
if (0 != ftruncate(ds_buf->seg_id, real_size)) { if (0 != ftruncate(ds_buf->seg_id, real_size)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
"ftruncate(2)", "", strerror(err), err); "ftruncate(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;
@ -418,9 +414,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
PROT_READ | PROT_WRITE, MAP_SHARED, PROT_READ | PROT_WRITE, MAP_SHARED,
ds_buf->seg_id, 0))) { ds_buf->seg_id, 0))) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
"mmap(2)", "", strerror(err), err); "mmap(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;
@ -466,9 +461,8 @@ out:
if (-1 != ds_buf->seg_id) { if (-1 != ds_buf->seg_id) {
if (0 != close(ds_buf->seg_id)) { if (0 != close(ds_buf->seg_id)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
"close(2)", "", strerror(err), err); "close(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;
@ -500,9 +494,8 @@ segment_attach(opal_shmem_ds_t *ds_buf)
if (my_pid != ds_buf->seg_cpid) { if (my_pid != ds_buf->seg_cpid) {
if (-1 == (ds_buf->seg_id = open(ds_buf->seg_name, O_RDWR))) { if (-1 == (ds_buf->seg_id = open(ds_buf->seg_name, O_RDWR))) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
"open(2)", "", strerror(err), err); "open(2)", "", strerror(err), err);
return NULL; return NULL;
@ -512,9 +505,8 @@ segment_attach(opal_shmem_ds_t *ds_buf)
PROT_READ | PROT_WRITE, MAP_SHARED, PROT_READ | PROT_WRITE, MAP_SHARED,
ds_buf->seg_id, 0))) { ds_buf->seg_id, 0))) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
"mmap(2)", "", strerror(err), err); "mmap(2)", "", strerror(err), err);
/* mmap failed, so close the file and return NULL - no error check /* mmap failed, so close the file and return NULL - no error check
@ -529,9 +521,8 @@ segment_attach(opal_shmem_ds_t *ds_buf)
*/ */
if (0 != close(ds_buf->seg_id)) { if (0 != close(ds_buf->seg_id)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1,
hn, "close(2)", "", strerror(err), err); hn, "close(2)", "", strerror(err), err);
} }
@ -570,9 +561,8 @@ segment_detach(opal_shmem_ds_t *ds_buf)
if (0 != munmap((void *)ds_buf->seg_base_addr, ds_buf->seg_size)) { if (0 != munmap((void *)ds_buf->seg_base_addr, ds_buf->seg_size)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
"munmap(2)", "", strerror(err), err); "munmap(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;
@ -599,9 +589,8 @@ segment_unlink(opal_shmem_ds_t *ds_buf)
if (-1 == unlink(ds_buf->seg_name)) { if (-1 == unlink(ds_buf->seg_name)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
"unlink(2)", ds_buf->seg_name, strerror(err), err); "unlink(2)", ds_buf->seg_name, strerror(err), err);
return OPAL_ERROR; return OPAL_ERROR;

Просмотреть файл

@ -88,9 +88,8 @@ shmem_posix_shm_open(char *posix_file_name_buff, size_t size)
* of here. we can't be selected :-(. * of here. we can't be selected :-(.
*/ */
else { else {
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_output_verbose(10, opal_shmem_base_framework.framework_output, opal_output_verbose(10, opal_shmem_base_framework.framework_output,
"shmem_posix_shm_open: disqualifying posix because " "shmem_posix_shm_open: disqualifying posix because "
"shm_open(2) failed with error: %s (errno %d)\n", "shm_open(2) failed with error: %s (errno %d)\n",

Просмотреть файл

@ -178,9 +178,8 @@ posix_runtime_query(mca_base_module_t **module,
/* free up allocated resources before we return */ /* free up allocated resources before we return */
if (0 != shm_unlink(tmp_buff)) { if (0 != shm_unlink(tmp_buff)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1,
hn, "shm_unlink(2)", "", strerror(err), err); hn, "shm_unlink(2)", "", strerror(err), err);
/* something strange happened, so consider this a run-time test /* something strange happened, so consider this a run-time test

Просмотреть файл

@ -203,9 +203,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
/* size backing file - note the use of real_size here */ /* size backing file - note the use of real_size here */
else if (0 != ftruncate(ds_buf->seg_id, real_size)) { else if (0 != ftruncate(ds_buf->seg_id, real_size)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
"ftruncate(2)", "", strerror(err), err); "ftruncate(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;
@ -215,9 +214,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
PROT_READ | PROT_WRITE, MAP_SHARED, PROT_READ | PROT_WRITE, MAP_SHARED,
ds_buf->seg_id, 0))) { ds_buf->seg_id, 0))) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
"mmap(2)", "", strerror(err), err); "mmap(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;
@ -267,9 +265,8 @@ out:
if (-1 != ds_buf->seg_id) { if (-1 != ds_buf->seg_id) {
if (0 != close(ds_buf->seg_id)) { if (0 != close(ds_buf->seg_id)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
"close(2)", "", strerror(err), err); "close(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;
@ -307,9 +304,8 @@ segment_attach(opal_shmem_ds_t *ds_buf)
if (my_pid != ds_buf->seg_cpid) { if (my_pid != ds_buf->seg_cpid) {
if (-1 == (ds_buf->seg_id = shm_open(ds_buf->seg_name, O_RDWR, 0600))) { if (-1 == (ds_buf->seg_id = shm_open(ds_buf->seg_name, O_RDWR, 0600))) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
"open(2)", "", strerror(err), err); "open(2)", "", strerror(err), err);
return NULL; return NULL;
@ -319,9 +315,8 @@ segment_attach(opal_shmem_ds_t *ds_buf)
PROT_READ | PROT_WRITE, MAP_SHARED, PROT_READ | PROT_WRITE, MAP_SHARED,
ds_buf->seg_id, 0))) { ds_buf->seg_id, 0))) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
"mmap(2)", "", strerror(err), err); "mmap(2)", "", strerror(err), err);
/* mmap failed, so shm_unlink and return NULL - no error check here /* mmap failed, so shm_unlink and return NULL - no error check here
@ -337,9 +332,8 @@ segment_attach(opal_shmem_ds_t *ds_buf)
*/ */
if (0 != close(ds_buf->seg_id)) { if (0 != close(ds_buf->seg_id)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1,
hn, "close(2)", "", strerror(err), err); hn, "close(2)", "", strerror(err), err);
} }
@ -379,9 +373,8 @@ segment_detach(opal_shmem_ds_t *ds_buf)
if (0 != munmap((void*)ds_buf->seg_base_addr, ds_buf->seg_size)) { if (0 != munmap((void*)ds_buf->seg_base_addr, ds_buf->seg_size)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
"munmap(2)", "", strerror(err), err); "munmap(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;
@ -408,9 +401,8 @@ segment_unlink(opal_shmem_ds_t *ds_buf)
if (-1 == shm_unlink(ds_buf->seg_name)) { if (-1 == shm_unlink(ds_buf->seg_name)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
"shm_unlink(2)", ds_buf->seg_name, strerror(err), err); "shm_unlink(2)", ds_buf->seg_name, strerror(err), err);
return OPAL_ERROR; return OPAL_ERROR;

Просмотреть файл

@ -195,9 +195,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
if (-1 == (ds_buf->seg_id = shmget(IPC_PRIVATE, real_size, if (-1 == (ds_buf->seg_id = shmget(IPC_PRIVATE, real_size,
IPC_CREAT | IPC_EXCL | S_IRWXU))) { IPC_CREAT | IPC_EXCL | S_IRWXU))) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn,
"shmget(2)", "", strerror(err), err); "shmget(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;
@ -206,9 +205,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
/* attach to the sement */ /* attach to the sement */
else if ((void *)-1 == (seg_hdrp = shmat(ds_buf->seg_id, NULL, 0))) { else if ((void *)-1 == (seg_hdrp = shmat(ds_buf->seg_id, NULL, 0))) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn,
"shmat(2)", "", strerror(err), err); "shmat(2)", "", strerror(err), err);
shmctl(ds_buf->seg_id, IPC_RMID, NULL); shmctl(ds_buf->seg_id, IPC_RMID, NULL);
@ -221,9 +219,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
*/ */
else if (0 != shmctl(ds_buf->seg_id, IPC_RMID, NULL)) { else if (0 != shmctl(ds_buf->seg_id, IPC_RMID, NULL)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn,
"shmctl(2)", "", strerror(err), err); "shmctl(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;
@ -294,9 +291,8 @@ segment_attach(opal_shmem_ds_t *ds_buf)
if ((void *)-1 == (ds_buf->seg_base_addr = shmat(ds_buf->seg_id, NULL, if ((void *)-1 == (ds_buf->seg_base_addr = shmat(ds_buf->seg_id, NULL,
0))) { 0))) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn,
"shmat(2)", "", strerror(err), err); "shmat(2)", "", strerror(err), err);
shmctl(ds_buf->seg_id, IPC_RMID, NULL); shmctl(ds_buf->seg_id, IPC_RMID, NULL);
@ -337,9 +333,8 @@ segment_detach(opal_shmem_ds_t *ds_buf)
if (0 != shmdt((char*)ds_buf->seg_base_addr)) { if (0 != shmdt((char*)ds_buf->seg_base_addr)) {
int err = errno; int err = errno;
char hn[MAXHOSTNAMELEN]; char hn[OPAL_MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1); gethostname(hn, sizeof(hn));
hn[MAXHOSTNAMELEN - 1] = '\0';
opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn, opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn,
"shmdt(2)", "", strerror(err), err); "shmdt(2)", "", strerror(err), err);
rc = OPAL_ERROR; rc = OPAL_ERROR;

Просмотреть файл

@ -269,7 +269,7 @@ opal_init_util(int* pargc, char*** pargv)
{ {
int ret; int ret;
char *error = NULL; char *error = NULL;
char hostname[512]; char hostname[OPAL_MAXHOSTNAMELEN];
if( ++opal_util_initialized != 1 ) { if( ++opal_util_initialized != 1 ) {
if( opal_util_initialized < 1 ) { if( opal_util_initialized < 1 ) {
@ -294,7 +294,7 @@ opal_init_util(int* pargc, char*** pargv)
* that we don't bother with fqdn and prefix issues here - we let * that we don't bother with fqdn and prefix issues here - we let
* the RTE later replace this with a modified name if the user * the RTE later replace this with a modified name if the user
* requests it */ * requests it */
gethostname(hostname, 512); gethostname(hostname, sizeof(hostname));
opal_process_info.nodename = strdup(hostname); opal_process_info.nodename = strdup(hostname);
/* initialize the memory allocator */ /* initialize the memory allocator */

Просмотреть файл

@ -127,7 +127,7 @@ OBJ_CLASS_INSTANCE(opal_output_stream_t, opal_object_t, construct, NULL);
bool opal_output_init(void) bool opal_output_init(void)
{ {
int i; int i;
char hostname[32]; char hostname[OPAL_MAXHOSTNAMELEN];
char *str; char *str;
if (initialized) { if (initialized) {
@ -177,7 +177,6 @@ bool opal_output_init(void)
verbose.lds_want_stderr = true; verbose.lds_want_stderr = true;
} }
gethostname(hostname, sizeof(hostname)); gethostname(hostname, sizeof(hostname));
hostname[sizeof(hostname)-1] = '\0';
asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid()); asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid());
for (i = 0; i < OPAL_OUTPUT_MAX_STREAMS; ++i) { for (i = 0; i < OPAL_OUTPUT_MAX_STREAMS; ++i) {
@ -254,7 +253,7 @@ bool opal_output_switch(int output_id, bool enable)
void opal_output_reopen_all(void) void opal_output_reopen_all(void)
{ {
char *str; char *str;
char hostname[32]; char hostname[OPAL_MAXHOSTNAMELEN];
str = getenv("OPAL_OUTPUT_STDERR_FD"); str = getenv("OPAL_OUTPUT_STDERR_FD");
if (NULL != str) { if (NULL != str) {

Просмотреть файл

@ -42,7 +42,7 @@
#define HOSTFORMAT "[%s:%05d] " #define HOSTFORMAT "[%s:%05d] "
static char stacktrace_hostname[64]; static char stacktrace_hostname[OPAL_MAXHOSTNAMELEN];
static char *unable_to_print_msg = "Unable to print stack trace!\n"; static char *unable_to_print_msg = "Unable to print stack trace!\n";
/** /**
@ -427,7 +427,6 @@ int opal_util_register_stackhandlers (void)
bool complain, showed_help = false; bool complain, showed_help = false;
gethostname(stacktrace_hostname, sizeof(stacktrace_hostname)); gethostname(stacktrace_hostname, sizeof(stacktrace_hostname));
stacktrace_hostname[sizeof(stacktrace_hostname) - 1] = '\0';
/* to keep these somewhat readable, only print the machine name */ /* to keep these somewhat readable, only print the machine name */
for (i = 0 ; i < (int)strlen(stacktrace_hostname) ; ++i) { for (i = 0 ; i < (int)strlen(stacktrace_hostname) ; ++i) {
if (stacktrace_hostname[i] == '.') { if (stacktrace_hostname[i] == '.') {

Просмотреть файл

@ -75,8 +75,8 @@ int opal_timing_clocksync_read(char *fname)
bool found = false; bool found = false;
char *ptr = NULL; char *ptr = NULL;
char hname[1024] = "NA"; char hname[OPAL_MAXHOSTNAMELEN] = "NA";
if( gethostname(hname, 1024) ){ if( gethostname(hname, sizeof(hname)) ){
opal_output(0, "opal_timing_clocksync_read(%s): Cannot gethostname", opal_output(0, "opal_timing_clocksync_read(%s): Cannot gethostname",
fname); fname);
} }

Просмотреть файл

@ -176,6 +176,7 @@ typedef unsigned int uint;
#define MAXPATHLEN _MAX_PATH #define MAXPATHLEN _MAX_PATH
#define MAXHOSTNAMELEN _MAX_PATH #define MAXHOSTNAMELEN _MAX_PATH
#define OPAL_MAXHOSTNAMELEN (MAXHOSTNAMELEN + 1)
#define PATH_MAX _MAX_PATH #define PATH_MAX _MAX_PATH
#define WTERMSIG(EXIT_CODE) (1) #define WTERMSIG(EXIT_CODE) (1)
#define WIFEXITED(EXIT_CODE) (1) #define WIFEXITED(EXIT_CODE) (1)

Просмотреть файл

@ -194,15 +194,14 @@ static int component_send(orte_rml_send_t *msg)
static char* component_get_addr(void) static char* component_get_addr(void)
{ {
int len; int len;
char hn[MAXHOSTNAMELEN], *cptr; char hn[OPAL_MAXHOSTNAMELEN], *cptr;
/* /*
* TODO: for aries want to plug in GNI addr here instead to * TODO: for aries want to plug in GNI addr here instead to
* eventually be able to support connect/accept using aprun. * eventually be able to support connect/accept using aprun.
*/ */
len = gethostname(hn, MAXHOSTNAMELEN - 1); len = gethostname(hn, sizeof(hn));
hn[len]='\0';
asprintf(&cptr, "gni://%s:%d", hn, getpid()); asprintf(&cptr, "gni://%s:%d", hn, getpid());

Просмотреть файл

@ -230,7 +230,7 @@ int orte_daemon(int argc, char *argv[])
char *rml_uri; char *rml_uri;
int i; int i;
opal_buffer_t *buffer; opal_buffer_t *buffer;
char hostname[100]; char hostname[OPAL_MAXHOSTNAMELEN];
#if OPAL_ENABLE_FT_CR == 1 #if OPAL_ENABLE_FT_CR == 1
char *tmp_env_var = NULL; char *tmp_env_var = NULL;
#endif #endif
@ -297,7 +297,7 @@ int orte_daemon(int argc, char *argv[])
* away just in case we have a problem along the way * away just in case we have a problem along the way
*/ */
if (orted_globals.debug) { if (orted_globals.debug) {
gethostname(hostname, 100); gethostname(hostname, sizeof(hostname));
fprintf(stderr, "Daemon was launched on %s - beginning to initialize\n", hostname); fprintf(stderr, "Daemon was launched on %s - beginning to initialize\n", hostname);
} }
@ -725,12 +725,12 @@ int orte_daemon(int argc, char *argv[])
if (orte_retain_aliases) { if (orte_retain_aliases) {
char **aliases=NULL; char **aliases=NULL;
uint8_t naliases, ni; uint8_t naliases, ni;
char hostname[ORTE_MAX_HOSTNAME_SIZE]; char hostname[OPAL_MAXHOSTNAMELEN];
/* if we stripped the prefix or removed the fqdn, /* if we stripped the prefix or removed the fqdn,
* include full hostname as an alias * include full hostname as an alias
*/ */
gethostname(hostname, ORTE_MAX_HOSTNAME_SIZE); gethostname(hostname, sizeof(hostname));
if (strlen(orte_process_info.nodename) < strlen(hostname)) { if (strlen(orte_process_info.nodename) < strlen(hostname)) {
opal_argv_append_nosize(&aliases, hostname); opal_argv_append_nosize(&aliases, hostname);
} }

Просмотреть файл

@ -1,4 +1,6 @@
#define _GNU_SOURCE #define _GNU_SOURCE
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
@ -13,7 +15,7 @@ int main(int argc, char* argv[])
int msg; int msg;
MPI_Comm parent, children[NUM_CHILDREN]; MPI_Comm parent, children[NUM_CHILDREN];
int rank, size, i; int rank, size, i;
char hostname[512]; char hostname[OPAL_MAXHOSTNAMELEN];
pid_t pid; pid_t pid;
char *child_argv[2] = { "", NULL }; char *child_argv[2] = { "", NULL };
@ -54,7 +56,7 @@ int main(int argc, char* argv[])
} }
/* Otherwise, we're the child */ /* Otherwise, we're the child */
else { else {
gethostname(hostname, 512); gethostname(hostname, sizeof(hostname));
if (argc == 1) { if (argc == 1) {
printf("ERROR: child did not receive exepcted argv!\n"); printf("ERROR: child did not receive exepcted argv!\n");
i = -1; i = -1;

Просмотреть файл

@ -5,6 +5,8 @@
* The most basic of MPI applications * The most basic of MPI applications
*/ */
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "mpi.h" #include "mpi.h"
@ -12,13 +14,13 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int rank, size; int rank, size;
char hostname[512]; char hostname[OPAL_MAXHOSTNAMELEN];
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_size(MPI_COMM_WORLD, &size);
gethostname(hostname, 512); gethostname(hostname, sizeof(hostname));
printf("%s: I am %d of %d. pid=%d\n", hostname, rank, size, getpid()); printf("%s: I am %d of %d. pid=%d\n", hostname, rank, size, getpid());
if (rank%3 == 0) { if (rank%3 == 0) {

Просмотреть файл

@ -6,6 +6,9 @@
*/ */
#define _GNU_SOURCE #define _GNU_SOURCE
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
@ -15,7 +18,7 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int rank, size; int rank, size;
char hostname[512]; char hostname[OPAL_MAXHOSTNAMELEN];
void *appnum; void *appnum;
void *univ_size; void *univ_size;
char *appstr, *unistr; char *appstr, *unistr;
@ -40,7 +43,7 @@ int main(int argc, char* argv[])
asprintf(&unistr, "%d", *(int*)univ_size); asprintf(&unistr, "%d", *(int*)univ_size);
} }
gethostname(hostname, 512); gethostname(hostname, sizeof(hostname));
printf("Hello, World, I am %d of %d on host %s from app number %s universe size %s universe envar %s\n", printf("Hello, World, I am %d of %d on host %s from app number %s universe size %s universe envar %s\n",
rank, size, hostname, appstr, unistr, (NULL == envar) ? "NULL" : envar); rank, size, hostname, appstr, unistr, (NULL == envar) ? "NULL" : envar);

Просмотреть файл

@ -1,3 +1,5 @@
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
@ -11,7 +13,7 @@ int main(int argc, char* argv[])
int msg, rc, i; int msg, rc, i;
MPI_Comm parent, child; MPI_Comm parent, child;
int rank, size; int rank, size;
char hostname[512]; char hostname[OPAL_MAXHOSTNAMELEN];
pid_t pid; pid_t pid;
MPI_Info info; MPI_Info info;
char *keyval, *tmp; char *keyval, *tmp;
@ -63,7 +65,7 @@ int main(int argc, char* argv[])
else { else {
MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_size(MPI_COMM_WORLD, &size);
gethostname(hostname, 512); gethostname(hostname, sizeof(hostname));
pid = getpid(); pid = getpid();
printf("Hello from the child %d of %d on host %s pid %ld\n", rank, 3, hostname, (long)pid); printf("Hello from the child %d of %d on host %s pid %ld\n", rank, 3, hostname, (long)pid);
if (0 == rank) { if (0 == rank) {

Просмотреть файл

@ -1,3 +1,5 @@
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
@ -9,7 +11,7 @@ int main(int argc, char* argv[])
int msg, rc; int msg, rc;
MPI_Comm parent, child; MPI_Comm parent, child;
int rank, size; int rank, size;
char hostname[512]; char hostname[OPAL_MAXHOSTNAMELEN];
pid_t pid; pid_t pid;
pid = getpid(); pid = getpid();
@ -41,7 +43,7 @@ int main(int argc, char* argv[])
else { else {
MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_size(MPI_COMM_WORLD, &size);
gethostname(hostname, 512); gethostname(hostname, sizeof(hostname));
pid = getpid(); pid = getpid();
printf("Hello from the child %d of %d on host %s pid %ld\n", rank, 3, hostname, (long)pid); printf("Hello from the child %d of %d on host %s pid %ld\n", rank, 3, hostname, (long)pid);
if (0 == rank) { if (0 == rank) {

Просмотреть файл

@ -1,3 +1,4 @@
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -44,7 +45,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char hostname[255] ; char hostname[OPAL_MAXHOSTNAMELEN] ;
char buff[255] ; char buff[255] ;
int role ; int role ;
@ -80,7 +81,7 @@ int main(int argc, char *argv[])
/* get the node name */ /* get the node name */
{ {
int retval = gethostname(hostname, 255) ; int retval = gethostname(hostname, sizeof(hostname));
if(retval == -1) if(retval == -1)
{ {
fprintf(stderr, "gethostname failed: %s\n", strerror(errno)) ; fprintf(stderr, "gethostname failed: %s\n", strerror(errno)) ;

Просмотреть файл

@ -1,3 +1,5 @@
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
@ -9,7 +11,7 @@ int main(int argc, char* argv[])
int msg; int msg;
MPI_Comm parent, child; MPI_Comm parent, child;
int rank, size; int rank, size;
char hostname[512]; char hostname[OPAL_MAXHOSTNAMELEN];
pid_t pid; pid_t pid;
int i; int i;
char *cmds[2]; char *cmds[2];
@ -48,7 +50,7 @@ int main(int argc, char* argv[])
else { else {
MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_size(MPI_COMM_WORLD, &size);
gethostname(hostname, 512); gethostname(hostname, sizeof(hostname));
pid = getpid(); pid = getpid();
printf("Hello from the child %d of %d on host %s pid %ld: argv[1] = %s\n", rank, size, hostname, (long)pid, argv[1]); printf("Hello from the child %d of %d on host %s pid %ld: argv[1] = %s\n", rank, size, hostname, (long)pid, argv[1]);
MPI_Recv(&msg, 1, MPI_INT, 0, 1, parent, MPI_STATUS_IGNORE); MPI_Recv(&msg, 1, MPI_INT, 0, 1, parent, MPI_STATUS_IGNORE);

Просмотреть файл

@ -1,3 +1,5 @@
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -9,7 +11,7 @@ int main(int argc, char ** argv){
int i; int i;
int rank, size, child_rank; int rank, size, child_rank;
char nomehost[20]; char nomehost[OPAL_MAXHOSTNAMELEN];
MPI_Comm parent, intercomm1, intercomm2; MPI_Comm parent, intercomm1, intercomm2;
int erro; int erro;
int level, curr_level; int level, curr_level;
@ -60,7 +62,7 @@ int main(int argc, char ** argv){
} }
gethostname(nomehost, 20); gethostname(nomehost, sizeof(nomehost));
printf("(%d) in %s\n", rank, nomehost); printf("(%d) in %s\n", rank, nomehost);
MPI_Finalize(); MPI_Finalize();

Просмотреть файл

@ -6,6 +6,8 @@
* abnormal program termination * abnormal program termination
*/ */
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
@ -21,14 +23,14 @@ int main(int argc, char* argv[])
int i, rc; int i, rc;
double pi; double pi;
pid_t pid; pid_t pid;
char hostname[500]; char hostname[OPAL_MAXHOSTNAMELEN];
if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) { if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) {
fprintf(stderr, "orte_abort: couldn't init orte - error code %d\n", rc); fprintf(stderr, "orte_abort: couldn't init orte - error code %d\n", rc);
return rc; return rc;
} }
pid = getpid(); pid = getpid();
gethostname(hostname, 500); gethostname(hostname, sizeof(hostname));
if (1 < argc) { if (1 < argc) {
rc = strtol(argv[1], NULL, 10); rc = strtol(argv[1], NULL, 10);

Просмотреть файл

@ -6,6 +6,8 @@
* abnormal program termination * abnormal program termination
*/ */
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
@ -21,14 +23,14 @@ int main(int argc, char* argv[])
int i, rc; int i, rc;
double pi; double pi;
pid_t pid; pid_t pid;
char hostname[500]; char hostname[OPAL_MAXHOSTNAMELEN];
if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) { if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) {
fprintf(stderr, "orte_abort: couldn't init orte - error code %d\n", rc); fprintf(stderr, "orte_abort: couldn't init orte - error code %d\n", rc);
return rc; return rc;
} }
pid = getpid(); pid = getpid();
gethostname(hostname, 500); gethostname(hostname, sizeof(hostname));
printf("orte_abort: Name %s Host: %s Pid %ld\n", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), printf("orte_abort: Name %s Host: %s Pid %ld\n", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
hostname, (long)pid); hostname, (long)pid);

Просмотреть файл

@ -5,6 +5,8 @@
* The most basic of MPI applications * The most basic of MPI applications
*/ */
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
@ -20,7 +22,7 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int rc, i, restart=-1; int rc, i, restart=-1;
char hostname[512], *rstrt; char hostname[OPAL_MAXHOSTNAMELEN], *rstrt;
pid_t pid; pid_t pid;
if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) { if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) {
@ -32,7 +34,7 @@ int main(int argc, char* argv[])
restart = strtol(rstrt, NULL, 10); restart = strtol(rstrt, NULL, 10);
} }
gethostname(hostname, 512); gethostname(hostname, sizeof(hostname));
pid = getpid(); pid = getpid();
printf("orte_nodename: Node %s Name %s Pid %ld Restarts: %d\n", printf("orte_nodename: Node %s Name %s Pid %ld Restarts: %d\n",

Просмотреть файл

@ -1,6 +1,8 @@
/* -*- C -*- /* -*- C -*-
*/ */
#include "orte_config.h"
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
@ -19,14 +21,14 @@ int main(int argc, char* argv[])
int i, rc; int i, rc;
double pi; double pi;
pid_t pid; pid_t pid;
char hostname[500]; char hostname[OPAL_MAXHOSTNAMELEN];
if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) { if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) {
fprintf(stderr, "orte_abort: couldn't init orte - error code %d\n", rc); fprintf(stderr, "orte_abort: couldn't init orte - error code %d\n", rc);
return rc; return rc;
} }
pid = getpid(); pid = getpid();
gethostname(hostname, 500); gethostname(hostname, sizeof(hostname));
if (1 < argc) { if (1 < argc) {
rc = strtol(argv[1], NULL, 10); rc = strtol(argv[1], NULL, 10);

Просмотреть файл

@ -99,7 +99,7 @@ int orte_proc_info(void)
int idx, i; int idx, i;
char *ptr; char *ptr;
char hostname[ORTE_MAX_HOSTNAME_SIZE]; char hostname[OPAL_MAXHOSTNAMELEN];
char **prefixes; char **prefixes;
bool match; bool match;
struct in_addr buf; struct in_addr buf;
@ -168,7 +168,7 @@ int orte_proc_info(void)
orte_process_info.pid = getpid(); orte_process_info.pid = getpid();
/* get the nodename */ /* get the nodename */
gethostname(hostname, ORTE_MAX_HOSTNAME_SIZE); gethostname(hostname, sizeof(hostname));
/* add this to our list of aliases */ /* add this to our list of aliases */
opal_argv_append_nosize(&orte_process_info.aliases, hostname); opal_argv_append_nosize(&orte_process_info.aliases, hostname);

Просмотреть файл

@ -45,8 +45,6 @@
BEGIN_C_DECLS BEGIN_C_DECLS
#define ORTE_MAX_HOSTNAME_SIZE 512
typedef uint32_t orte_proc_type_t; typedef uint32_t orte_proc_type_t;
#define ORTE_PROC_TYPE_NONE 0x0000 #define ORTE_PROC_TYPE_NONE 0x0000
#define ORTE_PROC_SINGLETON 0x0001 #define ORTE_PROC_SINGLETON 0x0001

Просмотреть файл

@ -42,7 +42,7 @@ static bool have_been_invoked = false;
int oshmem_shmem_abort(int errcode) int oshmem_shmem_abort(int errcode)
{ {
char *host, hostname[MAXHOSTNAMELEN]; char *host, hostname[OPAL_MAXHOSTNAMELEN];
pid_t pid = 0; pid_t pid = 0;
/* Protection for recursive invocation */ /* Protection for recursive invocation */

Просмотреть файл

@ -59,7 +59,7 @@ test_ifaddrtoname(char *addr)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
char hostname[MAXHOSTNAMELEN]; char hostname[OPAL_MAXHOSTNAMELEN];
opal_init(&argc, &argv); opal_init(&argc, &argv);
test_init("opal_if"); test_init("opal_if");
@ -117,7 +117,7 @@ main(int argc, char *argv[])
} }
/* local host name */ /* local host name */
gethostname(hostname, MAXHOSTNAMELEN); gethostname(hostname, sizeof(hostname));
if (test_ifaddrtoname(hostname)) { if (test_ifaddrtoname(hostname)) {
test_success(); test_success();
} else { } else {