[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.0.4-161-g058286b

mysql vizuser noreply at mpich.org
Tue May 7 15:37:57 CDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".

The branch, master has been updated
       via  058286b1b5308c965c4790878a49dbb3ffa1fcdf (commit)
      from  bbb5a3c4b26f9642fc1dec6c96c9c7ca1f695f17 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/058286b1b5308c965c4790878a49dbb3ffa1fcdf

commit 058286b1b5308c965c4790878a49dbb3ffa1fcdf
Author: William Gropp <wgropp at illinois.edu>
Date:   Tue May 7 14:25:13 2013 -0500

    Add casts to suppress false warnings about alignment issues.

diff --git a/src/mpl/src/mpltrmem.c b/src/mpl/src/mpltrmem.c
index dc455ff..cac9f12 100644
--- a/src/mpl/src/mpltrmem.c
+++ b/src/mpl/src/mpltrmem.c
@@ -233,7 +233,8 @@ void *MPL_trmalloc(size_t a, int lineno, const char fname[])
         goto fn_exit;
 
     memset(new, TRDefaultByte, nsize + sizeof(TrSPACE) + sizeof(unsigned long));
-    head = (TRSPACE *) new;
+    /* Cast to (void*) to avoid false warnings about alignment issues */
+    head = (TRSPACE *) (void *)new;
     new += sizeof(TrSPACE);
 
     if (TRhead[0] != TRHEAD_PRESENTINAL || TRhead[2] != TRHEAD_POSTSENTINAL) {
@@ -256,7 +257,8 @@ void *MPL_trmalloc(size_t a, int lineno, const char fname[])
     MPL_strncpy(head->fname, fname, TR_FNAME_LEN);
     head->fname[TR_FNAME_LEN - 1] = 0;
     head->cookie = COOKIE_VALUE;
-    nend = (unsigned long *) (new + nsize);
+    /* Cast to (void*) to avoid false warning about alignment */
+    nend = (unsigned long *) (void *) (new + nsize);
     nend[0] = COOKIE_VALUE;
 
     allocated += nsize;
@@ -309,7 +311,9 @@ void MPL_trfree(void *a_ptr, int line, const char file[])
             return;
     }
 
-    head = (TRSPACE *) ( ((char *)a_ptr) - sizeof(TrSPACE) );
+    /* Alignment guaranteed by the way a_ptr was allocated.  Use
+       (void *) cast to suppress false warning about alignment issues */
+    head = (TRSPACE *) (void *) ( ((char *)a_ptr) - sizeof(TrSPACE) );
 
     /* We need to mark the memory as defined before performing our own error
      * checks or valgrind will flag the trfree function as erroneous.  The real
@@ -328,7 +332,8 @@ void MPL_trfree(void *a_ptr, int line, const char file[])
                          "called in %s at line %d\n", world_rank, hexstring, file, line);
         return;
     }
-    nend = (unsigned long *) ((char *)a_ptr + head->size);
+    /* Cast to (void*) to avoid false warning about alignment */
+    nend = (unsigned long *) (void *) ((char *)a_ptr + head->size);
 /* Check that nend is properly aligned */
     if ((sizeof(long) == 4 && ((long) nend & 0x3) != 0) ||
         (sizeof(long) == 8 && ((long) nend & 0x7) != 0)) {
@@ -506,7 +511,8 @@ int MPL_trvalid2(const char str[], int line, const char file[] )
            the full header is padded to ensure correct byte alignment with
            the data */
         a    = (char *)( (TrSPACE *)head + 1 );
-        nend = (unsigned long *) (a + head->size);
+        /* Cast to (void*) to avoid false warning about alignment */
+        nend = (unsigned long *) (void *)(a + head->size);
 
         /* mark defined before accessing nend contents */
         MPL_VG_MAKE_MEM_DEFINED(nend, sizeof(*nend));
@@ -785,9 +791,9 @@ void *MPL_trrealloc(void *p, size_t size, int lineno, const char fname[])
     TRSPACE *head = 0;
     char hexstring[MAX_ADDRESS_CHARS];
 
-/* We should really use the size of the old block... */
+    /* We should really use the size of the old block... */
     if (p) {
-        head = (TRSPACE *) ((char *)p - sizeof(TrSPACE));
+        head = (TRSPACE *) (void*) ((char *)p - sizeof(TrSPACE));
         MPL_VG_MAKE_MEM_DEFINED(head, sizeof(*head));   /* mark defined before accessing contents */
         if (head->cookie != COOKIE_VALUE) {
             /* Damaged header */
diff --git a/src/util/mem/handlemem.c b/src/util/mem/handlemem.c
index 61ed867..7894746 100644
--- a/src/util/mem/handlemem.c
+++ b/src/util/mem/handlemem.c
@@ -157,7 +157,9 @@ void *MPIU_Handle_direct_init(void *direct,
 
     for (i=0; i<direct_size; i++) {
 	/* printf( "Adding %p in %d\n", ptr, handle_type ); */
-	hptr = (MPIU_Handle_common *)ptr;
+        /* First cast to (void*) to avoid false warnings about alignment
+           (consider that a requirement of the input parameters) */
+	hptr = (MPIU_Handle_common *)(void *)ptr;
 	ptr  = ptr + obj_size;
 	hptr->next = ptr;
 	hptr->handle = ((unsigned)HANDLE_KIND_DIRECT << HANDLE_KIND_SHIFT) | 
@@ -209,7 +211,8 @@ static void *MPIU_Handle_indirect_init( void *(**indirect)[],
     }
     ptr = (char *)block_ptr;
     for (i=0; i<indirect_num_indices; i++) {
-	hptr       = (MPIU_Handle_common *)ptr;
+        /* Cast to (void*) to avoid false warning about alignment */
+	hptr       = (MPIU_Handle_common *)(void*)ptr;
 	ptr        = ptr + obj_size;
 	hptr->next = ptr;
 	hptr->handle   = ((unsigned)HANDLE_KIND_INDIRECT << HANDLE_KIND_SHIFT) | 

-----------------------------------------------------------------------

Summary of changes:
 src/mpl/src/mpltrmem.c   |   20 +++++++++++++-------
 src/util/mem/handlemem.c |    7 +++++--
 2 files changed, 18 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list