From: Ivan Maidanski Date: Mon, 17 Oct 2016 07:53:19 +0000 (+0300) Subject: Workaround more 'void pointers in calculations' cppcheck warnings X-Git-Tag: v8.0.0~1108 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=957da90c6ff8084c48b7c8e3b4bcf6ecc83fb1b9;p=platform%2Fupstream%2Flibgc.git Workaround more 'void pointers in calculations' cppcheck warnings * include/new_gc_alloc.h (single_client_gc_alloc_template::allocate, single_client_gc_alloc_template::ptr_free_allocate, single_client_gc_alloc_template::deallocate, single_client_gc_alloc_template::ptr_free_deallocate, single_client_traceable_alloc_template::allocate, single_client_traceable_alloc_template::ptr_free_allocate, single_client_traceable_alloc_template::deallocate, single_client_traceable_alloc_template::ptr_free_deallocate): Replace GC_Xobjfreelist_ptr+nwords with &GC_Xobjfreelist_ptr[nwords]. * reclaim.c (GC_start_reclaim): Replace fop++ with (*(word**)&fop)++. * thread_local_alloc.c (return_freelists): Replace gfl+i with &gfl[i]. --- diff --git a/include/new_gc_alloc.h b/include/new_gc_alloc.h index a857947..9d00cff 100644 --- a/include/new_gc_alloc.h +++ b/include/new_gc_alloc.h @@ -190,8 +190,9 @@ class single_client_gc_alloc_template { void * op; if (n > GC_max_fast_bytes) return GC_malloc(n); - flh = GC_objfreelist_ptr + nwords; - if (0 == (op = *flh)) { + flh = &GC_objfreelist_ptr[nwords]; + op = *flh; + if (0 == op) { return GC_aux::GC_out_of_line_malloc(nwords, GC_NORMAL); } *flh = GC_obj_link(op); @@ -205,8 +206,9 @@ class single_client_gc_alloc_template { void * op; if (n > GC_max_fast_bytes) return GC_malloc_atomic(n); - flh = GC_aobjfreelist_ptr + nwords; - if (0 == (op = *flh)) { + flh = &GC_aobjfreelist_ptr[nwords]; + op = *flh; + if (0 == op) { return GC_aux::GC_out_of_line_malloc(nwords, GC_PTRFREE); } *flh = GC_obj_link(op); @@ -219,7 +221,8 @@ class single_client_gc_alloc_template { GC_free(p); } else { size_t nwords = GC_round_up(n); - void ** flh = GC_objfreelist_ptr + nwords; + void ** flh = &GC_objfreelist_ptr[nwords]; + GC_obj_link(p) = *flh; memset(reinterpret_cast(p) + GC_bytes_per_word, 0, GC_bytes_per_word * (nwords - 1)); @@ -233,7 +236,8 @@ class single_client_gc_alloc_template { GC_free(p); } else { size_t nwords = GC_round_up(n); - void ** flh = GC_aobjfreelist_ptr + nwords; + void ** flh = &GC_aobjfreelist_ptr[nwords]; + GC_obj_link(p) = *flh; *flh = p; GC_aux::GC_bytes_recently_freed += nwords * GC_bytes_per_word; @@ -254,8 +258,9 @@ class single_client_traceable_alloc_template { void * op; if (n > GC_max_fast_bytes) return GC_malloc_uncollectable(n); - flh = GC_uobjfreelist_ptr + nwords; - if (0 == (op = *flh)) { + flh = &GC_uobjfreelist_ptr[nwords]; + op = *flh; + if (0 == op) { return GC_aux::GC_out_of_line_malloc(nwords, GC_UNCOLLECTABLE); } *flh = GC_obj_link(op); @@ -270,8 +275,9 @@ class single_client_traceable_alloc_template { void * op; if (n > GC_max_fast_bytes) return GC_malloc_atomic_uncollectable(n); - flh = GC_auobjfreelist_ptr + nwords; - if (0 == (op = *flh)) { + flh = &GC_auobjfreelist_ptr[nwords]; + op = *flh; + if (0 == op) { return GC_aux::GC_out_of_line_malloc(nwords, GC_AUNCOLLECTABLE); } *flh = GC_obj_link(op); @@ -285,7 +291,8 @@ class single_client_traceable_alloc_template { GC_free(p); } else { size_t nwords = GC_round_up_uncollectable(n); - void ** flh = GC_uobjfreelist_ptr + nwords; + void ** flh = &GC_uobjfreelist_ptr[nwords]; + GC_obj_link(p) = *flh; *flh = p; GC_aux::GC_uncollectable_bytes_recently_freed += @@ -298,7 +305,8 @@ class single_client_traceable_alloc_template { GC_free(p); } else { size_t nwords = GC_round_up_uncollectable(n); - void ** flh = GC_auobjfreelist_ptr + nwords; + void ** flh = &GC_auobjfreelist_ptr[nwords]; + GC_obj_link(p) = *flh; *flh = p; GC_aux::GC_uncollectable_bytes_recently_freed += diff --git a/reclaim.c b/reclaim.c index e266e8b..2a113e7 100644 --- a/reclaim.c +++ b/reclaim.c @@ -625,7 +625,7 @@ GC_INNER void GC_start_reclaim(GC_bool report_if_found) void **lim = &(GC_obj_kinds[kind].ok_freelist[MAXOBJGRANULES+1]); for (fop = GC_obj_kinds[kind].ok_freelist; - (word)fop < (word)lim; fop++) { + (word)fop < (word)lim; (*(word **)&fop)++) { if (*fop != 0) { if (should_clobber) { GC_clear_fl_links(fop); diff --git a/thread_local_alloc.c b/thread_local_alloc.c index 01e23b4..26b7699 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -61,7 +61,7 @@ static void return_freelists(void **fl, void **gfl) for (i = 1; i < TINY_FREELISTS; ++i) { if ((word)(fl[i]) >= HBLKSIZE) { - return_single_freelist(fl[i], gfl+i); + return_single_freelist(fl[i], &gfl[i]); } /* Clear fl[i], since the thread structure may hang around. */ /* Do it in a way that is likely to trap if we access it. */ @@ -72,7 +72,7 @@ static void return_freelists(void **fl, void **gfl) if (fl[0] == ERROR_FL) return; # endif if ((word)(fl[0]) >= HBLKSIZE) { - return_single_freelist(fl[0], gfl+1); + return_single_freelist(fl[0], &gfl[1]); } }