[mpich-commits] r10759 - in mpich2/trunk/src: binding/cxx include mpi/pt2pt mpi/spawn mpid/ch3/src mpl/include mpl/src pm/util util/mem util/procmap
gropp at mcs.anl.gov
gropp at mcs.anl.gov
Tue Dec 11 10:09:42 CST 2012
Author: gropp
Date: 2012-12-11 10:09:42 -0600 (Tue, 11 Dec 2012)
New Revision: 10759
Modified:
mpich2/trunk/src/binding/cxx/buildiface
mpich2/trunk/src/include/glue_romio.h.in
mpich2/trunk/src/include/mpibsend.h
mpich2/trunk/src/include/mpimem.h
mpich2/trunk/src/mpi/pt2pt/bsendutil.c
mpich2/trunk/src/mpi/spawn/comm_join.c
mpich2/trunk/src/mpid/ch3/src/mpid_getpname.c
mpich2/trunk/src/mpid/ch3/src/mpid_port.c
mpich2/trunk/src/mpid/ch3/src/mpidi_pg.c
mpich2/trunk/src/mpl/include/mpltrmem.h
mpich2/trunk/src/mpl/src/mpltrmem.c
mpich2/trunk/src/pm/util/env.c
mpich2/trunk/src/pm/util/ioloop.c
mpich2/trunk/src/pm/util/labelout.c
mpich2/trunk/src/pm/util/pmiserv.c
mpich2/trunk/src/pm/util/pmutil.h
mpich2/trunk/src/pm/util/rm.c
mpich2/trunk/src/pm/util/simple_pmiutil2.c
mpich2/trunk/src/util/mem/trmem.c
mpich2/trunk/src/util/procmap/local_proc.c
Log:
Update the trmem routines and macros (defined when malloc took an unsigned int for size) to use size_t instead, as well as some int/size_t cleanup (again for code that correctly used signed int when it was written)
Modified: mpich2/trunk/src/binding/cxx/buildiface
===================================================================
--- mpich2/trunk/src/binding/cxx/buildiface 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/binding/cxx/buildiface 2012-12-11 16:09:42 UTC (rev 10759)
@@ -1955,17 +1955,19 @@
// header isn't C++ clean. Instead, we just include a definition
// for size_t. If this is not the correct size, then edit this line
// (Note that this is needed only when memory tracing is enabled)
+// FIXME: determine whether the type definition is needed, and include the
+// correct definition.
typedef unsigned int size_t;
-extern \"C\" void *MPIU_trmalloc( unsigned int, int, const char [] );
+extern \"C\" void *MPIU_trmalloc( size_t, int, const char [] );
extern \"C\" void MPIU_trfree( void *, int, const char [] );
extern \"C\" void MPIU_trdump( void *, int );
void *operator new(size_t size) {
- void *p = MPIU_trmalloc( (unsigned int) size, _mpi_lineno, __FILE__ );
+ void *p = MPIU_trmalloc( size, _mpi_lineno, __FILE__ );
return p;}
void operator delete(void *p) {
MPIU_trfree( p, _mpi_lineno, __FILE__ );}
void *operator new[]( size_t size) {
- void *p = MPIU_trmalloc( (unsigned int) size, _mpi_lineno, __FILE__ );
+ void *p = MPIU_trmalloc( size, _mpi_lineno, __FILE__ );
return p;}
void operator delete[](void *p) {
MPIU_trfree( p, _mpi_lineno, __FILE__ );}
Modified: mpich2/trunk/src/include/glue_romio.h.in
===================================================================
--- mpich2/trunk/src/include/glue_romio.h.in 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/include/glue_romio.h.in 2012-12-11 16:09:42 UTC (rev 10759)
@@ -54,10 +54,10 @@
void MPIR_Ext_cs_exit_allfunc(void);
/* prototypes for the mem tracing routines */
-void *MPIU_trmalloc(unsigned int a, int lineno, const char fname[]);
+void *MPIU_trmalloc(size_t a, int lineno, const char fname[]);
void MPIU_trfree(void *a_ptr, int line, const char fname[]);
-void *MPIU_trcalloc(unsigned int nelem, unsigned int elsize, int lineno, const char fname[]);
-void *MPIU_trrealloc(void *p, int size, int lineno, const char fname[]);
+void *MPIU_trcalloc(size_t nelem, size_t elsize, int lineno, const char fname[]);
+void *MPIU_trrealloc(void *p, size_t size, int lineno, const char fname[]);
void *MPIU_trstrdup(const char *str, int lineno, const char fname[]);
#endif /* defined(GLUE_ROMIO_H_INCLUDED) */
Modified: mpich2/trunk/src/include/mpibsend.h
===================================================================
--- mpich2/trunk/src/include/mpibsend.h 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/include/mpibsend.h 2012-12-11 16:09:42 UTC (rev 10759)
@@ -53,7 +53,7 @@
request is not currently available */
typedef struct MPIR_Bsend_msg {
void *msgbuf;
- int count;
+ int count; /* int type to match needs of Pack routine */
MPI_Datatype dtype;
int tag;
struct MPID_Comm *comm_ptr;
@@ -62,14 +62,14 @@
/* BsendData describes a bsend request */
typedef struct MPIR_Bsend_data {
- int size; /* size that is available for data */
- int total_size; /* total size of this segment,
+ size_t size; /* size that is available for data */
+ size_t total_size; /* total size of this segment,
including all headers */
struct MPIR_Bsend_data *next, *prev;
MPIR_Bsend_kind_t kind;
struct MPID_Request *request;
- MPIR_Bsend_msg_t msg;
- double alignpad; /* make sure that the struct
+ MPIR_Bsend_msg_t msg;
+ double alignpad; /* make sure that the struct
shares double alignment */
} MPIR_Bsend_data_t;
Modified: mpich2/trunk/src/include/mpimem.h
===================================================================
--- mpich2/trunk/src/include/mpimem.h 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/include/mpimem.h 2012-12-11 16:09:42 UTC (rev 10759)
@@ -6,6 +6,10 @@
#ifndef MPIMEM_H_INCLUDED
#define MPIMEM_H_INCLUDED
+#ifndef MPICHCONF_H_INCLUDED
+#error 'mpimem.h requires that mpichconf.h be included first'
+#endif
+
/* Make sure that we have the definitions for the malloc routines and size_t */
#include <stdio.h>
#include <stdlib.h>
@@ -138,17 +142,17 @@
/* ------------------------------------------------------------------------- */
void MPIU_trinit(int);
-void *MPIU_trmalloc(unsigned int, int, const char []);
+void *MPIU_trmalloc(size_t, int, const char []);
void MPIU_trfree(void *, int, const char []);
int MPIU_trvalid(const char []);
void MPIU_trspace(int *, int *);
void MPIU_trid(int);
void MPIU_trlevel(int);
void MPIU_trDebugLevel(int);
-void *MPIU_trcalloc(unsigned int, unsigned int, int, const char []);
-void *MPIU_trrealloc(void *, int, int, const char[]);
+void *MPIU_trcalloc(size_t, size_t, int, const char []);
+void *MPIU_trrealloc(void *, size_t, int, const char[]);
void *MPIU_trstrdup(const char *, int, const char[]);
-void MPIU_TrSetMaxMem(int);
+void MPIU_TrSetMaxMem(size_t);
void MPIU_trdump(FILE *, int);
#ifdef USE_MEMORY_TRACING
@@ -173,7 +177,7 @@
.ve
However, it can also be defined as
.vb
- #define MPIU_Malloc(n) MPIU_trmalloc(n,__FILE__,__LINE__)
+ #define MPIU_Malloc(n) MPIU_trmalloc(n,__LINE__,__FILE__)
.ve
where 'MPIU_trmalloc' is a tracing version of 'malloc' that is included with
MPICH.
@@ -181,7 +185,7 @@
Module:
Utility
M*/
-#define MPIU_Malloc(a) MPIU_trmalloc((unsigned)(a),__LINE__,__FILE__)
+#define MPIU_Malloc(a) MPIU_trmalloc((a),__LINE__,__FILE__)
/*M
MPIU_Calloc - Allocate memory that is initialized to zero.
@@ -203,7 +207,7 @@
Utility
M*/
#define MPIU_Calloc(a,b) \
- MPIU_trcalloc((unsigned)(a),(unsigned)(b),__LINE__,__FILE__)
+ MPIU_trcalloc((a),(b),__LINE__,__FILE__)
/*M
MPIU_Free - Free memory
@@ -224,7 +228,7 @@
.ve
However, it can also be defined as
.vb
- #define MPIU_Free(n) MPIU_trfree(n,__FILE__,__LINE__)
+ #define MPIU_Free(n) MPIU_trfree(n,__LINE__,__FILE__)
.ve
where 'MPIU_trfree' is a tracing version of 'free' that is included with
MPICH.
Modified: mpich2/trunk/src/mpi/pt2pt/bsendutil.c
===================================================================
--- mpich2/trunk/src/mpi/pt2pt/bsendutil.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/mpi/pt2pt/bsendutil.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -57,10 +57,10 @@
static struct BsendBuffer {
void *buffer; /* Pointer to the begining of the user-
provided buffer */
- int buffer_size; /* Size of the user-provided buffer */
+ size_t buffer_size; /* Size of the user-provided buffer */
void *origbuffer; /* Pointer to the buffer provided by
the user */
- int origbuffer_size; /* Size of the buffer as provided
+ size_t origbuffer_size;/* Size of the buffer as provided
by the user */
MPIR_Bsend_data_t *avail; /* Pointer to the first available block
of space */
@@ -157,7 +157,9 @@
/*
* Detach a buffer. This routine must wait until any pending bsends
- * are complete.
+ * are complete. Note that MPI specifies the type of the returned "size"
+ * argument as an "int" (the definition predates that of ssize_t as a
+ * standard type).
*/
#undef FUNCNAME
#define FUNCNAME MPIR_Bsend_detach
@@ -183,7 +185,9 @@
/* Note that this works even when the buffer does not exist */
*(void **) bufferp = BsendBuffer.origbuffer;
- *size = BsendBuffer.origbuffer_size;
+ /* This cast to int will work because the user must use an int to describe
+ the buffer size */
+ *size = (int)BsendBuffer.origbuffer_size;
BsendBuffer.origbuffer = NULL;
BsendBuffer.origbuffer_size = 0;
BsendBuffer.buffer = 0;
Modified: mpich2/trunk/src/mpi/spawn/comm_join.c
===================================================================
--- mpich2/trunk/src/mpi/spawn/comm_join.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/mpi/spawn/comm_join.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -46,7 +46,10 @@
while (length)
{
- num_bytes = send(fd, buffer, length, 0);
+ /* The expectation is that the length of a join message will fit
+ in an int. For Unixes that define send as returning ssize_t,
+ we can safely cast this to an int. */
+ num_bytes = (int)send(fd, buffer, length, 0);
/* --BEGIN ERROR HANDLING-- */
if (num_bytes == -1)
{
@@ -75,7 +78,8 @@
while (length)
{
- num_bytes = recv(fd, buffer, length, 0);
+ /* See discussion on send above for the cast to int. */
+ num_bytes = (int)recv(fd, buffer, length, 0);
/* --BEGIN ERROR HANDLING-- */
if (num_bytes == -1)
{
Modified: mpich2/trunk/src/mpid/ch3/src/mpid_getpname.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/src/mpid_getpname.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/mpid/ch3/src/mpid_getpname.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -84,7 +84,7 @@
static inline void setupProcessorName( void )
{
if (gethostname(processorName, MPI_MAX_PROCESSOR_NAME) == 0) {
- processorNameLen = strlen( processorName );
+ processorNameLen = (int)strlen( processorName );
}
}
@@ -92,7 +92,7 @@
static inline void setupProcessorName( void );
{
if (sysinfo(SI_HOSTNAME, processorName, MPI_MAX_PROCESSOR_NAME) == 0) {
- processorNameLen = strlen( processorName );
+ processorNameLen = (int)strlen( processorName );
}
}
@@ -102,6 +102,6 @@
/* Set the name as the rank of the process */
MPIU_Snprintf( processorName, MPI_MAX_PROCESSOR_NAME, "%d",
MPIDI_Process.my_pg_rank );
- processorNameLen = strlen( processorName );
+ processorNameLen = (int)strlen( processorName );
}
#endif
Modified: mpich2/trunk/src/mpid/ch3/src/mpid_port.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/src/mpid_port.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/mpid/ch3/src/mpid_port.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -245,7 +245,7 @@
port_name_tag_mask[i]) {
/* Mark the appropriate bit as used and return that */
port_name_tag_mask[i] |= (1 << ((8 * sizeof(int)) - j - 1));
- *port_name_tag = ((i * 8 * sizeof(int)) + j);
+ *port_name_tag = ((i * 8 * (int)sizeof(int)) + j);
goto fn_exit;
}
}
@@ -268,8 +268,8 @@
{
int idx, rem_tag;
- idx = tag / (sizeof(int) * 8);
- rem_tag = tag - (idx * sizeof(int) * 8);
+ idx = tag / ((int)sizeof(int) * 8);
+ rem_tag = tag - (int)(idx * sizeof(int) * 8);
port_name_tag_mask[idx] &= ~(1 << ((8 * sizeof(int)) - 1 - rem_tag));
}
Modified: mpich2/trunk/src/mpid/ch3/src/mpidi_pg.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/src/mpidi_pg.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/mpid/ch3/src/mpidi_pg.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -730,9 +730,9 @@
char *string = 0;
char *pg_idStr = (char *)pg->id; /* In the PMI/KVS space,
the pg id is a string */
- char buf[MPIDI_MAX_KVS_VALUE_LEN];
- int i, j, vallen, rc, mpi_errno = MPI_SUCCESS, len;
- int curSlen;
+ char buf[MPIDI_MAX_KVS_VALUE_LEN];
+ int i, j, rc, mpi_errno = MPI_SUCCESS, len;
+ size_t vallen, curSlen;
/* Make an initial allocation of a string with an estimate of the
needed space */
@@ -782,7 +782,7 @@
if (len + vallen + 1 >= curSlen) {
char *nstring = 0;
curSlen += (pg->size - i) * (vallen + 1 );
- nstring = MPIU_Realloc( string, curSlen);
+ nstring = MPIU_Realloc( string, curSlen );
if (!nstring) {
MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
}
Modified: mpich2/trunk/src/mpl/include/mpltrmem.h
===================================================================
--- mpich2/trunk/src/mpl/include/mpltrmem.h 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/mpl/include/mpltrmem.h 2012-12-11 16:09:42 UTC (rev 10759)
@@ -12,7 +12,7 @@
does not alias any pointer prior to the call.
*/
void MPL_trinit(int);
-void *MPL_trmalloc(unsigned int, int, const char[]);
+void *MPL_trmalloc(size_t, int, const char[]);
void MPL_trfree(void *, int, const char[]);
int MPL_trvalid(const char[]);
int MPL_trvalid2(const char[],int,const char[]);
@@ -20,10 +20,10 @@
void MPL_trid(int);
void MPL_trlevel(int);
void MPL_trDebugLevel(int);
-void *MPL_trcalloc(unsigned int, unsigned int, int, const char[]);
-void *MPL_trrealloc(void *, int, int, const char[]);
+void *MPL_trcalloc(size_t, size_t, int, const char[]);
+void *MPL_trrealloc(void *, size_t, int, const char[]);
void *MPL_trstrdup(const char *, int, const char[]);
-void MPL_TrSetMaxMem(int);
+void MPL_TrSetMaxMem(size_t);
/* Make sure that FILE is defined */
#include <stdio.h>
Modified: mpich2/trunk/src/mpl/src/mpltrmem.c
===================================================================
--- mpich2/trunk/src/mpl/src/mpltrmem.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/mpl/src/mpltrmem.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -202,7 +202,7 @@
double aligned pointer to requested storage, or null if not
available.
+*/
-void *MPL_trmalloc(unsigned int a, int lineno, const char fname[])
+void *MPL_trmalloc(size_t a, int lineno, const char fname[])
{
TRSPACE *head;
char *new = NULL;
@@ -753,11 +753,11 @@
Double aligned pointer to requested storage, or null if not
available.
+*/
-void *MPL_trcalloc(unsigned int nelem, unsigned int elsize, int lineno, const char fname[])
+void *MPL_trcalloc(size_t nelem, size_t elsize, int lineno, const char fname[])
{
void *p;
- p = MPL_trmalloc((unsigned) (nelem * elsize), lineno, fname);
+ p = MPL_trmalloc(nelem * elsize, lineno, fname);
if (p) {
memset(p, 0, nelem * elsize);
}
@@ -778,7 +778,7 @@
available. This implementation ALWAYS allocates new space and copies
the contents into the new space.
+*/
-void *MPL_trrealloc(void *p, int size, int lineno, const char fname[])
+void *MPL_trrealloc(void *p, size_t size, int lineno, const char fname[])
{
void *pnew;
size_t nsize;
@@ -809,7 +809,7 @@
return NULL;
}
- pnew = MPL_trmalloc((unsigned) size, lineno, fname);
+ pnew = MPL_trmalloc(size, lineno, fname);
if (p && pnew) {
nsize = size;
@@ -846,7 +846,7 @@
void *p;
size_t len = strlen(str) + 1;
- p = MPL_trmalloc((unsigned)len, lineno, (char *) fname);
+ p = MPL_trmalloc(len, lineno, fname);
if (p) {
memcpy(p, str, len);
}
@@ -991,7 +991,7 @@
fflush(fp);
}
-void MPL_TrSetMaxMem(int size)
+void MPL_TrSetMaxMem(size_t size)
{
TRMaxMemAllow = size;
}
Modified: mpich2/trunk/src/pm/util/env.c
===================================================================
--- mpich2/trunk/src/pm/util/env.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/pm/util/env.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -102,7 +102,8 @@
while (*lPtr) {
name = lPtr++;
while (*lPtr && *lPtr != ',') lPtr++;
- namelen = lPtr - name;
+ /* The length of any environment string will fit in an int */
+ namelen = (int)(lPtr - name);
p = (EnvData *)MPIU_Malloc( sizeof(EnvData) );
p->value = 0;
p->name = (const char *)MPIU_Malloc( namelen + 1 );
@@ -243,7 +244,8 @@
{
const char *value;
char *str;
- int slen, rc;
+ int rc;
+ size_t slen;
while (elist) {
/* Skip variables that already have value strings */
Modified: mpich2/trunk/src/pm/util/ioloop.c
===================================================================
--- mpich2/trunk/src/pm/util/ioloop.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/pm/util/ioloop.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -238,7 +238,7 @@
#ifdef HAVE_TIME
time_t t;
t = time( NULL );
- end_time = seconds + t;
+ end_time = seconds + (int)t;
#elif defined(HAVE_GETTIMEOFDAY)
struct timeval tp;
gettimeofday( &tp, NULL );
@@ -264,7 +264,7 @@
#ifdef HAVE_TIME
time_t t;
t = time( NULL );
- time_left = end_time - t;
+ time_left = end_time - (int)t;
#elif defined(HAVE_GETTIMEOFDAY)
struct timeval tp;
gettimeofday( &tp, NULL );
Modified: mpich2/trunk/src/pm/util/labelout.c
===================================================================
--- mpich2/trunk/src/pm/util/labelout.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/pm/util/labelout.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -209,7 +209,7 @@
switch (*pin) {
case '%': *pout++ = '%'; lenleft--; break;
case 'd':
- dlen = strlen( rankAsChar );
+ dlen = (int)strlen( rankAsChar );
if (dlen < lenleft) {
MPIU_Strncpy( pout, rankAsChar, lenleft );
pout += dlen;
@@ -221,7 +221,7 @@
}
break;
case 'w':
- dlen = strlen(worldnumAsChar);
+ dlen = (int)strlen(worldnumAsChar);
if (dlen < lenleft) {
MPIU_Strncpy( pout, worldnumAsChar, lenleft );
pout += dlen;
@@ -248,7 +248,7 @@
/* Recursively invoke the label routine */
IOLabelSetLabelText( wPattern, wLabel, sizeof(wLabel),
rank, worldnum );
- dlen = strlen(wLabel);
+ dlen = (int)strlen(wLabel);
if (dlen < lenleft) {
MPIU_Strncpy( pout, wLabel, lenleft );
pout += dlen;
Modified: mpich2/trunk/src/pm/util/pmiserv.c
===================================================================
--- mpich2/trunk/src/pm/util/pmiserv.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/pm/util/pmiserv.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -1391,7 +1391,7 @@
/* Carefully read data into buffer. This could be
written to read more at one time, but would then
need to know the size of the readbuf */
- n = read( fd, readbuf, 1 );
+ n = (int)read( fd, readbuf, 1 );
} while (n == -1 && errno == EINTR);
if (n == 0) {
/* EOF */
Modified: mpich2/trunk/src/pm/util/pmutil.h
===================================================================
--- mpich2/trunk/src/pm/util/pmutil.h 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/pm/util/pmutil.h 2012-12-11 16:09:42 UTC (rev 10759)
@@ -54,12 +54,17 @@
#define DBG_PRINTF(a) DBG_PRINTFCOND(MPIE_Debug,a)
/* #define USE_LOG_SYSCALLS */
+/* For the system calls used in PMI, values returned by the system
+ calls will fit in an int, and need to be an int (signed) to
+ test for error, since a return of -1 (typically) indicates error,
+ even for system calls such as write that may return an unsigned value (!)
+*/
#ifdef USE_LOG_SYSCALLS
#include <errno.h>
#define MPIE_SYSCALL(a_,b_,c_) { \
printf( "about to call %s (%s,%d)\n", #b_ ,__FILE__, __LINE__);\
fflush(stdout); errno = 0;\
- a_ = b_ c_; \
+ a_ = (int)b_ c_; \
if ((a_)>=0 || errno==0) {\
printf( "%s returned %d\n", #b_, a_ );\
} \
@@ -68,7 +73,7 @@
#b_, a_, errno, strerror(errno));\
}; fflush(stdout);}
#else
-#define MPIE_SYSCALL(a_,b_,c_) a_ = b_ c_
+#define MPIE_SYSCALL(a_,b_,c_) a_ = (int)b_ c_
#endif
Modified: mpich2/trunk/src/pm/util/rm.c
===================================================================
--- mpich2/trunk/src/pm/util/rm.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/pm/util/rm.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -210,7 +210,8 @@
char dirname[PATH_MAX];
const char *path=getenv("MPIEXEC_MACHINES_PATH");
MachineTable *mt;
- int len, nFound = 0;
+ size_t len;
+ int nFound = 0;
/* Try to open the machines file. arch may be null, in which
case we open the default file */
@@ -341,13 +342,14 @@
mt->desc[nFound].login = 0;
if (npstring) {
char *newp;
- int n = strtol( npstring, &newp, 0 );
+ size_t n = strtol( npstring, &newp, 0 );
if (newp == npstring) {
/* This indicates an error in the file. How do we
report that? */
n = 1;
}
- mt->desc[nFound].np = n;
+ /* Length of hostname will fit in an int. */
+ mt->desc[nFound].np = (int)n;
}
else
mt->desc[nFound].np = 1;
Modified: mpich2/trunk/src/pm/util/simple_pmiutil2.c
===================================================================
--- mpich2/trunk/src/pm/util/simple_pmiutil2.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/pm/util/simple_pmiutil2.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -132,7 +132,11 @@
if (nextChar == lastChar) {
lastfd = fd;
do {
- n = read( fd, readbuf, sizeof(readbuf)-1 );
+ /* The size of the read buffer will always fit within
+ an int. */
+ /* FIXME: the read length should be the size of the buffer,
+ not the size of the pointer to buffer */
+ n = (int)read( fd, readbuf, sizeof(readbuf)-1 );
} while (n == -1 && errno == EINTR);
if (n == 0) {
/* EOF */
@@ -172,7 +176,8 @@
int PMIU_writeline( int fd, char *buf )
{
- int size, n;
+ int n;
+ size_t size;
size = strlen( buf );
if ( size > PMIU_MAXLINE ) {
@@ -184,7 +189,10 @@
buf );
else {
do {
- n = write( fd, buf, size );
+ /* We assume that the size of any buf to be written fits
+ in an int. For the PMI interface, this should always
+ be true */
+ n = (int)write( fd, buf, size );
} while (n == -1 && errno == EINTR);
if ( n < 0 ) {
@@ -204,8 +212,8 @@
*/
int PMIU_parse_keyvals( char *st )
{
- char *p, *keystart, *valstart;
- int offset;
+ char *p, *keystart, *valstart;
+ size_t offset;
if ( !st )
return( -1 );
Modified: mpich2/trunk/src/util/mem/trmem.c
===================================================================
--- mpich2/trunk/src/util/mem/trmem.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/util/mem/trmem.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -22,7 +22,7 @@
MPIU_THREAD_CS_EXIT(MEMALLOC,);
}
-void *MPIU_trmalloc(unsigned int a, int lineno, const char fname[])
+void *MPIU_trmalloc(size_t a, int lineno, const char fname[])
{
void *retval;
MPIU_THREAD_CS_ENTER(MEMALLOC,);
@@ -75,7 +75,7 @@
MPIU_THREAD_CS_EXIT(MEMALLOC,);
}
-void *MPIU_trcalloc(unsigned int nelem, unsigned int elsize, int lineno, const char fname[])
+void *MPIU_trcalloc(size_t nelem, size_t elsize, int lineno, const char fname[])
{
void *retval;
MPIU_THREAD_CS_ENTER(MEMALLOC,);
@@ -84,7 +84,7 @@
return retval;
}
-void *MPIU_trrealloc(void *p, int size, int lineno, const char fname[])
+void *MPIU_trrealloc(void *p, size_t size, int lineno, const char fname[])
{
void *retval;
MPIU_THREAD_CS_ENTER(MEMALLOC,);
@@ -102,7 +102,7 @@
return retval;
}
-void MPIU_TrSetMaxMem(int size)
+void MPIU_TrSetMaxMem(size_t size)
{
MPIU_THREAD_CS_ENTER(MEMALLOC,);
MPL_TrSetMaxMem(size);
Modified: mpich2/trunk/src/util/procmap/local_proc.c
===================================================================
--- mpich2/trunk/src/util/procmap/local_proc.c 2012-12-11 04:25:54 UTC (rev 10758)
+++ mpich2/trunk/src/util/procmap/local_proc.c 2012-12-11 16:09:42 UTC (rev 10759)
@@ -84,6 +84,8 @@
node to the list. */
/* these two will be realloc'ed later to the appropriate size (currently unknown) */
+ /* FIXME: realloc doesn't guarantee that the allocated area will be
+ shrunk - so using realloc is not an appropriate strategy. */
MPIU_CHKPMEM_MALLOC (external_ranks, int *, sizeof(int) * comm->remote_size, mpi_errno, "external_ranks");
MPIU_CHKPMEM_MALLOC (local_ranks, int *, sizeof(int) * comm->remote_size, mpi_errno, "local_ranks");
More information about the commits
mailing list