]> granicus.if.org Git - gc/log
gc
8 years agoSuppress 'tainted string passed to vulnerable operation' false defects
Ivan Maidanski [Tue, 15 Nov 2016 07:48:31 +0000 (10:48 +0300)]
Suppress 'tainted string passed to vulnerable operation' false defects

* include/private/gc_priv.h (TRUSTED_STRING): New tagging macro; add
comment.
* misc.c (GC_init): Process the result of GETENV("GC_LOG_FILE") by
TRUSTED_STRING.
* tools/if_mach.c (main): Process argv[3] by TRUSTED_STRING (before
passing the string to execvp).
* tools/if_not_there.c (main): Declare "fname" local variable;
process argv[1] and argv[2] by TRUSTED_STRING (before passing the
strings to fopen/opendir and execvp, respectively).

8 years agoWorkaround 'function is never used' cppcheck style warnings
Ivan Maidanski [Thu, 17 Nov 2016 08:40:34 +0000 (11:40 +0300)]
Workaround 'function is never used' cppcheck style warnings
(Cherry-pick commits c5d4ef9857bb8a from 'master' branch.)

* tests/test.c [DBG_HDRS_ALL || MAKE_BACK_GRAPH] (GC_DEBUG): Do not
define if CPPCHECK.
* tests/test.c (NO_TEST_HANDLE_FORK): Define also if not GC_PTHREADS;
do not define if CPPCHECK.
* tests/test.c: Include gc_inline.h, javaxfc.h if CPPCHECK.
* tests/test.c [CPPCHECK] (UNTESTED): New macro.
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS] (main): Call
GC_noop1(&WinMain) if CPPCHECK and not NO_WINMAIN_ENTRY; call
GC_noop1(&Init) if CPPCHECK and RTEMS.
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK]
(main): Call UNTESTED() for GC_debug_end_stubborn_change,
GC_debug_generic_or_special_malloc, GC_debug_register_displacement,
GC_post_incr, GC_pre_incr, GC_debug_gcj_malloc, GC_amiga_get_mem,
GC_amiga_set_toany, GC_MacTemporaryNewPtr, GetFileLineFromStack,
GetModuleNameFromStack, GetSymbolNameFromStack, GC_get_bytes_since_gc,
GC_get_dont_expand, GC_get_dont_precollect, GC_get_finalize_on_demand,
GC_get_finalizer_notifier, GC_get_find_leak,
GC_get_force_unmap_on_gcollect, GC_get_free_bytes,
GC_get_free_space_divisor, GC_get_full_freq, GC_get_java_finalization,
GC_get_max_retries, GC_get_no_dls, GC_get_non_gc_bytes,
GC_get_on_collection_event, GC_get_on_heap_resize,
GC_get_pages_executable, GC_get_push_other_roots, GC_get_start_callback,
GC_get_stop_func, GC_get_time_limit, GC_get_warn_proc, GC_is_disabled,
GC_set_dont_precollect, GC_set_finalize_on_demand,
GC_set_finalizer_notifier, GC_set_free_space_divisor, GC_set_full_freq,
GC_set_java_finalization, GC_set_max_retries, GC_set_no_dls,
GC_set_non_gc_bytes, GC_set_on_collection_event, GC_set_on_heap_resize,
GC_set_oom_fn, GC_set_pages_executable, GC_set_push_other_roots,
GC_set_start_callback, GC_set_stop_func, GC_set_time_limit,
GC_malloc_explicitly_typed_ignore_off_page, GC_debug_change_stubborn,
GC_debug_strndup, GC_strndup, GC_posix_memalign, GC_new_free_list,
GC_new_kind, GC_new_proc, GC_clear_roots, GC_exclude_static_roots,
GC_expand_hp, GC_register_describe_type_fn,
GC_register_has_static_roots_callback, GC_get_abort_func,
GC_set_abort_func, GC_gcj_malloc_ignore_off_page, GC_dump_regions,
GC_is_tmp_root, GC_print_free_list, GC_print_trace,
GC_debug_register_finalizer_unreachable, GC_get_await_finalize_proc,
GC_register_disappearing_link, GC_set_await_finalize_proc,
GC_should_invoke_finalizers, GC_finalize_all, GC_dump_finalization,
GC_get_toggleref_func, GC_set_toggleref_func, GC_toggleref_add,
GC_set_log_fd, GC_allow_register_threads, GC_get_on_thread_event,
GC_register_altstack, GC_set_on_thread_event, strndup, strdup,
realloc, GC_wcsdup, GC_debug_wcsdup.
* tests/test.c [!NO_WINMAIN_ENTRY] (WinMain): Call GC_noop1(&WinMain)
if CPPCHECK.
* tests/test.c [!PCR && GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK]
(main): Call UNTESTED() for GC_ExitThread, GC_beginthreadex,
GC_endthreadex.
* tests/test.c [PCR] (test): Call GC_noop1(&PCR_GC_Run),
GC_noop1(&PCR_GC_Setup), GC_noop1((word)&test) if CPPCHECK.
* tests/test.c [!PCR && !GC_WIN32_THREADS && GC_PTHREADS && CPPCHECK]
(main): Call UNTESTED() for GC_pthread_detach, GC_dlopen,
GC_pthread_cancel, GC_pthread_exit, GC_pthread_sigmask,
GC_set_suspend_signal, GC_set_thr_restart_signal.

8 years agoWorkaround 'GC_DllMain is never used' cppcheck style warning
Ivan Maidanski [Thu, 17 Nov 2016 07:13:12 +0000 (10:13 +0300)]
Workaround 'GC_DllMain is never used' cppcheck style warning

* win32_threads.c [GC_WIN32_THREADS] (GC_init_parallel): Call
GC_noop1(&GC_DllMain) if CPPCHECK (and not GC_NO_THREADS_DISCOVERY).

8 years agoWorkaround 'WinMain() is never used' cppcheck false warning
Ivan Maidanski [Thu, 17 Nov 2016 07:06:22 +0000 (10:06 +0300)]
Workaround 'WinMain() is never used' cppcheck false warning

* tests/test_cpp.cc [!NO_WINMAIN_ENTRY] (WinMain): Call
GC_noop1(&WinMain) if CPPCHECK.

8 years agoWorkaround 'operator delete[]/new[] never used' cppcheck false warning
Ivan Maidanski [Thu, 17 Nov 2016 07:02:15 +0000 (10:02 +0300)]
Workaround 'operator delete[]/new[] never used' cppcheck false warning

* gc_cpp.cc [!_MSC_VER && GC_OPERATOR_NEW_ARRAY] (operator new[],
operator delete[]): Do not define if CPPCHECK.

8 years agoAdd testing of new[]/delete[] (test_cpp)
Ivan Maidanski [Tue, 15 Nov 2016 22:13:30 +0000 (01:13 +0300)]
Add testing of new[]/delete[] (test_cpp)

* tests/test_cpp.cc (main): Add test case for new[] and delete[].

8 years agoEliminate 'GC_record_fault is never used' cppcheck style warning
Ivan Maidanski [Mon, 14 Nov 2016 07:58:26 +0000 (10:58 +0300)]
Eliminate 'GC_record_fault is never used' cppcheck style warning

* checksums.c [CHECKSUMS] (GC_record_fault): Do not define unless
MPROTECT_VDB and not DARWIN.
* os_dep.c [MPROTECT_VDB && CHECKSUMS] (GC_record_fault): Do not
declare if DARWIN.

8 years agoDo not define amiga_get_mem, MacTemporaryNewPtr unless really used (extra)
Ivan Maidanski [Mon, 14 Nov 2016 16:52:35 +0000 (19:52 +0300)]
Do not define amiga_get_mem, MacTemporaryNewPtr unless really used (extra)

* extra/AmigaOS.c (GC_amiga_get_mem): Define only if GC_AMIGA_FASTALLOC.
* extra/MacOS.c (TemporaryMemoryBlock, TemporaryMemoryHandle,
struct TemporaryMemoryBlock, theTemporaryMemory,
GC_MacTemporaryNewPtr, perform_final_collection,
GC_MacFreeTemporaryMemory): Define only if USE_TEMPORARY_MEMORY.

8 years agoChange no-argument functions declaration style to ANSI C (extra files)
Ivan Maidanski [Mon, 14 Nov 2016 07:39:54 +0000 (10:39 +0300)]
Change no-argument functions declaration style to ANSI C (extra files)

* extra/AmigaOS.c (GC_get_main_stack_base, GC_register_data_segments):
Replace "()" to "(void)" in the function prototype.
* extra/MacOS.c (GC_MacGetDataStart, perform_final_collection,
GC_MacFreeTemporaryMemory, GC_MacGetDataEnd): Likewise.
* extra/msvc_dbg.c (GetSymHandle): Likewise.

8 years agoReplace C++ style comments to C ones, remove commented out code (extra)
Ivan Maidanski [Mon, 14 Nov 2016 07:12:32 +0000 (10:12 +0300)]
Replace C++ style comments to C ones, remove commented out code (extra)

* extra/AmigaOS.c (GC_amiga_get_mem, GC_amiga_allocwrapper_any,
GC_amiga_allocwrapper_fast): Replace the style of comments from C++
to C.
* extra/MacOS.c (CodeZeroPtr, GC_MacTemporaryNewPtr): Likewise.
* extra/Mac_files/MacOS_config.h: Likewise.
* extra/AmigaOS.c (GC_amiga_get_mem, GC_amiga_rec_alloc,
GC_amiga_allocwrapper_any, GC_amiga_allocwrapper_fast): Remove
commented out code.
* extra/Mac_files/MacOS_config.h: Likewise.

8 years agoFix register_finalizer call in disclaim_bench for GC_DEBUG
Ivan Maidanski [Tue, 15 Nov 2016 21:41:33 +0000 (00:41 +0300)]
Fix register_finalizer call in disclaim_bench for GC_DEBUG

* tests/disclaim_bench.c (testobj_new): Call
GC_REGISTER_FINALIZER_NO_ORDER instead of GC_register_finalizer_no_order.

8 years agoEliminate 'function result not used' code defect in GC_mark_local
Ivan Maidanski [Wed, 16 Nov 2016 07:34:08 +0000 (10:34 +0300)]
Eliminate 'function result not used' code defect in GC_mark_local

* mark.c (GC_mark_local): Explicitly cast AO_compare_and_swap result to
void (to outline that the result is unused intentionally).

8 years agoFix threaded tests runtime crash if GC_NO_THREAD_REDIRECTS supplied
Ivan Maidanski [Sat, 19 Nov 2016 17:16:27 +0000 (20:16 +0300)]
Fix threaded tests runtime crash if GC_NO_THREAD_REDIRECTS supplied

* tests/disclaim_test.c (GC_NO_THREAD_REDIRECTS): Undefine (before
include "gc*.h").
* tests/test.c (GC_NO_THREAD_REDIRECTS): Likewise.
* tests/thread_leak_test.c (GC_NO_THREAD_REDIRECTS): Likewise.

8 years agoFix initsecondarythread_test runtime failure if GC compiled w/o threads
Ivan Maidanski [Sat, 19 Nov 2016 17:02:25 +0000 (20:02 +0300)]
Fix initsecondarythread_test runtime failure if GC compiled w/o threads

Now the test should fail during its linking if a single-threaded libgc
is used (this should not happen in case of configure/make).

* tests/initsecondarythread.c (main): Call GC_get_parallel() to ensure
that libgc is compiled with the threads support.

8 years agoFix 'incompatible ptr-to-int conversion' compiler warning in push_all_stack
Ivan Maidanski [Thu, 17 Nov 2016 06:56:12 +0000 (09:56 +0300)]
Fix 'incompatible ptr-to-int conversion' compiler warning in push_all_stack

* mark_rts.c [TRACE_BUF] (GC_push_all_stack_partially_eager): Add
explicit cast to word for GC_add_trace_entry bottom/top arguments.

8 years agoFix GC_jmp_buf multiple definition
Ivan Maidanski [Tue, 15 Nov 2016 08:35:28 +0000 (11:35 +0300)]
Fix GC_jmp_buf multiple definition

This error occurs only if "-fno-common" gcc option is specified.

* include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES && THREADS
|| NEED_FIND_LIMIT] (GC_jmp_buf): Replace variable definition with
a declaration (as GC_EXTERN).
* os_dep.c [USE_PROC_FOR_LIBRARIES && THREADS || NEED_FIND_LIMIT]
(GC_jmp_buf): Define global variable (as GC_INNER).

8 years agoEnsure oom_fn callback executed on out-of-memory in calloc
Ivan Maidanski [Fri, 18 Nov 2016 14:16:32 +0000 (17:16 +0300)]
Ensure oom_fn callback executed on out-of-memory in calloc
(fix commits e10c1eb4e1a6f9)

* malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER] (calloc):
Call oom_fn(SIZE_MAX) (instead of returning NULL) if n*lb overflows.
* typd_mlc.c (GC_calloc_explicitly_typed): Likewise.
* typd_mlc.c (GC_calloc_explicitly_typed): If register_disappearing_link
failed due to lack of memory then call oom_fn(lb) instead of
GC_malloc(lb); update comment.

8 years agoFix assertion violation in GC_repeat_read if --enable-redirect-malloc
Ivan Maidanski [Sat, 19 Nov 2016 17:37:04 +0000 (20:37 +0300)]
Fix assertion violation in GC_repeat_read if --enable-redirect-malloc

* malloc.c [REDIRECT_MALLOC && GC_LINUX_THREADS] (GC_init_lib_bounds):
Declare cancel_state local variable; DISABLE_CANCEL for GC_text_mapping
(because GC_repeat_read expects the cancellation state off); call
RESTORE_CANCEL on return.

8 years agoAdjust GC_memalign comment
Ivan Maidanski [Fri, 18 Nov 2016 14:23:00 +0000 (17:23 +0300)]
Adjust GC_memalign comment

* mallocx.c (GC_memalign): Place the comment about debug variant near
the function; remove note about the test/integration status.

8 years agoChangeLog: add information that CVE-2016-9427 is fixed in v7.2h+
Ivan Maidanski [Fri, 18 Nov 2016 19:23:51 +0000 (22:23 +0300)]
ChangeLog: add information that CVE-2016-9427 is fixed in v7.2h+

8 years agoFix assertion violation in mark_local checking GC_mark_stack_top
Ivan Maidanski [Thu, 17 Nov 2016 07:23:53 +0000 (10:23 +0300)]
Fix assertion violation in mark_local checking GC_mark_stack_top

* mark.c (GC_mark_local): Replace AO_load with AO_load_acquire in
the assertion comparing global_first_nonempty to GC_mark_stack_top.

8 years agoUpdate README to use autogen.sh on build from the source repository
Ivan Maidanski [Thu, 17 Nov 2016 06:38:55 +0000 (09:38 +0300)]
Update README to use autogen.sh on build from the source repository

* README.md (Installation and Portability): Replace autoreconf (and
automake) invocation with autogen.sh one; pass -j option to make.

8 years agoUpdate AUTHORS file (add Joshua Richardson)
Ivan Maidanski [Thu, 17 Nov 2016 06:33:20 +0000 (09:33 +0300)]
Update AUTHORS file (add Joshua Richardson)

8 years agoDocument configure 'syntax error' issue in README
Ivan Maidanski [Wed, 16 Nov 2016 09:05:43 +0000 (12:05 +0300)]
Document configure 'syntax error' issue in README

* README.md (Installation and Portability): Add information how to
avoid "syntax error near unexpected token ATOMIC_OPS" configure failure
(caused by lack of pkg.m4).

8 years agoFix potential integer overflow in GC_find_limit_* functions
Ivan Maidanski [Tue, 15 Nov 2016 12:25:54 +0000 (15:25 +0300)]
Fix potential integer overflow in GC_find_limit_* functions

* os_dep.c [OPENBSD] (GC_find_limit_openbsd, GC_skip_hole_openbsd): Add
assertion for the minimum value of bound; increment result by pgsz only
if no overflow is guaranteed.
* os_dep.c [USE_PROC_FOR_LIBRARIES && THREADS || NEED_FIND_LIMIT]
(GC_find_limit_with_bound): Add assertion for the minimum/maximum value
of bound; increment/decrement result by MIN_PAGE_SIZE only if no
overflow/underflow is guaranteed.

8 years agoUpdate ChangeLog file (v7.6 changes only)
Ivan Maidanski [Fri, 11 Nov 2016 22:23:43 +0000 (01:23 +0300)]
Update ChangeLog file (v7.6 changes only)

8 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Fri, 11 Nov 2016 21:50:21 +0000 (00:50 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(Cherry-pick commit 88c54c0 from 'release-7_4' branch.)

8 years agoAdd AppVeyor CI configuration
Andy Li [Sat, 6 Aug 2016 15:22:33 +0000 (23:22 +0800)]
Add AppVeyor CI configuration
(Cherry-pick commits af6bc0a2a0e60030bdd67 from 'master' branch.)

Note: builds version is set to 7.6.x

8 years agoExport GC_print_free_list()
Ivan Maidanski [Mon, 31 Oct 2016 07:09:10 +0000 (10:09 +0300)]
Export GC_print_free_list()

Note: this function is not used by GC itself.

* include/gc_inline.h (GC_print_free_list): New public API prototype.
* reclaim.c [!NO_DEBUGGING]: Include gc_inline.h (to check that
GC_print_free_list prototype matches the definition).
* reclaim.c [!NO_DEBUGGING] (GC_print_free_list): Define as public
(GC_API+GC_CALL); remove "ok" local variable; add assertions about kind
and sz_in_granules maximum values.

8 years agoEliminate duplicate log messages in GC_mark_from
Ivan Maidanski [Fri, 28 Oct 2016 08:45:48 +0000 (11:45 +0300)]
Eliminate duplicate log messages in GC_mark_from

This change also eliminates 'bad copy-paste' code defect in GC_mark_from.

* mark.c [ENABLE_TRACE] (GC_mark_from): Combine 2 logged messages
about "large section" and "splitting" into a single one;
replace "Tracing from" logged message with "small object" message
(which is not logged for large objects).

8 years agoEliminate redundant local variable in register_finalizer
Ivan Maidanski [Fri, 28 Oct 2016 08:29:22 +0000 (11:29 +0300)]
Eliminate redundant local variable in register_finalizer

The variable caused a report about a code defect which is a false
positive.

* finalize.c (GC_register_finalizer_inner): Remove "base" local
variable (use "obj" argument instead).

8 years agoEliminate 'printf format specifies type void*' GCC pedantic warnings
Ivan Maidanski [Thu, 20 Oct 2016 22:54:17 +0000 (01:54 +0300)]
Eliminate 'printf format specifies type void*' GCC pedantic warnings

Explicitly cast pointer arguments (passed to printf and ABORT_ARGn) to
void* to match %p format specifier.

* allchblk.c [!NO_DEBUGGING] (GC_dump_regions): Cast arguments to
void* those printf format specifier is %p.
* alloc.c [!NO_DEBUGGING] (GC_print_heap_sects): Likewise.
* backgraph.c [MAKE_BACK_GRAPH] (backwards_height): Likewise.
* blacklst.c (GC_default_print_heap_obj_proc): Likewise.
* blacklst.c [PRINT_BLACK_LIST] (GC_print_blacklisted_ptr): Likewise.
* cord/cordbscs.c (CORD_dump_inner): Likewise.
* darwin_stop_world.c [DEBUG_THREADS_EXTRA] (GC_FindTopOfStack):
Likewise.
* darwin_stop_world.c [DEBUG_THREADS] (GC_stack_range_for): Likewise.
* dbg_mlc.c (GC_print_obj): Likewise.
* dbg_mlc.c [!SHORT_DBG_HDRS] (GC_print_smashed_obj): Likewise.
* dyn_load.c [HAVE_DL_ITERATE_PHDR]
(GC_register_dynamic_libraries_dl_iterate_phdr): Likewise.
* dyn_load.c [IRIX5] (GC_register_dynamic_libraries): Likewise.
* finalize.c [!NO_DEBUGGING] (GC_dump_finalization_links,
GC_dump_finalization): Likewise.
* include/private/gc_pmark.h [MARK_BIT_PER_GRANULE || MARK_BIT_PER_OBJ]
(PUSH_CONTENTS_HDR): Likewise.
* mark.c [ENABLE_TRACE] (GC_mark_from): Likewise.
* mark_rts.c [!NO_DEBUGGING] (GC_print_static_roots): Likewise.
* mark_rts.c [DEBUG_ADD_DEL_ROOTS] (GC_add_roots_inner,
GC_remove_root_at_pos): Likewise.
* misc.c [ENABLE_TRACE] (GC_init): Likewise.
* os_dep.c [LINUX || HURD] (GC_init_linux_data_start): Likewise.
* os_dep.c [!OS2 && !MSWIN32] (GC_register_data_segments): Likewise.
* os_dep.c [USE_MUNMAP && !USE_WINALLOC && !NACL] (GC_remap): Likewise.
* os_dep.c [!DARWIN && !MSWIN32 && !MSWINCE] (GC_write_fault_handler):
Likewise.
* os_dep.c [PROC_VDB && DEBUG_DIRTY_BITS] (GC_read_dirty): Likewise.
* os_dep.c [MPROTECT_VDB && DARWIN && BROKEN_EXCEPTION_HANDLING]
(catch_exception_raise): Likewise.
* pthread_stop_world.c [DEBUG_THREADS] (GC_push_all_stacks): Likewise.
* pthread_support.c [DEBUG_THREADS] (GC_unregister_my_thread_inner,
GC_unregister_my_thread, GC_start_rtn_prepare_thread): Likewise.
* reclaim.c [!NO_DEBUGGING] (GC_print_free_list): Likewise.
* specific.c [USE_CUSTOM_SPECIFIC && GC_ASSERTIONS]
(GC_check_tsd_marks): Likewise.
* win32_threads.c [DEBUG_THREADS] (GC_push_stack_for): Likewise.
* win32_threads.c [GC_PTHREADS && DEBUG_THREADS] (GC_pthread_join,
GC_pthread_create, GC_pthread_start_inner, GC_thread_exit_proc):
Likewise.
* dbg_mlc.c: Remove duplicate check of SHORT_DBG_HDRS.
* include/private/gc_pmark.h [MARK_BIT_PER_GRANULE || MARK_BIT_PER_OBJ]
(PUSH_CONTENTS_HDR): Add missing parentheses around "source" argument
when casting it to ptr_t.

8 years agoWorkaround more 'void pointers in calculations' cppcheck warnings
Ivan Maidanski [Mon, 17 Oct 2016 07:53:19 +0000 (10:53 +0300)]
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].

8 years agoEliminate all 'scope of variable can be reduced' cppcheck style warnings
Ivan Maidanski [Tue, 4 Oct 2016 20:27:53 +0000 (23:27 +0300)]
Eliminate all 'scope of variable can be reduced' cppcheck style warnings
(Cherry-pick commits 03bb5fbb3692f981d04a665347c0a117f6c from 'master'.)

* allchblk.c (GC_compute_large_free_bytes, GC_print_hblkfreelist,
free_list_index_of, GC_dump_regions, GC_add_to_fl, GC_unmap_old,
GC_allochblk_nth): Move local variable declaration to the inner scope
where the variable is actually used.
* alloc.c (GC_maybe_gc, GC_collect_a_little_inner, GC_set_fl_marks,
GC_clear_fl_marks): Likewise.
* dyn_load.c (GC_register_dynamic_libraries): Likewise.
* finalize.c (GC_ignore_self_finalize_mark_proc,
GC_register_finalizer_inner, GC_dump_finalization_links,
GC_dump_finalization, GC_make_disappearing_links_disappear,
GC_remove_dangling_disappearing_links, GC_invoke_finalizers): Likewise.
* headers.c (GC_install_counts): Likewise.
* malloc.c (GC_malloc_kind_global, GC_generic_malloc_uncollectable,
GC_free): Likewise.
* mark.c (GC_push_all_eager, GC_push_marked1, GC_push_marked2,
GC_push_marked4): Likewise.
* mark_rts.c (GC_next_exclusion, GC_exclude_static_roots_inner,
GC_push_conditional_with_exclusions): Likewise.
* misc.c (GC_base, GC_parse_mem_size_arg, GC_write): Likewise.
* os_dep.c (GC_repeat_read, GC_get_maps, GC_least_described_address,
GC_register_root_section, GC_register_data_segments): Likewise.
* reclaim.c (GC_reclaim_block, GC_start_reclaim): Likewise.
* finalize.c (ITERATE_DL_HASHTBL_BEGIN): Declare prev_dl local variable.
* allchblk.c [USE_MUNMAP] (GC_merge_unmapped): Move local variable
declarations to the inner scope where the variables are actually used.
* allchblk.c [MARK_BIT_PER_GRANULE] (setup_header): Move local variable
declarations to the inner scope where the variables are actually used.
* alloc.c [!SMALL_CONFIG] (GC_try_to_collect_inner,
GC_finish_collection): Likewise.
* alloc.c (GC_stopped_mark): Likewise.
* backgraph.c [MAKE_BACK_GRAPH] (add_edge): Likewise.
* darwin_stop_world.c [GC_DARWIN_THREADS] (GC_push_all_stacks,
GC_stop_world, GC_thread_resume): Likewise.
* dyn_load.c [USE_PROC_FOR_LIBRARIES] (sort_heap_sects): Likewise.
* dyn_load.c [ALPHA && OSF1 || HPUX] (GC_register_dynamic_libraries):
Likewise.
* dyn_load.c [DARWIN] (GC_dyld_image_add, GC_dyld_image_remove):
Likewise.
* extra/AmigaOS.c (GC_amiga_free_all_mem, GC_amiga_allocwrapper_any):
Likewise.
* extra/msvc_dbg.c (GetDescriptionFromAddress): Likewise.
* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_core_gcj_malloc,
GC_gcj_malloc_ignore_off_page): Likewise.
* include/new_gc_alloc.h (single_client_gc_alloc_template::deallocate,
single_client_gc_alloc_template::ptr_free_deallocate,
single_client_traceable_alloc_template::deallocate,
single_client_traceable_alloc_template::ptr_free_deallocate): Likewise.
* malloc.c [THREADS] (GC_free_inner): Likewise.
* mark_rts.c (GC_add_roots_inner): Likewise.
* misc.c (GC_clear_stack): Likewise.
* os_dep.c [GWW_VDB] (GC_gww_read_dirty): Likewise.
* os_dep.c [MPROTECT_VDB] (GC_protect_heap): Likewise.
* os_dep.c [PROC_VDB] (GC_read_dirty): Likewise.
* os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise): Likewise.
* pthread_stop_world.c [GC_NETBSD_THREADS_WORKAROUND] (GC_start_world):
Likewise.
* pthread_support.c [!GC_NO_PTHREAD_SIGMASK] (pthread_sigmask):
Likewise (but not for fudged_set).
* reclaim.c [!SMALL_CONFIG] (GC_reclaim_all): Likewise.
* tests/test.c (run_one_test): Likewise.
* tests/test.c [MACOS] (SetMinimumStack): Likewise.
* thread_local_alloc.c [THREAD_LOCAL_ALLOC] (return_single_freelist):
Likewise.
* typd_mlc.c (GC_make_descriptor): Likewise.
* win32_threads.c (GC_start_world, GC_CreateThread): Likewise.
* win32_threads.c [!GC_PTHREADS_PARAMARK] (GC_start_mark_threads_inner):
Likewise.
* win32_threads.c [!MSWINCE && !CYGWIN32] (GC_beginthreadex): Likewise.
* os_dep.c [!DARWIN] (GC_write_fault_handler): Move "i" local variable
declaration to the inner scope where the variable is actually used.

8 years agoWorkaround more '#error' cppcheck error messages
Ivan Maidanski [Thu, 13 Oct 2016 08:03:04 +0000 (11:03 +0300)]
Workaround more '#error' cppcheck error messages

* darwin_stop_world.c (GC_stack_range_for): Skip #error pragma if
CPPCHECK.
* dyn_load.c [DYNAMIC_LOADING && !PCR && !DARWIN]: Likewise.
* dyn_load.c [SOLARISDL && !PCR && !GC_SOLARIS_THREADS && THREADS]:
Likewise.
* include/private/gc_priv.h [!POWERPC && !I386 && !X86_64 && !ARM32
&& !AARCH64] (GC_THREAD_STATE_T): Likewise.
* include/private/gcconfig.h [GC_IRIX_THREADS && !IRIX5 || ...]:
Likewise.
* include/private/gcconfig.h [PARALLEL_MARK && !THREADS]: Likewise.
* include/private/gcconfig.h [MARK_BIT_PER_GRANULE && MARK_BIT_PER_OBJ
|| ...]: Likewise.
* pcr_interface.c [PCR] (GC_enumerate_block): Likewise.
* win32_threads.c [!I386 && !X86_64 && !ARM32 && !SHx && !MIPS && !PPC
&& !ALPHA] (GC_push_stack_for): Likewise.
* darwin_stop_world.c (GC_stack_range_for): Initialize "lo" local
variable even if platform unsupported.

8 years agoWorkaround '#error' cppcheck error messages
Ivan Maidanski [Wed, 5 Oct 2016 22:12:55 +0000 (01:12 +0300)]
Workaround '#error' cppcheck error messages

* extra/msvc_dbg.c (GetStackFramesFromContext): Skip #error pragma
if CPPCHECK.
* include/private/gcconfig.h [sun && mc68000]: Likewise.
* include/private/gcconfig.h [hp9000s300 || ibm032 || _AUX_SOURCE
|| __pj__]: Likewise.
* include/private/gcconfig.h [!mach_type_known]: Likewise.
* include/private/gcconfig.h [HEXAGON && LINUX && !__ELF__]: Likewise.
* include/private/gcconfig.h [!ALIGNMENT || !STACKBOTTOM]: Likewise.
* os_dep.c [USE_MUNMAP && !USE_MMAP]: Likewise.
* os_dep.c [MPROTECT_VDB && DARWIN && !ARM32 && !AARCH64 && !POWERPC
&& !I386]: Likewise.

8 years agoWorkaround 'value of macro unknown' cppcheck info messages
Ivan Maidanski [Mon, 24 Oct 2016 08:06:33 +0000 (11:06 +0300)]
Workaround 'value of macro unknown' cppcheck info messages

The messages are eliminated for the macros: __int64, _SIGRTMIN,
ARM_THREAD_STATE32, ARM_UNIFIED_THREAD_STATE, FIXUP_POINTER,
GC_COLLECT_AT_MALLOC, GC_FREE_SPACE_DIVISOR, GC_FULL_FREQ,
GC_INITIAL_HEAP_SIZE, GC_MAX_RETRIES, GC_MAXIMUM_HEAP_SIZE,
GC_MIN_MARKERS, GC_SIG_SUSPEND, GC_SIG_THR_RESTART, GC_TIME_LIMIT,
HEURISTIC2_LIMIT, MAP_ANONYMOUS, RTLD_DI_LINKMAP, SAVE_CALL_COUNT,
SIZE_MAX.

* alloc.c (GC_full_freq, GC_free_space_divisor, GC_time_limit): Define
to default immediate value if CPPCHECK.
* darwin_stop_world.c [ARM32 && ARM_THREAD_STATE32]
(GC_ARM_UNIFIED_THREAD_STATE): New macro (defined to
ARM_UNIFIED_THREAD_STATE unless CPPCHECK).
* darwin_stop_world.c [ARM32 && ARM_THREAD_STATE32]
(GC_stack_range_for): Use GC_ARM_UNIFIED_THREAD_STATE; do not use value
of ARM_THREAD_STATE32 if CPPCHECK.
* dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_RTLD_DI_LINKMAP): New macro
(defined to RTLD_DI_LINKMAP unless CPPCHECK).
* dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_FirstDLOpenedLinkMap): Use
GC_RTLD_DI_LINKMAP.
* include/gc.h (GC_word, GC_signed_word): Do not define to __int64 if
CPPCHECK.
* include/gc.h (GC_INIT_CONF_MAX_RETRIES,
GC_INIT_CONF_FREE_SPACE_DIVISOR, GC_INIT_CONF_FULL_FREQ,
GC_INIT_CONF_TIME_LIMIT, GC_INIT_CONF_SUSPEND_SIGNAL,
GC_INIT_CONF_THR_RESTART_SIGNAL, GC_MAXIMUM_HEAP_SIZE,
GC_INITIAL_HEAP_SIZE): Define to empty if CPPCHECK.
* include/private/gc_priv.h [SIZE_MAX] (GC_SIZE_MAX): Do not define to
SIZE_MAX if CPPCHECK.
* include/private/gc_priv.h [DARWIN && ARM32
&& ARM_UNIFIED_THREAD_STATE] (GC_MACH_THREAD_STATE): Do not define to
ARM_UNIFIED_THREAD_STATE if CPPCHECK.
* include/private/gc_priv.h [GC_PTHREADS && _SIGRTMIN] (SIG_SUSPEND):
Do not define to _SIGRTMIN if CPPCHECK.
* pthread_stop_world.c [!SIG_THR_RESTART && _SIGRTMIN]
(SIG_THR_RESTART): Likewise.
* include/private/gcconfig.h [SAVE_CALL_CHAIN && SAVE_CALL_COUNT]
(NFRAMES): Define to immediate value (do not use value of
SAVE_CALL_COUNT) if CPPCHECK.
* include/private/gcconfig.h [!FIXUP_POINTER && POINTER_MASK]
(FIXUP_POINTER): Define to a sample expression (not using values of
POINTER_MASK and POINTER_SHIFT) if CPPCHECK.
* malloc.c [GC_COLLECT_AT_MALLOC] (GC_dbg_collect_at_malloc_min_lb):
Define to sample value (not using value of GC_COLLECT_AT_MALLOC) if
CPPCHECK.
* misc.c [GC_INITIAL_HEAP_SIZE] (GC_init): Define to default immediate
value if CPPCHECK.
* os_dep.c [!BEOS && !OS2 && !SWIN32 && !GC_OPENBSD_THREADS
&& !STACKBOTTOM && HEURISTIC2_LIMIT] (GC_get_main_stack_base): Do not
use value of HEURISTIC2_LIMIT if CPPCHECK.
* os_dep.c [USE_MMAP_ANON && MAP_ANONYMOUS] (OPT_MAP_ANON): Do not use
value of MAP_ANONYMOUS if CPPCHECK.
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && !GC_TIME_LIMIT]
(GC_TIME_LIMIT): Do not define.
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD]
(GC_brief_async_signal_safe_sleep): Do not use value of GC_TIME_LIMIT
if CPPCHECK.
* pthread_support.c [PARALLEL_MARK && GC_MIN_MARKERS] (GC_thr_init):
Do not use value of GC_MIN_MARKERS if CPPCHECK.
* win32_threads.c [PARALLEL_MARK && GC_MIN_MARKERS] (GC_thr_init):
Likewise.
* tests/test.c [GC_DEBUG && SAVE_CALL_CHAIN && SAVE_CALL_COUNT]
(check_heap_stats): Use NFRAMES instead of SAVE_CALL_COUNT (i.e. do not
use value of SAVE_CALL_COUNT).

8 years agoWorkaround 'value of REDIRECT_MALLOC/FREE unknown' cppcheck info messages
Ivan Maidanski [Sat, 22 Oct 2016 15:21:33 +0000 (18:21 +0300)]
Workaround 'value of REDIRECT_MALLOC/FREE unknown' cppcheck info messages

* malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER]
(REDIRECT_MALLOC_F): New macro (defined to REDIRECT_MALLOC unless
CPPCHECK).
* malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER] (malloc,
calloc, strdup, strndup): Use REDIRECT_MALLOC_F instead of
REDIRECT_MALLOC.
* malloc.c [REDIRECT_FREE && !REDIRECT_MALLOC_IN_HEADER]
(REDIRECT_FREE_F): New macro (defined to REDIRECT_FREE unless
CPPCHECK).
* malloc.c [REDIRECT_FREE && !REDIRECT_MALLOC_IN_HEADER] (free): Use
REDIRECT_FREE_F instead of REDIRECT_FREE.

8 years agoWorkaround 'value of WINAPI unknown' cppcheck info messages
Ivan Maidanski [Sat, 22 Oct 2016 14:39:36 +0000 (17:39 +0300)]
Workaround 'value of WINAPI unknown' cppcheck info messages

* include/gc.h [GC_WIN32_THREADS && WINAPI && !CPPCHECK]
(GC_WINDOWS_H_INCLUDED): New macro.
* include/gc.h [GC_WIN32_THREADS] (GC_WINDOWS_H_INCLUDED): Define also
if windows.h included.
* include/gc.h [GC_WIN32_THREADS]: Replace "#ifdef WINAPI" with
"#ifdef GC_WINDOWS_H_INCLUDED".

8 years agoWorkaround 'value of SIGBUS unknown' cppcheck info messages
Ivan Maidanski [Sat, 22 Oct 2016 07:11:46 +0000 (10:11 +0300)]
Workaround 'value of SIGBUS unknown' cppcheck info messages

* include/private/gcconfig.h [SIGBUS && !CPPCHECK] (HAVE_SIGBUS): New
macro.
* os_dep.c [NEED_FIND_LIMIT || UNIX_LIKE] (old_bus_handler,
GC_set_and_save_fault_handler, GC_reset_fault_handler): Replace
"ifdef SIGBUS" with "ifdef HAVE_SIGBUS".
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_remove_allowed_signals): Likewise.

8 years agoEliminate 'value of DATASTART2 unknown' cppcheck info messages
Ivan Maidanski [Sat, 22 Oct 2016 06:48:29 +0000 (09:48 +0300)]
Eliminate 'value of DATASTART2 unknown' cppcheck info messages

* dyn_load.c [HAVE_DL_ITERATE_PHDR]
(GC_register_dynamic_libraries_dl_iterate_phdr): Replace
defined(DATASTART2) with defined(GC_HAVE_DATAREGION2).
* os_dep.c [!OS2 && !MSWIN32 && !OPENBSD] (GC_register_data_segments):
Likewise.
* include/private/gcconfig.h [DATASTART2] (GC_HAVE_DATAREGION2): New
macro.

8 years agoEliminate 'value of GC_PTHREAD_EXIT_ATTRIBUTE unknown' cppcheck messages
Ivan Maidanski [Fri, 21 Oct 2016 22:31:44 +0000 (01:31 +0300)]
Eliminate 'value of GC_PTHREAD_EXIT_ATTRIBUTE unknown' cppcheck messages

* include/gc_config_macros.h [GC_PTHREAD_EXIT_ATTRIBUTE]
(GC_HAVE_PTHREAD_EXIT): New macro.
* include/gc_config_macros.h: Replace defined(GC_PTHREAD_EXIT_ATTRIBUTE)
with defined(GC_HAVE_PTHREAD_EXIT).
* include/gc_pthread_redirects.h: Likewise.
* pthread_support.c: Likewise.

8 years agoEliminate 'value of GC_RETURN_ADDR_PARENT unknown' cppcheck info messages
Ivan Maidanski [Fri, 21 Oct 2016 22:11:30 +0000 (01:11 +0300)]
Eliminate 'value of GC_RETURN_ADDR_PARENT unknown' cppcheck info messages

* dbg_mlc.c [GC_ADD_CALLER]: Replace defined(GC_RETURN_ADDR_PARENT)
with defined(GC_HAVE_RETURN_ADDR_PARENT).
* include/private/gc_priv.h (GC_DBG_EXTRAS): Likewise.
* include/gc_config_macros.h [GC_RETURN_ADDR_PARENT]
(GC_HAVE_RETURN_ADDR_PARENT): New macro.

8 years agoEliminate 'value of NEED_FIXUP_POINTER unknown' cppcheck info messages
Ivan Maidanski [Fri, 21 Oct 2016 17:27:51 +0000 (20:27 +0300)]
Eliminate 'value of NEED_FIXUP_POINTER unknown' cppcheck info messages

* include/private/gc_pmark.h: Replace #if NEED_FIXUP_POINTER
to #ifdef NEED_FIXUP_POINTER.
* include/private/gcconfig.h (NEED_FIXUP_POINTER): If FIXUP_POINTER
then define to empty else leave undefined.
* mark.c (GC_push_all_stack): Replace if(!NEED_FIXUP_POINTER)
to #ifndef NEED_FIXUP_POINTER.
* mark_rts.c (GC_push_all_stack_partially_eager): Likewise.

8 years agoFix missing #error pragma
Ivan Maidanski [Wed, 12 Oct 2016 19:42:41 +0000 (22:42 +0300)]
Fix missing #error pragma

* dyn_load.c [DYNAMIC_LOADING && !PCR && !DARWIN]: Replace "-->" with
* dyn_load.c [SOLARISDL && !PCR && !GC_SOLARIS_THREADS && THREADS]:
Likewise.
* include/private/gc_hdrs [CPP_WORDSZ!=32 && CPP_WORDSZ<36]: Likewise.
* include/private/gc_priv.h [!HBLKSIZE]: Likewise.
* pthread_stop_world.c [!NSIG]: Likewise.

8 years agoEliminate 'Condition 0==datastart always false' cppcheck warning (dyn_load)
Ivan Maidanski [Tue, 25 Oct 2016 21:14:20 +0000 (00:14 +0300)]
Eliminate 'Condition 0==datastart always false' cppcheck warning (dyn_load)

* dyn_load.c [HAVE_DL_ITERATE_PHDR]
(GC_register_dynamic_libraries_dl_iterate_phdr): Cast datastart to
char*volatile* before dereferencing and checking against NULL.

8 years agoWorkaround 'condition is always false' cppcheck warning in get_next_stack
Ivan Maidanski [Tue, 25 Oct 2016 08:37:40 +0000 (11:37 +0300)]
Workaround 'condition is always false' cppcheck warning in get_next_stack

* win32_threads.c [CPPCHECK] (GC_get_next_stack): Set thread a non-null
value (near current_min assignment) even if GC_win32_dll_threads (to
avoid cppcheck complain that if(thread!=0) is always false (thus
UNPROTECT_THREAD(thread) is never reached) if GC_DISCOVER_TASK_THREADS.

8 years agoWorkaround 'possible null pointer dereference' cppcheck warning (Darwin)
Ivan Maidanski [Wed, 26 Oct 2016 21:38:55 +0000 (00:38 +0300)]
Workaround 'possible null pointer dereference' cppcheck warning (Darwin)

* darwin_stop_world.c [CPPCHECK] (GC_stack_range_for): Call ABORT if
p is NULL and thread_blocked is true.

8 years agoWorkaround 'possible null pointer dereference' cppcheck warnings
Ivan Maidanski [Tue, 18 Oct 2016 09:04:52 +0000 (12:04 +0300)]
Workaround 'possible null pointer dereference' cppcheck warnings

* include/private/gc_priv.h (GC_on_abort): Move definition upper (to be
before ABORT definition); define it to empty if PCR (this is needed for
CPPCHECK).
* include/private/gc_priv.h (ABORT): Specially define to
{GC_on_abort(msg);abort();} block statement if CPPCHECK.
* tests/test.c (chktree): Check for n is zero only once; add comment.

8 years agoWorkaround 'variable reassigned before old value used' cppcheck warnings
Ivan Maidanski [Tue, 18 Oct 2016 21:42:29 +0000 (00:42 +0300)]
Workaround 'variable reassigned before old value used' cppcheck warnings

* misc.c (GC_call_with_gc_active): Call GC_noop1 for
GC_traced_stack_sect and GC_blocked_sp (before restoring their original
values) if CPPCHECK.
* win32_threads.c (GC_do_blocking_inner): Call GC_noop1 for
thread_blocked_sp field (before restoring its original value)
if CPPCHECK.
* win32_threads.c (GC_call_with_gc_active): Call GC_noop1 for
traced_stack_sect field (before restoring its original value)
if CPPCHECK.

8 years agoWorkaround 'same expression on both sides of ==' cppcheck style warning
Ivan Maidanski [Tue, 18 Oct 2016 10:34:34 +0000 (13:34 +0300)]
Workaround 'same expression on both sides of ==' cppcheck style warning

* misc.c (GC_init): Do not check sizeof(signed_word) value if CPPCHECK.

8 years agoWorkaround 'same expression on both sides of OR' cppcheck style warning
Ivan Maidanski [Tue, 18 Oct 2016 10:26:34 +0000 (13:26 +0300)]
Workaround 'same expression on both sides of OR' cppcheck style warning

* os_dep.c [USE_WINALLOC || CYGWIN32] (GC_mem_top_down): Define to
non-zero value (MEM_TOP_DOWN) if CPPCHECK.

8 years agoWorkaround 'redundant assignment of *result to itself' cppcheck warning
Ivan Maidanski [Tue, 18 Oct 2016 10:05:02 +0000 (13:05 +0300)]
Workaround 'redundant assignment of *result to itself' cppcheck warning

* os_dep.c [DGUX || LINUX && SPARC] (GC_SysVGetDataStart): Call
GC_noop1(&v) if CPPCHECK where v = *result.

8 years agoWorkaround 'obsolete function alloca() called' cppcheck warnings
Ivan Maidanski [Tue, 18 Oct 2016 09:24:34 +0000 (12:24 +0300)]
Workaround 'obsolete function alloca() called' cppcheck warnings

* dyn_load.c [AIX] (GC_register_dynamic_libraries): Code refactoring
to have alloca() call only once (at the beginning of a block); use
variable-length array instead of alloca() if CPPCHECK.

8 years agoWorkaround 'struct member is never used' cppcheck style warnings
Ivan Maidanski [Tue, 18 Oct 2016 07:59:20 +0000 (10:59 +0300)]
Workaround 'struct member is never used' cppcheck style warnings

* os_dep.c [OS2] (GC_register_data_segments): Assign 0 to
hdrdos.padding, hdr386.exe_format_level/os/padding1/padding2,
seg.pagemap/mapsize/reserved fields if CPPCHECK; add comment.
* os_dep.c [MPROTECT_VDB && DARWIN] (GC_mprotect_thread): Assign 0 to
the first element of reply.data, msg.data fields if CPPCHECK; add
comment.
* typd_mlc.c (TAG): Define to ad.ad_tag (instead of ld.ld_tag).

8 years agoWorkaround 'checking if unsigned value is negative' cppcheck warning
Ivan Maidanski [Mon, 17 Oct 2016 21:28:25 +0000 (00:28 +0300)]
Workaround 'checking if unsigned value is negative' cppcheck warning

* allchblk.c [GC_ASSERTIONS && !USE_MUNMAP] (GC_add_to_fl): Replace
(signed_word)GC_heapsize<0 with (GC_heapsize&SIGNB)!=0.

8 years agoWorkaround 'unused variable' cppcheck style warnings
Ivan Maidanski [Mon, 17 Oct 2016 07:01:16 +0000 (10:01 +0300)]
Workaround 'unused variable' cppcheck style warnings

* include/private/gc_locks.h [PCR && THREADS] (DCL_LOCK_STATE): Define
to empty if CPPCHECK.
* mach_dep.c [MACOS && __MWERKS__ && POWERPC] (getRegisters): Declare
as external of CPPCHECK (as cppcheck does not recognize "asm" in
function declaration).

8 years agoEliminate 'constructor with 1 argument is not explicit' cppcheck warning
Ivan Maidanski [Wed, 14 Sep 2016 22:03:15 +0000 (01:03 +0300)]
Eliminate 'constructor with 1 argument is not explicit' cppcheck warning
(Cherry-pick commits 569fd66 and 7811301 from 'master' branch.)

Note that -D CPPCHECK should be passed to cppcheck to activate
this workaround.

* include/gc_allocator.h (GC_ATTR_EXPLICIT): New macro (defined to
"explicit" keyword if at least C++11 or CPPCHECK, otherwise to empty).
* include/gc_allocator.h (gc_allocator::gc_allocator,
gc_allocator_ignore_off_page::gc_allocator_ignore_off_page,
traceable_allocator::traceable_allocator): Use GC_ATTR_EXPLICIT.
* tests/test_cpp.cc (A::A, B::B, C::C, D::D): Likewise.
* tests/test_cpp.cc (GC_ATTR_EXPLICIT): Define macro in the same way as
in include/gc_allocator.h

8 years agoEliminate 'class defines member variable with name also defined in parent' cppcheck...
Ivan Maidanski [Tue, 13 Sep 2016 18:53:08 +0000 (21:53 +0300)]
Eliminate 'class defines member variable with name also defined in parent' cppcheck warning

* tests/test_cpp.cc (F::nFreed, F::nAllocated): Add 'F' suffix to field name (to avoid
hiding the similar one in the parent class).

8 years agoFix 'void pointers in calculations: behavior undefined' cppcheck warning
Ivan Maidanski [Wed, 14 Sep 2016 06:47:40 +0000 (09:47 +0300)]
Fix 'void pointers in calculations: behavior undefined' cppcheck warning

* dbg_mlc.c (OFN_UNSET): Replace -1 with ~(signed_word)0; add
outermost parentheses.

8 years agoFix 'syntax error' reported by cppcheck for mach_dep
Ivan Maidanski [Wed, 12 Oct 2016 19:59:22 +0000 (22:59 +0300)]
Fix 'syntax error' reported by cppcheck for mach_dep

The error is reported at line containing "asm".

* mach_dep.c [MACOS && M68K && THINK_C] (GC_push_regs): Do not define
if CPPCHECK.

8 years agoWorkaround 'tainted int used as loop bound' static analysis tool warning
Ivan Maidanski [Fri, 21 Oct 2016 18:57:15 +0000 (21:57 +0300)]
Workaround 'tainted int used as loop bound' static analysis tool warning
(Cherry-pick commits 1868a90 and 0f23ec4 from 'master' branch.)

No need to check upper bound of n here, so a dummy check is added.

* tests/test_cpp.cc (main) [LINT2]: Check upper bound of n signed local
variable (the check is actually dummy).
* tests/test_cpp.cc (main): Reformat code (which handles n variable).

8 years agoEliminate 'null dereference' code defect warning in register_finalizer
Ivan Maidanski [Sat, 29 Oct 2016 14:49:37 +0000 (17:49 +0300)]
Eliminate 'null dereference' code defect warning in register_finalizer

* finalize.c (GC_register_finalizer_inner): Add GC_ASSERT that fn is
non-zero (instead of specifying this in a comment) for the case when
new_fo is non-NULL (new_fo is returned by GC_oom_fn).
* finalize.c [LINT2] (GC_register_finalizer_inner): Call ABORT if hhdr
is NULL (for the case when new_fo is non-NULL).

8 years agoWorkaround 'insecure libc pseudo-random number generator used' code defect
Ivan Maidanski [Fri, 28 Oct 2016 07:57:20 +0000 (10:57 +0300)]
Workaround 'insecure libc pseudo-random number generator used' code defect

* dbg_mlc.c [LINT2] (GC_random): New function.
* dbg_mlc.c [KEEP_BACK_PTRS && LINT2] (RANDOM): Define to GC_random.
* dbg_mlc.c [KEEP_BACK_PTRS && LINT2]: Do not include stdlib.h.
* dbg_mlc.c [KEEP_BACK_PTRS && !LINT2] (GC_RAND_MAX): Define.
* dbg_mlc.c (GC_generate_random_heap_address): Replace RAND_MAX with
GC_RAND_MAX.
* include/private/gc_priv.h [LINT2] (GC_RAND_MAX): New macro.
* include/private/gc_priv.h [LINT2] (GC_random): Prototype (as
GC_API_PRIV).
* tests/disclaim_bench.c [LINT2] (rand): Redefine to GC_random.
* tests/disclaim_test.c [LINT2] (rand): Likewise.
* tests/disclaim_test.c [LINT2]: Include private/gc_priv.h instead of
config.h.

8 years agoWorkaround 'mmap() resource handle leak' static analyzer warning
Ivan Maidanski [Mon, 3 Oct 2016 20:34:56 +0000 (23:34 +0300)]
Workaround 'mmap() resource handle leak' static analyzer warning

* os_dep.c [USE_MUNMAP && LINT2] (GC_unmap, GC_remap, GC_unmap_gap):
Call GC_noop1(result) where result is returned by mmap or VirtualAlloc.
* os_dep.c [USE_MUNMAP && NACL] (GC_remap): Rename mmap_result local
variable to result.
* os_dep.c [USE_MUNMAP && !USE_WINALLOC] (GC_unmap_gap): Update
GC_unmapped_bytes (by len) only if len is non-zero.

8 years agoWorkaround 'local variable size too big' static analyzer warning
Ivan Maidanski [Mon, 3 Oct 2016 07:22:59 +0000 (10:22 +0300)]
Workaround 'local variable size too big' static analyzer warning

* mark.c [PARALLEL_MARK] (LOCAL_MARK_STACK_SIZE): Define to smaller
value if LINT2 (to avoid static analysis tool warning that
local_mark_stack local variable size is very big).

8 years agoEliminate 'comparison is always false' static analyzer warning in finalize
Ivan Maidanski [Wed, 28 Sep 2016 07:04:39 +0000 (10:04 +0300)]
Eliminate 'comparison is always false' static analyzer warning in finalize

GC_enqueue_all_finalizers code refactoring is done (removal of the
unreachable statement) to eliminate the warning.

* finalize.c (GC_enqueue_all_finalizers): Remove "prev_fo" local
variable; remove "register" keyword for local variables;
remove the pointer to the chain of hash table entries from the roots
(i.e. setting the roots pointer to null) at the beginning of processing
the chain (instead of updating the roots pointer on deletion of each
entry and finally setting it to null); remove fo_set_next(prev_fo) as
it is never called (because prev_fo was always null); update
GC_fo_entries only when the whole table processed (i.e. all items
removed).

8 years agoEnable GC_is_tmp_root for all platforms
Ivan Maidanski [Sat, 29 Oct 2016 07:25:50 +0000 (10:25 +0300)]
Enable GC_is_tmp_root for all platforms

* mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Define for any platform
(not only for Win32); update comment.

8 years agoAllow custom TRACE_ENTRIES value
Ivan Maidanski [Fri, 28 Oct 2016 21:48:53 +0000 (00:48 +0300)]
Allow custom TRACE_ENTRIES value

* mark.c [TRACE_BUF] (TRACE_ENTRIES): Do not define if already defined.

8 years agoExport GC_is_tmp_root() and GC_print_trace[_inner]()
Ivan Maidanski [Sat, 29 Oct 2016 07:14:42 +0000 (10:14 +0300)]
Export GC_is_tmp_root() and GC_print_trace[_inner]()

Note: these 3 functions are not used by GC itself.

* include/gc_mark.h (GC_is_tmp_root, GC_print_trace,
GC_print_trace_inner): New public API prototype.
* mark.c [TRACE_BUF] (GC_print_trace_inner, GC_print_trace): Define as
public (GC_API+GC_CALL).
* mark_rts.c [MSWIN32 && !NO_DEBUGGING] (GC_is_tmp_root): Likewise.
* mark_rts.c [MSWIN32 && !NO_DEBUGGING] (GC_is_tmp_root): Replace
GC_bool return type with int, replace ptr_t argument type to void*
(because GC_bool and ptr_t are not exported from GC).

8 years agoExport GC_dump_finalization/regions()
Ivan Maidanski [Fri, 28 Oct 2016 21:23:02 +0000 (00:23 +0300)]
Export GC_dump_finalization/regions()

Note: these 2 functions are not used by GC itself.

* allchblk.c [!NO_DEBUGGING] (GC_dump_regions): Turn into a public
definition (add GC_API+GC_CALL).
* finalize.c [!NO_DEBUGGING] (GC_dump_finalization): Likewise.
* include/gc.h (GC_dump_regions, GC_dump_finalization): New public API
prototype.

8 years agoFix GC_collect_or_expand to prevent allocation size value wrap-around
Ivan Maidanski [Tue, 27 Sep 2016 07:12:18 +0000 (10:12 +0300)]
Fix GC_collect_or_expand to prevent allocation size value wrap-around

Relates to issue #135 on Github.

* alloc.c (GC_WORD_MAX): New macro.
* alloc.c (GC_collect_or_expand): Limit blocks_to_get by
GC_WORD_MAX / HBLKSIZE value (to avoid multiplication overflow in
GC_expand_hp_inner).

8 years agoFix malloc routines to prevent size value wrap-around
Ivan Maidanski [Mon, 19 Sep 2016 21:07:47 +0000 (00:07 +0300)]
Fix malloc routines to prevent size value wrap-around

See issue #135 on Github.

* allchblk.c (GC_allochblk, GC_allochblk_nth): Use
OBJ_SZ_TO_BLOCKS_CHECKED instead of OBJ_SZ_TO_BLOCKS.
* malloc.c (GC_alloc_large): Likewise.
* alloc.c (GC_expand_hp_inner): Type of "bytes" local variable changed
from word to size_t; cast ROUNDUP_PAGESIZE argument to size_t; prevent
overflow when computing GC_heapsize+bytes > GC_max_heapsize.
* dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page,
GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc,
GC_debug_generic_malloc_inner,
GC_debug_generic_malloc_inner_ignore_off_page,
GC_debug_malloc_stubborn, GC_debug_malloc_atomic,
GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable):
Use SIZET_SAT_ADD (instead of "+" operator) to add extra bytes to lb
value.
* fnlz_mlc.c (GC_finalized_malloc): Likewise.
* gcj_mlc.c (GC_debug_gcj_malloc): Likewise.
* include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES,
ADD_SLOP, ROUNDUP_PAGESIZE): Likewise.
* include/private/gcconfig.h (GET_MEM): Likewise.
* mallocx.c (GC_malloc_many, GC_memalign): Likewise.
* os_dep.c (GC_wince_get_mem, GC_win32_get_mem): Likewise.
* typd_mlc.c (GC_malloc_explicitly_typed,
GC_malloc_explicitly_typed_ignore_off_page,
GC_calloc_explicitly_typed): Likewise.
* headers.c (GC_scratch_alloc): Change type of bytes_to_get from word
to size_t (because ROUNDUP_PAGESIZE_IF_MMAP result type changed).
* include/private/gc_priv.h: Include limits.h (unless SIZE_MAX already
defined).
* include/private/gc_priv.h (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): Move from
malloc.c file.
* include/private/gc_priv.h (SIZET_SAT_ADD): New macro (defined before
include gcconfig.h).
* include/private/gc_priv.h (EXTRA_BYTES, GC_page_size): Change type
to size_t.
* os_dep.c (GC_page_size): Likewise.
* include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES,
ADD_SLOP, ROUNDUP_PAGESIZE): Add comment about the argument.
* include/private/gcconfig.h (GET_MEM): Likewise.
* include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES,
ADD_SLOP, OBJ_SZ_TO_BLOCKS, ROUNDUP_PAGESIZE,
ROUNDUP_PAGESIZE_IF_MMAP): Rename argument to "lb".
* include/private/gc_priv.h (OBJ_SZ_TO_BLOCKS_CHECKED): New macro.
* include/private/gcconfig.h (GC_win32_get_mem, GC_wince_get_mem,
GC_unix_get_mem): Change argument type from word to int.
* os_dep.c (GC_unix_mmap_get_mem, GC_unix_get_mem,
GC_unix_sbrk_get_mem, GC_wince_get_mem, GC_win32_get_mem): Likewise.
* malloc.c (GC_alloc_large_and_clear): Call OBJ_SZ_TO_BLOCKS only
if no value wrap around is guaranteed.
* malloc.c (GC_generic_malloc): Do not check for lb_rounded < lb case
(because ROUNDED_UP_GRANULES and GRANULES_TO_BYTES guarantees no value
wrap around).
* mallocx.c (GC_generic_malloc_ignore_off_page): Likewise.
* misc.c (GC_init_size_map): Change "i" local variable type from int
to size_t.
* os_dep.c (GC_write_fault_handler, catch_exception_raise): Likewise.
* misc.c (GC_envfile_init): Cast len to size_t when passed to
ROUNDUP_PAGESIZE_IF_MMAP.
* os_dep.c (GC_setpagesize): Cast GC_sysinfo.dwPageSize and
GETPAGESIZE() to size_t (when setting GC_page_size).
* os_dep.c (GC_unix_mmap_get_mem, GC_unmap_start, GC_remove_protection):
Expand ROUNDUP_PAGESIZE macro but without value wrap-around checking
(the argument is of word type).
* os_dep.c (GC_unix_mmap_get_mem): Replace -GC_page_size with
~GC_page_size+1 (because GC_page_size is unsigned); remove redundant
cast to size_t.
* os_dep.c (GC_unix_sbrk_get_mem): Add explicit cast of GC_page_size
to SBRK_ARG_T.
* os_dep.c (GC_wince_get_mem): Change type of res_bytes local variable
to size_t.
* typd_mlc.c: Do not include limits.h.
* typd_mlc.c (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): Remove (as defined in
gc_priv.h now).

8 years agoFix 'shift count >= width of type' compiler warning in GC_SQRT_SIZE_MAX
Ivan Maidanski [Wed, 21 Sep 2016 18:25:35 +0000 (21:25 +0300)]
Fix 'shift count >= width of type' compiler warning in GC_SQRT_SIZE_MAX
(fix commit 83231d0)
(Cherry-pick part of commit b4eb5c1 from 'master' branch.)

* malloc.c (GC_SQRT_SIZE_MAX): Change type from unsigned to size_t.

8 years agoFix calloc_explicitly_typed in case of lb*n overflow
Ivan Maidanski [Thu, 15 Sep 2016 15:40:21 +0000 (18:40 +0300)]
Fix calloc_explicitly_typed in case of lb*n overflow
(Cherry-pick commits 4e1a6f9 and part of b4eb5c1 from 'master' branch.)

* typd_mlc.c: Include limits.h (for SIZE_MAX).
* typd_mlc.c (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): New macro (same as in
malloc.c).
* typd_mlc.c (GC_calloc_explicitly_typed): Return NULL if lb * n
overflows (same algorithm as in calloc defined in malloc.c); eliminate
lb *= n code duplication.

8 years agoAdjust code indentation of calloc_explicitly_typed
Ivan Maidanski [Thu, 15 Sep 2016 20:20:04 +0000 (23:20 +0300)]
Adjust code indentation of calloc_explicitly_typed

* typd_mlc.c (GC_calloc_explicitly_typed): Adjust code indentation.

8 years agoCode refactoring of divide-by-HBLKSIZE occurrences
Ivan Maidanski [Tue, 27 Sep 2016 07:55:27 +0000 (10:55 +0300)]
Code refactoring of divide-by-HBLKSIZE occurrences

* alloc.c (GC_print_heap_sects): Replace "/HBLKSIZE" with divHBLKSZ.
* blacklst.c (total_stack_black_listed): Likewise.

8 years agoEliminate 'dereference of null' CSA false warning in array_mark_proc
Ivan Maidanski [Tue, 25 Oct 2016 21:56:02 +0000 (00:56 +0300)]
Eliminate 'dereference of null' CSA false warning in array_mark_proc

The exact warning message is: Access to field 'mse_start' results in a
dereference of a null pointer (loaded from variable 'new_mark_stack_ptr').

Note: the warning is eliminated regardless of assertion checking status.

* typd_mlc.c (GC_array_mark_proc): Call ABORT if mark_stack_ptr is NULL
(thus orig_mark_stack_ptr is ensured to be non-NULL after the check).

8 years agoFix 'variable unused' compiler warning in FirstDLOpenedLinkMap
Ivan Maidanski [Tue, 18 Oct 2016 22:02:25 +0000 (01:02 +0300)]
Fix 'variable unused' compiler warning in FirstDLOpenedLinkMap

* dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_FirstDLOpenedLinkMap):
Declare dp local variable only if !NETBSD or !RTLD_DI_LINKMAP.

8 years agoFix potential overflow in decrement when computing GC_markers_m1
Ivan Maidanski [Fri, 30 Sep 2016 14:12:24 +0000 (17:12 +0300)]
Fix potential overflow in decrement when computing GC_markers_m1

Also, call WARN if a non-positive value is specified in GC_MARKERS.

* pthread_support.c [PARALLEL_MARK] (GC_thr_init): Replace markers_m1
local variable with markers one; keep real number of markers in
"markers" variable (not a decremented one); treat invalid (i.e.
non-positive) markers value (obtained from GC_MARKERS environment
variable) the same way as too big ones (i.e. set to maximum number of
markers in this case); adjust WARN message accordingly; report invalid
or too big markers value in WARN.
* win32_threads.c [PARALLEL_MARK] (GC_thr_init): Likewise.
* pthread_support.c [PARALLEL_MARK] (GC_thr_init): Adjust code
indentation.

8 years agoFix GC_requested_heapsize increment in GC_init
Ivan Maidanski [Fri, 30 Sep 2016 12:46:42 +0000 (15:46 +0300)]
Fix GC_requested_heapsize increment in GC_init

Also eliminate static analyzer warning about potential overflow in
initial_heap_sz * HBLKSIZE.

* misc.c (GC_init): Change initial_heap_sz to keep size value in bytes
instead of HBLKSIZE units (thus, GC_requested_heapsize is incremented
by a number of bytes not HBLKSIZE units).

8 years agoEliminate 'assigned value never used' CSA warning in min_bytes_allocd
Ivan Maidanski [Tue, 13 Sep 2016 18:04:47 +0000 (21:04 +0300)]
Eliminate 'assigned value never used' CSA warning in min_bytes_allocd

The warning was reported only if GC_ALWAYS_MULTITHREADED.

* alloc.c (min_bytes_allocd): Assign stack_size value for the
single-threaded case only if GC_need_to_lock is false.

8 years agoFix 'replacement operator delete cannot be inline' GCC warning (Cygwin)
Ivan Maidanski [Sat, 29 Oct 2016 14:31:41 +0000 (17:31 +0300)]
Fix 'replacement operator delete cannot be inline' GCC warning (Cygwin)
(fix commits 83e0a2c3379238)

This commit also eliminates
"operator delete is missing exception specification throw()" compiler
warning.

* gc_cpp.cc (operator delete): Define unconditionally (i.e. for Cygwin
too).
* include/gc_cpp.h [__CYGWIN__]: Do not include "new" header.
* include/gc_cpp.h [__CYGWIN__] (operator delete): Remove (as
replacement function 'operator delete' cannot be declared 'inline').

8 years agoWorkaround 'variable hides enumerator with same name' cppcheck warnings
Ivan Maidanski [Tue, 18 Oct 2016 10:19:09 +0000 (13:19 +0300)]
Workaround 'variable hides enumerator with same name' cppcheck warnings

* include/new_gc_alloc.h (GC_bytes_per_word, GC_word_alignment): Define
as const unsigned (instead of single-item enum) if CPPCHECK.

8 years agoWorkaround 'Condition 0!=GETENV() is always false' cppcheck style warnings
Ivan Maidanski [Tue, 18 Oct 2016 08:57:09 +0000 (11:57 +0300)]
Workaround 'Condition 0!=GETENV() is always false' cppcheck style warnings

* include/private/gc_priv.h [NO_GETENV] (GETENV): Do not define to NULL
if CPPCHECK.

8 years agoWorkaround 'passing untyped NULL to variadic function' cppcheck warning
Ivan Maidanski [Tue, 18 Oct 2016 08:14:22 +0000 (11:14 +0300)]
Workaround 'passing untyped NULL to variadic function' cppcheck warning

The portability warning "Passing NULL after the last typed argument to
a variadic function leads to undefined behavior" was reported for
ABORT_ARG2(..., DATASTART, DATAEND) call in GC_register_data_segments.

* include/private/gcconfig.h [SYMBIAN || __EMSCRIPTEN__] (DATASTART,
DATAEND): Explicitly cast NULL to ptr_t.

8 years agoEliminate 'printf format specifier mismatch' compiler warning (tools)
Ivan Maidanski [Thu, 13 Oct 2016 08:44:52 +0000 (11:44 +0300)]
Eliminate 'printf format specifier mismatch' compiler warning (tools)

* tools/setjmp_t.c (main): Use %lu (instead of %ld) printf format
specifier for unsigned long value.

8 years agoEliminate 'address of local variable returned' static analyzer warning
Ivan Maidanski [Wed, 5 Oct 2016 08:32:00 +0000 (11:32 +0300)]
Eliminate 'address of local variable returned' static analyzer warning

* mark_rts.c [__GNUC__ >= 4] (GC_approx_sp): Use
__builtin_frame_address(0) instead of &sp (but still write the value to
the volatile local variable to force stack to grow if necessary).
* tools/setjmp_t.c [__GNUC__ >= 4] (nested_sp): Return
__builtin_frame_address(0) instead of sp.

8 years agoFix tools/setjmp_t to prevent nested_sp inlining
Ivan Maidanski [Wed, 5 Oct 2016 08:04:25 +0000 (11:04 +0300)]
Fix tools/setjmp_t to prevent nested_sp inlining

Inlined nested_sp might cause incorrect result of nested_sp()<sp.

* tools/setjmp_t.c (nested_sp): Change return from int* to word.
* tools/setjmp_t.c (nested_sp_fn): New global volatile variable
initialized to nested_sp.
* tools/setjmp_t.c (main): Use nested_sp_fn instead of nested_sp;
remove redundant cast.

8 years agoEliminate 'unnecessary comparison of static strings' cppcheck warning
Ivan Maidanski [Thu, 13 Oct 2016 08:16:23 +0000 (11:16 +0300)]
Eliminate 'unnecessary comparison of static strings' cppcheck warning

* tools/if_mach.c (main): Replace strcmp(x, "")!=0 with strlen(x)>0.

8 years agoEliminate 'suspicious pointer subtraction' cppcheck warning (gc_cpp)
Ivan Maidanski [Wed, 26 Oct 2016 08:13:29 +0000 (11:13 +0300)]
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).

8 years agoEliminate unreachable PROC/DEFAULT_VDB GC_printf calls in gctest main()
Ivan Maidanski [Wed, 26 Oct 2016 08:44:37 +0000 (11:44 +0300)]
Eliminate unreachable PROC/DEFAULT_VDB GC_printf calls in gctest main()

* tests/test.c [!GC_WIN32_THREADS && !GC_PTHREADS && !NO_INCREMENTAL
&& (MPROTECT_VDB || PROC_VDB || GWW_VDB) && !MAKE_BACK_GRAPH &&] (main):
Remove unreachable GC_printf call about DEFAULT_VDB; remove extra check
of GWW_VDB case.
* tests/test.c [GC_PTHREADS && MPROTECT_VDB && !REDIRECT_MALLOC
&& !MAKE_BACK_GRAPH && !USE_PROC_FOR_LIBRARIES && !NO_INCREMENTAL]
(main): Remove extra check of MPROTECT_VDB case; remove unreachable
GC_printf calls about PROC_VDB and DEFAULT_VDB.

8 years agoEliminate 'value of CLOCK_TYPE unknown' cppcheck info message
Ivan Maidanski [Fri, 21 Oct 2016 20:34:41 +0000 (23:34 +0300)]
Eliminate 'value of CLOCK_TYPE unknown' cppcheck info message

* tests/disclaim_bench.c (main): Replace #ifdef CLOCK_TYPE
with #ifndef NO_CLOCK.

8 years agoFix 'ISO C90 does not support %lf, %lg gnu_printf formats' GCC warnings
Ivan Maidanski [Fri, 21 Oct 2016 19:11:09 +0000 (22:11 +0300)]
Fix 'ISO C90 does not support %lf, %lg gnu_printf formats' GCC warnings

* tests/disclaim_bench.c (main): Replace "%lf" printf format specifier
to "%f" one, and "%lg" one to "%g" one.

8 years agoFix 'ISO C90 forbids mixed declarations and code' compiler warning
Ivan Maidanski [Fri, 21 Oct 2016 08:42:26 +0000 (11:42 +0300)]
Fix 'ISO C90 forbids mixed declarations and code' compiler warning

* pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS]
(GC_thread_exit_proc): Move GC_log_printf() call down to be after local
variables declarations.
* thread_local_alloc.c [THREAD_LOCAL_ALLOC && USE_PTHREAD_SPECIFIC
&& !USE_WIN32_SPECIFIC]: Add {} to have "k" local variable declaration
before any statement in a block.

8 years agoFix local variable declarations in disclaim_bench
Ivan Maidanski [Wed, 19 Oct 2016 08:09:33 +0000 (11:09 +0300)]
Fix local variable declarations in disclaim_bench

* tests/disclaim_bench.c (main): Place (move) tI, tF local variable
declarations (in the block) before any statement.

8 years agoFix typo in CHECK_GCLIB_VERSION name (test)
Ivan Maidanski [Thu, 13 Oct 2016 08:37:21 +0000 (11:37 +0300)]
Fix typo in CHECK_GCLIB_VERSION name (test)

* tests/test.c (CHECK_GCLIB_VERSION): Fix typo in macro name.

8 years agoWorkaround 'resource leak' error reported by cppcheck (tools, test)
Ivan Maidanski [Thu, 13 Oct 2016 08:33:17 +0000 (11:33 +0300)]
Workaround 'resource leak' error reported by cppcheck (tools, test)

* tests/test.c [GC_GCJ_SUPPORT && TEST_WITH_SYSTEM_MALLOC] (reverse):
Call GC_noop1 for malloc() result.
* tools/if_not_there.c (main): Move "f" local variable assignments
outside conditional expression.

8 years agoEliminate 'potential overflow' static analyzer warning in test
Ivan Maidanski [Tue, 4 Oct 2016 07:28:18 +0000 (10:28 +0300)]
Eliminate 'potential overflow' static analyzer warning in test

* tests/subthread_create.c (entry): Replace (int)(int_v1 - uint_v2)
expression with int_v1 - (int)uint_v2.

8 years agoCode refactoring of tests/subthread_create regarding AO add primitive
Ivan Maidanski [Thu, 29 Sep 2016 21:16:43 +0000 (00:16 +0300)]
Code refactoring of tests/subthread_create regarding AO add primitive

* tests/subthread_create.c (entry): Use AO_fetch_and_add1(&v) instead
of AO_fetch_and_add(&v,1).