From: Ivan Maidanski Date: Wed, 26 Oct 2016 08:13:29 +0000 (+0300) Subject: Eliminate 'suspicious pointer subtraction' cppcheck warning (gc_cpp) X-Git-Tag: v8.0.0~1071 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c6a48c396c4093945ef0c2978f5ea63a4ef2042c;p=platform%2Fupstream%2Flibgc.git Eliminate 'suspicious pointer subtraction' cppcheck warning (gc_cpp) * include/gc_cpp.h (gc_cleanup::gc_cleanup): Define this_ptr void pointer; use this_ptr instead of this keyword to outline that the pointer subtraction is intentional (i.e., "this->" was not intended). --- diff --git a/include/gc_cpp.h b/include/gc_cpp.h index b0ab260..9110633 100644 --- a/include/gc_cpp.h +++ b/include/gc_cpp.h @@ -428,11 +428,12 @@ inline gc_cleanup::gc_cleanup() { GC_finalization_proc oldProc; void* oldData; - void* base = GC_base((void*) this); + void* this_ptr = (void*)this; + void* base = GC_base(this_ptr); if (base != 0) { // Don't call the debug version, since this is a real base address. GC_register_finalizer_ignore_self(base, (GC_finalization_proc) cleanup, - (void*) ((char*) this - (char*) base), + (void*)((char*)this_ptr - (char*)base), &oldProc, &oldData); if (oldProc != 0) { GC_register_finalizer_ignore_self(base, oldProc, oldData, 0, 0);