opal: standardize on max hostname length
Define OPAL_MAXHOSTNAMELEN to be either: (MAXHOSTNAMELEN + 1) or (limits.h:HOST_NAME_MAX + 1) or (255 + 1) For pmix code, define above using PMIX_MAXHOSTNAMELEN. Fixup opal layer to use the new max. Signed-off-by: Karol Mroz <mroz.karol@gmail.com>
This commit is contained in:
parent
fdd1ff7c29
commit
e1c64e6e59
@ -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?
|
||||
@ -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++
|
||||
|
@ -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,
|
||||
|
@ -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++) {
|
||||
@ -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");
|
||||
|
@ -48,6 +48,8 @@
|
||||
* Version: 0.1b
|
||||
*/
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "event2/event-config.h"
|
||||
|
||||
@ -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
|
||||
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
*/
|
||||
@ -387,14 +396,9 @@ 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
|
||||
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++
|
||||
|
@ -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) {
|
||||
@ -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) {
|
||||
|
@ -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))) {
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
@ -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;
|
||||
|
@ -365,9 +365,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
|
||||
* 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)) {
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "mmap on nfs", 1, hn,
|
||||
real_file_name);
|
||||
}
|
||||
@ -382,9 +381,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
|
||||
goto out;
|
||||
}
|
||||
if (!space_available) {
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
rc = OPAL_ERR_OUT_OF_RESOURCE;
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "target full", 1,
|
||||
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 */
|
||||
if (-1 == (ds_buf->seg_id = open(real_file_name, O_CREAT | O_RDWR, 0600))) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
|
||||
"open(2)", "", strerror(err), err);
|
||||
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 */
|
||||
if (0 != ftruncate(ds_buf->seg_id, real_size)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
|
||||
"ftruncate(2)", "", strerror(err), err);
|
||||
rc = OPAL_ERROR;
|
||||
@ -418,9 +414,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
ds_buf->seg_id, 0))) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
|
||||
"mmap(2)", "", strerror(err), err);
|
||||
rc = OPAL_ERROR;
|
||||
@ -466,9 +461,8 @@ out:
|
||||
if (-1 != ds_buf->seg_id) {
|
||||
if (0 != close(ds_buf->seg_id)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
|
||||
"close(2)", "", strerror(err), err);
|
||||
rc = OPAL_ERROR;
|
||||
@ -500,9 +494,8 @@ segment_attach(opal_shmem_ds_t *ds_buf)
|
||||
if (my_pid != ds_buf->seg_cpid) {
|
||||
if (-1 == (ds_buf->seg_id = open(ds_buf->seg_name, O_RDWR))) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
|
||||
"open(2)", "", strerror(err), err);
|
||||
return NULL;
|
||||
@ -512,9 +505,8 @@ segment_attach(opal_shmem_ds_t *ds_buf)
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
ds_buf->seg_id, 0))) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
|
||||
"mmap(2)", "", strerror(err), err);
|
||||
/* 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)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1,
|
||||
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)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
|
||||
"munmap(2)", "", strerror(err), err);
|
||||
rc = OPAL_ERROR;
|
||||
@ -599,9 +589,8 @@ segment_unlink(opal_shmem_ds_t *ds_buf)
|
||||
|
||||
if (-1 == unlink(ds_buf->seg_name)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
|
||||
"unlink(2)", ds_buf->seg_name, strerror(err), err);
|
||||
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 :-(.
|
||||
*/
|
||||
else {
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_output_verbose(10, opal_shmem_base_framework.framework_output,
|
||||
"shmem_posix_shm_open: disqualifying posix because "
|
||||
"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 */
|
||||
if (0 != shm_unlink(tmp_buff)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1,
|
||||
hn, "shm_unlink(2)", "", strerror(err), err);
|
||||
/* 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 */
|
||||
else if (0 != ftruncate(ds_buf->seg_id, real_size)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
|
||||
"ftruncate(2)", "", strerror(err), err);
|
||||
rc = OPAL_ERROR;
|
||||
@ -215,9 +214,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
ds_buf->seg_id, 0))) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
|
||||
"mmap(2)", "", strerror(err), err);
|
||||
rc = OPAL_ERROR;
|
||||
@ -267,9 +265,8 @@ out:
|
||||
if (-1 != ds_buf->seg_id) {
|
||||
if (0 != close(ds_buf->seg_id)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1, hn,
|
||||
"close(2)", "", strerror(err), err);
|
||||
rc = OPAL_ERROR;
|
||||
@ -307,9 +304,8 @@ segment_attach(opal_shmem_ds_t *ds_buf)
|
||||
if (my_pid != ds_buf->seg_cpid) {
|
||||
if (-1 == (ds_buf->seg_id = shm_open(ds_buf->seg_name, O_RDWR, 0600))) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
|
||||
"open(2)", "", strerror(err), err);
|
||||
return NULL;
|
||||
@ -319,9 +315,8 @@ segment_attach(opal_shmem_ds_t *ds_buf)
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
ds_buf->seg_id, 0))) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
|
||||
"mmap(2)", "", strerror(err), err);
|
||||
/* 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)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-mmap.txt", "sys call fail", 1,
|
||||
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)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
|
||||
"munmap(2)", "", strerror(err), err);
|
||||
rc = OPAL_ERROR;
|
||||
@ -408,9 +401,8 @@ segment_unlink(opal_shmem_ds_t *ds_buf)
|
||||
|
||||
if (-1 == shm_unlink(ds_buf->seg_name)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-posix.txt", "sys call fail", 1, hn,
|
||||
"shm_unlink(2)", ds_buf->seg_name, strerror(err), err);
|
||||
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,
|
||||
IPC_CREAT | IPC_EXCL | S_IRWXU))) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn,
|
||||
"shmget(2)", "", strerror(err), err);
|
||||
rc = OPAL_ERROR;
|
||||
@ -206,9 +205,8 @@ segment_create(opal_shmem_ds_t *ds_buf,
|
||||
/* attach to the sement */
|
||||
else if ((void *)-1 == (seg_hdrp = shmat(ds_buf->seg_id, NULL, 0))) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn,
|
||||
"shmat(2)", "", strerror(err), err);
|
||||
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)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn,
|
||||
"shmctl(2)", "", strerror(err), err);
|
||||
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,
|
||||
0))) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn,
|
||||
"shmat(2)", "", strerror(err), err);
|
||||
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)) {
|
||||
int err = errno;
|
||||
char hn[MAXHOSTNAMELEN];
|
||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||
char hn[OPAL_MAXHOSTNAMELEN];
|
||||
gethostname(hn, sizeof(hn));
|
||||
opal_show_help("help-opal-shmem-sysv.txt", "sys call fail", 1, hn,
|
||||
"shmdt(2)", "", strerror(err), err);
|
||||
rc = OPAL_ERROR;
|
||||
|
@ -269,7 +269,7 @@ opal_init_util(int* pargc, char*** pargv)
|
||||
{
|
||||
int ret;
|
||||
char *error = NULL;
|
||||
char hostname[512];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
|
||||
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
|
||||
* the RTE later replace this with a modified name if the user
|
||||
* requests it */
|
||||
gethostname(hostname, 512);
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
opal_process_info.nodename = strdup(hostname);
|
||||
|
||||
/* 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)
|
||||
{
|
||||
int i;
|
||||
char hostname[32];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
char *str;
|
||||
|
||||
if (initialized) {
|
||||
@ -177,7 +177,6 @@ bool opal_output_init(void)
|
||||
verbose.lds_want_stderr = true;
|
||||
}
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
hostname[sizeof(hostname)-1] = '\0';
|
||||
asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid());
|
||||
|
||||
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)
|
||||
{
|
||||
char *str;
|
||||
char hostname[32];
|
||||
char hostname[OPAL_MAXHOSTNAMELEN];
|
||||
|
||||
str = getenv("OPAL_OUTPUT_STDERR_FD");
|
||||
if (NULL != str) {
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#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";
|
||||
|
||||
/**
|
||||
@ -427,7 +427,6 @@ int opal_util_register_stackhandlers (void)
|
||||
bool complain, showed_help = false;
|
||||
|
||||
gethostname(stacktrace_hostname, sizeof(stacktrace_hostname));
|
||||
stacktrace_hostname[sizeof(stacktrace_hostname) - 1] = '\0';
|
||||
/* to keep these somewhat readable, only print the machine name */
|
||||
for (i = 0 ; i < (int)strlen(stacktrace_hostname) ; ++i) {
|
||||
if (stacktrace_hostname[i] == '.') {
|
||||
|
@ -75,8 +75,8 @@ int opal_timing_clocksync_read(char *fname)
|
||||
bool found = false;
|
||||
char *ptr = NULL;
|
||||
|
||||
char hname[1024] = "NA";
|
||||
if( gethostname(hname, 1024) ){
|
||||
char hname[OPAL_MAXHOSTNAMELEN] = "NA";
|
||||
if( gethostname(hname, sizeof(hname)) ){
|
||||
opal_output(0, "opal_timing_clocksync_read(%s): Cannot gethostname",
|
||||
fname);
|
||||
}
|
||||
|
@ -176,6 +176,7 @@ typedef unsigned int uint;
|
||||
|
||||
#define MAXPATHLEN _MAX_PATH
|
||||
#define MAXHOSTNAMELEN _MAX_PATH
|
||||
#define OPAL_MAXHOSTNAMELEN (MAXHOSTNAMELEN + 1)
|
||||
#define PATH_MAX _MAX_PATH
|
||||
#define WTERMSIG(EXIT_CODE) (1)
|
||||
#define WIFEXITED(EXIT_CODE) (1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user