From: Florian Krohm Date: Thu, 18 Sep 2014 18:35:47 +0000 (+0000) Subject: Fix a few casts that dropped type qualifiers. As pointed out by X-Git-Tag: svn/VALGRIND_3_11_0~978 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1f50bd18d454f240230dbf0d8e0648f999db2de;p=thirdparty%2Fvalgrind.git Fix a few casts that dropped type qualifiers. As pointed out by -Wcast-qual. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14554 --- diff --git a/coregrind/m_debuginfo/image.c b/coregrind/m_debuginfo/image.c index dfe077fd45..a289f441b1 100644 --- a/coregrind/m_debuginfo/image.c +++ b/coregrind/m_debuginfo/image.c @@ -877,7 +877,7 @@ Int ML_(img_strcmp_c)(DiImage* img, DiOffT off1, const HChar* str2) ensure_valid(img, off1, 1, "ML_(img_strcmp_c)"); while (True) { UChar c1 = get(img, off1); - UChar c2 = *(UChar*)str2; + UChar c2 = *(const UChar*)str2; if (c1 < c2) return -1; if (c1 > c2) return 1; if (c1 == 0) return 0; diff --git a/coregrind/m_debuginfo/storage.c b/coregrind/m_debuginfo/storage.c index 3d8a13f0cb..ab570be4a3 100644 --- a/coregrind/m_debuginfo/storage.c +++ b/coregrind/m_debuginfo/storage.c @@ -1858,8 +1858,8 @@ static void canonicaliseSymtab ( struct _DebugInfo* di ) static DiLoc* sorting_loctab = NULL; static Int compare_DiLoc_via_ix ( const void* va, const void* vb ) { - const DiLoc* a = &sorting_loctab[*(UInt*)va]; - const DiLoc* b = &sorting_loctab[*(UInt*)vb]; + const DiLoc* a = &sorting_loctab[*(const UInt*)va]; + const DiLoc* b = &sorting_loctab[*(const UInt*)vb]; if (a->addr < b->addr) return -1; if (a->addr > b->addr) return 1; return 0; diff --git a/coregrind/m_deduppoolalloc.c b/coregrind/m_deduppoolalloc.c index 916f7e8263..53d68535e7 100644 --- a/coregrind/m_deduppoolalloc.c +++ b/coregrind/m_deduppoolalloc.c @@ -249,10 +249,10 @@ void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa, SizeT eltSzB, const void *elt) // (A lot can be 10% of the elements colliding, even on // small nr of elements such as 10_000). ht_elt.key = VG_(adler32) (0, NULL, 0); - ht_elt.key = VG_(adler32) (ht_elt.key, (UChar*)elt, eltSzB); + ht_elt.key = VG_(adler32) (ht_elt.key, elt, eltSzB); ht_elt.eltSzB = eltSzB; - ht_elt.elt = (UChar*) elt; + ht_elt.elt = (void *)elt; ht_ins = VG_(HT_gen_lookup) (ddpa->ht_elements, &ht_elt, cmp_pool_elt); if (ht_ins) @@ -282,9 +282,9 @@ void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa, SizeT eltSzB, const void *elt) static __inline__ UInt elt2nr (DedupPoolAlloc *ddpa, const void *dedup_elt) { - vg_assert ((UChar*)dedup_elt >= ddpa->curpool - && (UChar*)dedup_elt < ddpa->curpool_free); - return 1 + ((UChar*)dedup_elt - ddpa->curpool) + vg_assert (dedup_elt >= (const void *)ddpa->curpool + && dedup_elt < (const void *)ddpa->curpool_free); + return 1 + ((const UChar*)dedup_elt - (const UChar *)ddpa->curpool) / VG_ROUNDUP(ddpa->fixedSzb, ddpa->eltAlign); } diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index 14d340ae0d..342fbe6bb8 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -696,7 +696,7 @@ void VG_(scheduler_init_phase2) ( ThreadId tid_main, guest state, its two copies, and the spill area. In short, all 4 areas must have a 16-aligned size and be 16-aligned, and placed back-to-back. */ -static void do_pre_run_checks ( ThreadState* tst ) +static void do_pre_run_checks ( volatile ThreadState* tst ) { Addr a_vex = (Addr) & tst->arch.vex; Addr a_vexsh1 = (Addr) & tst->arch.vex_shadow1; @@ -859,7 +859,7 @@ void run_thread_for_a_while ( /*OUT*/HWord* two_words, vg_assert(*dispatchCtrP > 0); tst = VG_(get_ThreadState)(tid); - do_pre_run_checks( (ThreadState*)tst ); + do_pre_run_checks( tst ); /* end Paranoia */ /* Futz with the XIndir stats counters. */ @@ -934,7 +934,7 @@ void run_thread_for_a_while ( /*OUT*/HWord* two_words, jumped, VG_(disp_run_translations)( two_words, - (void*)&tst->arch.vex, + (volatile void*)&tst->arch.vex, host_code_addr ) ); diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 44564aea45..79d9320f85 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -673,7 +673,8 @@ void inet6_format(HChar *s, const UChar ip[16]) static const unsigned char V4mappedprefix[12] = {0,0,0,0,0,0,0,0,0,0,0xff,0xff}; if (!VG_(memcmp)(ip, V4mappedprefix, 12)) { - struct vki_in_addr *sin_addr = (struct vki_in_addr *)(ip + 12); + const struct vki_in_addr *sin_addr = + (const struct vki_in_addr *)(ip + 12); UInt addr = VG_(ntohl)(sin_addr->s_addr); VG_(sprintf)(s, "::ffff:%u.%u.%u.%u", diff --git a/coregrind/pub_core_dispatch.h b/coregrind/pub_core_dispatch.h index 1193fad68c..9e08e9d46a 100644 --- a/coregrind/pub_core_dispatch.h +++ b/coregrind/pub_core_dispatch.h @@ -62,7 +62,7 @@ where we have to return a chain-me request. */ void VG_(disp_run_translations)( HWord* two_words, - void* guest_state, + volatile void* guest_state, Addr host_addr ); /* We need to know addresses of the continuation-point (cp_) labels so diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c index 71bd40288b..fb9963a476 100644 --- a/helgrind/hg_intercepts.c +++ b/helgrind/hg_intercepts.c @@ -159,8 +159,8 @@ __attribute__((noinline)) static int my_memcmp ( const void* ptr1, const void* ptr2, size_t size) { - unsigned char* uchar_ptr1 = (unsigned char*) ptr1; - unsigned char* uchar_ptr2 = (unsigned char*) ptr2; + const unsigned char* uchar_ptr1 = (const unsigned char*) ptr1; + const unsigned char* uchar_ptr2 = (const unsigned char*) ptr2; size_t i; for (i = 0; i < size; ++i) { if (uchar_ptr1[i] != uchar_ptr2[i])