Valgrind: r16348 - /trunk/coregrind/m_libcbase.c

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Valgrind: r16348 - /trunk/coregrind/m_libcbase.c

svn-2
Author: iraisr
Date: Wed May 10 06:38:57 2017
New Revision: 16348

Log:
Reduce the number of compiler warnings on MIPS platforms.
Patch by: Aleksandar Rikalo <[hidden email]>
Partially fixes BZ#370028.

Modified:
    trunk/coregrind/m_libcbase.c

Modified: trunk/coregrind/m_libcbase.c
==============================================================================
--- trunk/coregrind/m_libcbase.c (original)
+++ trunk/coregrind/m_libcbase.c Wed May 10 06:38:57 2017
@@ -753,24 +753,26 @@
       d++;
       sz--;
    }
+   UInt* d4 = ASSUME_ALIGNED(UInt*, d);
    if (sz == 0)
       return destV;
    c4 = uc;
    c4 |= (c4 << 8);
    c4 |= (c4 << 16);
    while (sz >= 16) {
-      ((UInt*)d)[0] = c4;
-      ((UInt*)d)[1] = c4;
-      ((UInt*)d)[2] = c4;
-      ((UInt*)d)[3] = c4;
-      d += 16;
+      d4[0] = c4;
+      d4[1] = c4;
+      d4[2] = c4;
+      d4[3] = c4;
+      d4 += 4;
       sz -= 16;
    }
    while (sz >= 4) {
-      ((UInt*)d)[0] = c4;
-      d += 4;
+      d4[0] = c4;
+      d4 += 1;
       sz -= 4;
    }
+   d = (UChar*) d4;
    while (sz >= 1) {
       d[0] = c;
       d++;
@@ -824,7 +826,8 @@
 #define BM_SWAP(a, b)                                    \
    swaptype != 0                                         \
       ? bm_swapfunc(a, b, es, swaptype)                  \
-      : (void)BM_EXCH(*(Word*)(a), *(Word*)(b), t)
+      : (void)BM_EXCH(*ASSUME_ALIGNED(Word*, (a)),       \
+                      *ASSUME_ALIGNED(Word*, (b)), t)
 
 #define BM_VECSWAP(a, b, n)                              \
    if (n > 0) bm_swapfunc(a, b, n, swaptype)
@@ -833,7 +836,7 @@
    if (swaptype != 0)                                    \
       pv = a, BM_SWAP(pv, pm);                           \
    else                                                  \
-      pv = (Char*)&v, v = *(Word*)pm
+      pv = (Char*)&v, v = *ASSUME_ALIGNED(Word*, pm)
 
 static Char* bm_med3 ( Char* a, Char* b, Char* c,
                        Int (*cmp)(const void*, const void*) ) {
@@ -848,7 +851,7 @@
       Word t;
       for ( ; n > 0; a += sizeof(Word), b += sizeof(Word),
                                         n -= sizeof(Word))
-         BM_EXCH(*(Word*)a, *(Word*)b, t);
+         BM_EXCH(*ASSUME_ALIGNED(Word*, a), *ASSUME_ALIGNED(Word*, b), t);
    } else {
       Char t;
       for ( ; n > 0; a += 1, b += 1, n -= 1)


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers