]> granicus.if.org Git - gc/log
gc
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 agoEliminate 'ISO C forbids an empty translation unit' GCC pedantic warning
Ivan Maidanski [Fri, 21 Oct 2016 08:18:22 +0000 (11:18 +0300)]
Eliminate 'ISO C forbids an empty translation unit' GCC pedantic warning

"extern int GC_quiet" is added to suppress compiler warning.

* extra/msvc_dbg.c [_M_AMD64 || !_MSC_VER] (GC_quiet): Declare external
variable.

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 agoEliminate 'scope of variable can be reduced' warning in write_fault_handler
Ivan Maidanski [Wed, 19 Oct 2016 08:42:24 +0000 (11:42 +0300)]
Eliminate 'scope of variable can be reduced' warning in write_fault_handler

* 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 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 '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 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 '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 '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 '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 '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 agoEliminate 'constructor with 1 argument is not explicit' warnings in test_cpp
Ivan Maidanski [Tue, 18 Oct 2016 08:50:14 +0000 (11:50 +0300)]
Eliminate 'constructor with 1 argument is not explicit' warnings in test_cpp
(fix commit 569fd66)

* tests/test_cpp.cc (GC_ATTR_EXPLICIT): Define macro in the same way as
in include/gc_allocator.h.

8 years agoWorkaround 'Uninitialized variable' cppcheck errors
Ivan Maidanski [Tue, 18 Oct 2016 08:39:17 +0000 (11:39 +0300)]
Workaround 'Uninitialized variable' cppcheck errors

* extra/AmigaOS.c [GC_AMIGA_DS] (GC_register_data_segments): Initialize
myseglist outside conditional statement.
* mach_dep.c [GETCONTEXT_FPU_EXCMASK_BUG && X86_64]
(GC_with_callee_saves_pushed): Call GC_noop1(&old_fcw) (before asm
fstcw) if CPPCHECK.
* mach_dep.c [!HAVE_BUILTIN_UNWIND_INIT] (GC_with_callee_saves_pushed):
Replace regs with &regs.
* os_dep.c [!MSWIN32 && !GC_OPENBSD_THREADS && ...]
(GC_get_main_stack_base): Set result to NULL if CPPCHECK but none of
HEURISTIC* and *STACKBOTTOM defined.

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 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 agoFix 'variable assigned a value that is never used' cppcheck style warnings
Ivan Maidanski [Mon, 17 Oct 2016 22:42:22 +0000 (01:42 +0300)]
Fix 'variable assigned a value that is never used' cppcheck style warnings

* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Remove
datastart local variable.
* extra/AmigaOS.c [GC_AMIGA_DS] (GC_register_data_segments): Remove
num local variable.
* extra/MacOS.c (firstTime): Remove.
* extra/MacOS.c (GC_MacTemporaryNewPtr): Do not define firstTime if
SHARED_LIBRARY_BUILD.
* extra/MacOS.c (GC_MacFreeTemporaryMemory): Do not define (and update)
totalMemoryUsed if SHARED_LIBRARY_BUILD.
* extra/msvc_dbg.c (GetDescriptionFromAddress): Do not assign size
variable when its value no longer used.

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 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 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 more 'scope of variable can be reduced' cppcheck style warnings
Ivan Maidanski [Fri, 14 Oct 2016 16:22:08 +0000 (19:22 +0300)]
Eliminate more 'scope of variable can be reduced' cppcheck style warnings

* 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.
* 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.

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 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 '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 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 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 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 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 agoEliminate 'scope of variable can be reduced' cppcheck warning in allchblk
Ivan Maidanski [Wed, 5 Oct 2016 20:58:00 +0000 (23:58 +0300)]
Eliminate 'scope of variable can be reduced' cppcheck warning in allchblk

* allchblk.c [USE_MUNMAP] (GC_merge_unmapped): Move local variable
declarations to the inner scope where the variables are actually used.

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 more 'scope of variable can be reduced' cppcheck style warnings
Ivan Maidanski [Tue, 4 Oct 2016 20:27:53 +0000 (23:27 +0300)]
Eliminate more 'scope of variable can be reduced' cppcheck style warnings

* 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.

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 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 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 agoFix printf format specifiers in extra files
Ivan Maidanski [Thu, 29 Sep 2016 21:53:23 +0000 (00:53 +0300)]
Fix printf format specifiers in extra files
(to eliminate cppcheck warnings)

* extra/MacOS.c (GC_MacFreeTemporaryMemory): Cast GC_gc_no to unsigned
long, and adjust fprintf format specifier appropriately.
* extra/msvc_dbg.c (GetDescriptionFromAddress): Cast line_number to
int when passed to wsprintf() to match format specifier.

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).

8 years agoEliminate 'FP divide-by-zero' static analyzer warning
Ivan Maidanski [Thu, 29 Sep 2016 08:02:31 +0000 (11:02 +0300)]
Eliminate 'FP divide-by-zero' static analyzer warning

* tests/disclaim_bench.c (main): Print "N/A" (i.e. do not invoke
printf with t/(double)free_count) if free_count <= 0.

8 years agoSkip thread suspend/resume API testing for Tru64 (OSF1)
Ivan Maidanski [Wed, 28 Sep 2016 22:30:42 +0000 (01:30 +0300)]
Skip thread suspend/resume API testing for Tru64 (OSF1)
(fix commit 8ff3262)

OSF1 has GC_retry_signals on by default but this is not supported by
thread suspend/resume API yet.

* tests/test.c [GC_PTHREADS && GC_ENABLE_SUSPEND_THREAD]
(fork_a_thread): Do not test GC_suspend/resume_thread if
GC_OSF1_THREADS.

8 years agoAdd more cases to huge_test to cover sizes close to word-type maximum
Ivan Maidanski [Wed, 28 Sep 2016 21:32:47 +0000 (00:32 +0300)]
Add more cases to huge_test to cover sizes close to word-type maximum

* tests/huge_test.c (GC_WORD_MAX): New macro.
* tests/huge_test.c (GC_SWORD_MAX): Use GC_WORD_MAX.
* tests/huge_test.c (main): Add GC_SWORD_MAX+1, GC_WORD_MAX,
GC_WORD_MAX-4/8/16/1024 test cases.

8 years agoEliminate 'write to memory that was const-qualified' code analyzer warning
Ivan Maidanski [Wed, 28 Sep 2016 08:32:55 +0000 (11:32 +0300)]
Eliminate 'write to memory that was const-qualified' code analyzer warning

* cord/cordbscs.c (CORD_from_fn): Rename to CORD_from_fn_inner; make it
static; change return type from CORD to CordRep*; define public
CORD_from_fn which simply calls CORD_from_fn_inner (with the type cast
to CORD).
* cord/cordbscs.c (CORD_substr_closure): Call CORD_from_fn_inner
instead of CORD_from_fn (thus remove the cast from const type to
a non-const one).

8 years agoRevert "Workaround 'struct member Generic::null never used' cppcheck style warning"
Ivan Maidanski [Wed, 28 Sep 2016 07:30:07 +0000 (10:30 +0300)]
Revert "Workaround 'struct member Generic::null never used' cppcheck style warning"
(after commit cbc51ee)

This reverts commit 3fea666ef34f90b2c04095274c449b0b7978d756.

The reverted commit is not needed anymore because commit cbc51ee
adds function.null value check.

8 years agoFix CORD_substr_closure for the case when CORD_from_fn returns C string
Ivan Maidanski [Wed, 28 Sep 2016 07:27:12 +0000 (10:27 +0300)]
Fix CORD_substr_closure for the case when CORD_from_fn returns C string

* cord/cordbscs.c (CORD_substr_closure): Change type of "result" local
variable from CORD to CordRep* (insert necessary type casts); update
function.header only if function.null field is zero (i.e. CORD_from_fn
returned pointer to CordRep, not a pointer to C character string).

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 agoEliminate 'deref-of-null' static analyzer warning in register_finalizer
Ivan Maidanski [Tue, 27 Sep 2016 17:39:44 +0000 (20:39 +0300)]
Eliminate 'deref-of-null' static analyzer warning in register_finalizer

* finalize.c (GC_register_finalizer_inner): Add GC_ASSERT that fn and
hhdr are non-NULL (instead of specifying this in a comment) if new_fo
is non-NULL (new_fo is returned by GC_oom_fn).

8 years agoFix 'label cannot be reached' static analyzer warning in disclaim_test
Ivan Maidanski [Tue, 27 Sep 2016 17:23:19 +0000 (20:23 +0300)]
Fix 'label cannot be reached' static analyzer warning in disclaim_test

* disclaim_test.c (GROW_LIMIT): Define to MUTATE_CNT/10 (instead of
10000000), so that it is always less than MUTATE_CNT (thus
i > GROW_LIMIT is not always false, thus all switch cases are
reachable).

8 years agoFix GC_bytes_allocd incrementation in case of allocation failure
Ivan Maidanski [Tue, 27 Sep 2016 17:05:19 +0000 (20:05 +0300)]
Fix GC_bytes_allocd incrementation in case of allocation failure

* malloc.c (GC_generic_malloc_inner,
GC_generic_malloc_inner_ignore_off_page, GC_generic_malloc): Increment
GC_bytes_allocd only if the allocation successful (op != NULL).
* mallocx.c (GC_generic_malloc_ignore_off_page): Likewise.

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 agoCode refactoring of huge_test
Ivan Maidanski [Tue, 27 Sep 2016 07:47:00 +0000 (10:47 +0300)]
Code refactoring of huge_test

* tests/huge_test.c [!GC_MAXIMUM_HEAP_SIZE] (GC_MAXIMUM_HEAP_SIZE,
GC_INITIAL_HEAP_SIZE): Define (before include gc.h); move the comment
from main().
* tests/huge_test.c (CHECK_ALLOC_FAILED): New macro.
* tests/huge_test.c (main): Remove "r" local variable; do not call
GC_set_max_heap_size and GC_expand_hp explicitly (as it is done
by GC_INIT provided GC_MAXIMUM_HEAP_SIZE and GC_INITIAL_HEAP_SIZE are
defined); use CHECK_ALLOC_FAILED (instead of if/fprintf/exit).

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 page calculation in checksums
Ivan Maidanski [Fri, 23 Sep 2016 06:39:18 +0000 (09:39 +0300)]
Fix page calculation in checksums

While consistent use of rounding mode for computing GC_faulted entries
is ok, the proper way of getting page number of an address is just to
clear the lowest bits of the latter.

* checksums.c (GC_record_fault, GC_was_faulted): Do not round-up when
computing page.
* checksums.c (GC_record_fault): Add assertion that GC_page_size is
initialized.

8 years agoTravis CI configuration: temporarily remove --enable-handle-fork
Ivan Maidanski [Wed, 21 Sep 2016 18:29:55 +0000 (21:29 +0300)]
Travis CI configuration: temporarily remove --enable-handle-fork
(while OS X handle-fork is not fixed)

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 commits 83231d04e1a6f9)

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

8 years agoFix typo in comment of GC_lock (Win32)
Ivan Maidanski [Mon, 19 Sep 2016 21:18:28 +0000 (00:18 +0300)]
Fix typo in comment of GC_lock (Win32)

* win32_threads.c [USE_PTHREAD_LOCKS] (GC_lock): Fix typo in comment
("pthread_mutex_trylock").

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 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

* 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 agoFix double multiplication of lb by n in calloc_explicitly_typed
Ivan Maidanski [Thu, 15 Sep 2016 06:47:23 +0000 (09:47 +0300)]
Fix double multiplication of lb by n in calloc_explicitly_typed

* typd_mlc.c (GC_calloc_explicitly_typed): Do not multiply lb by n
twice (when passed to GC_malloc in case of
GC_general_register_disappearing_link fails).

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

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 (as empty) unless
already defined in included gc_allocator.h.

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 agoWorkaround 'suspicious pointer subtraction' cppcheck warning in gc_cpp
Ivan Maidanski [Wed, 14 Sep 2016 06:21:02 +0000 (09:21 +0300)]
Workaround 'suspicious pointer subtraction' cppcheck warning in gc_cpp

* include/gc_cpp.h (gc_cleanup::gc_cleanup): Add extra parentheses
around (char*)this to outline that "this" pointer subtraction is
intentional (i.e., "this->" was not intended).

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 agoEliminate 'C-style pointer casting' cppcheck style warnings in test
Ivan Maidanski [Tue, 13 Sep 2016 18:22:24 +0000 (21:22 +0300)]
Eliminate 'C-style pointer casting' cppcheck style warnings in test

* tests/test_cpp.cc (D::CleanUp, main): Use static_cast instead of
C-style pointer cast.

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 agoWorkaround 'va_list used before va_start' cppcheck error in cord
Ivan Maidanski [Mon, 12 Sep 2016 18:55:25 +0000 (21:55 +0300)]
Workaround 'va_list used before va_start' cppcheck error in cord

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

* cord/cordprnt.c (CORD_vsprintf) [CPPCHECK]: Force to use va_copy
and va_end.
* cord/cordprnt.c (CORD_vsprintf): Set res to -1 if invalid format
specifier (instead of immediate return -1); call va_end at a single
place.

8 years agoWorkaround 'struct member Generic::null never used' cppcheck style warning
Ivan Maidanski [Thu, 1 Sep 2016 14:00:37 +0000 (17:00 +0300)]
Workaround 'struct member Generic::null never used' cppcheck style warning

* cord/cordbscs.c (CORD_from_fn): Check that 'null' field of the
allocated Function object is zero.

8 years agoEliminate 'checking if unsigned variable is <0' cppcheck style warning
Ivan Maidanski [Mon, 29 Aug 2016 12:58:00 +0000 (15:58 +0300)]
Eliminate 'checking if unsigned variable is <0' cppcheck style warning

* cord/cordbscs.c (CORD_from_fn, CORD_substr): Do not expect size_t
value to be negative (replace <=0 comparison with ==0 one).
* cord/cordxtra.c (CORD_cmp): Likewise.
* cord/cordbscs.c (CORD_substr): Remove obsolete comment (about SunOS 4
which had signed size_t type).

8 years agoEliminate 'condition is always true' cppcheck style warning
Ivan Maidanski [Mon, 29 Aug 2016 12:25:26 +0000 (15:25 +0300)]
Eliminate 'condition is always true' cppcheck style warning

* cord/cordprnt.c (CORD_vsprintf): Comment out always-true expression
about long_arg.

8 years agoEliminate 'scope of variable can be reduced' cppcheck warnings
Ivan Maidanski [Sat, 27 Aug 2016 05:48:02 +0000 (08:48 +0300)]
Eliminate 'scope of variable can be reduced' cppcheck warnings

* cord/cordbscs.c (CORD_cat_char_star, CORD_from_fn,
CORD_substr_checked, CORD_riter4, CORD_init_min_len): Move local
variable declaration to the inner scope where the variable is used.
* cord/cordxtra.c (CORD_cmp, CORD_ncmp, CORD_from_file_eager): Likewise.
* cord/tests/cordtest.c (test_basics): Likewise.
* cord/tests/de.c (line_pos, replace_line): Likewise.
* dbg_mlc.c (GC_generate_random_heap_address): Likewise.
* mark.c (GC_print_trace_inner): Likewise.
* misc.c (GC_printf): Likewise.
* cord/cordbscs.c (CORD_cat_char_star, CORD_from_fn,
CORD_substr_checked, CORD_riter4, CORD_init_min_len): Remove "register"
keyword for the moved variable.
* cord/cordxtra.c (CORD_cmp, CORD_ncmp, CORD_from_file_eager): Likewise.
* cord/tests/de.c (replace_line): Likewise.

8 years agoEliminate CSA false warning about null dereference in array_mark_proc
Ivan Maidanski [Fri, 26 Aug 2016 07:04:39 +0000 (10:04 +0300)]
Eliminate CSA false warning about null dereference 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').

* typd_mlc.c (GC_array_mark_proc): Add assertion that mark_stack_ptr is
non-NULL (thus orig_mark_stack_ptr is non-NULL too).

8 years agoEliminate 'value stored is never read' warning of Clang static analyzer
Ivan Maidanski [Fri, 26 Aug 2016 06:49:30 +0000 (09:49 +0300)]
Eliminate 'value stored is never read' warning of Clang static analyzer

* tools/setjmp_t.c (g): Declare (before "main").
* tools/setjmp_t.c (main): Call g(x) to use "x" variable value
after x=2.

8 years agoFix Clang static analyzer warning about not found gc_priv.h in extra files
Ivan Maidanski [Fri, 26 Aug 2016 06:41:35 +0000 (09:41 +0300)]
Fix Clang static analyzer warning about not found gc_priv.h in extra files

* extra/AmigaOS.c: Include "private/gc_priv.h" instead of "gc_priv.h".
* extra/MacOS.c: Likewise.

8 years agoFix header filename in gcconfig.h comment
Ivan Maidanski [Fri, 26 Aug 2016 06:29:35 +0000 (09:29 +0300)]
Fix header filename in gcconfig.h comment

* include/private/gcconfig.h: Replace include gc_private.h with gc.h
in comment (the header is supposed to be included to declare
GC_stackbottom).

8 years agoEliminate 'cast to void* from int' compiler warnings (Darwin/x64)
Ivan Maidanski [Thu, 18 Aug 2016 22:43:25 +0000 (01:43 +0300)]
Eliminate 'cast to void* from int' compiler warnings (Darwin/x64)

* darwin_stop_world.c (GC_stack_range_for, GC_suspend_thread_list,
GC_stop_world, GC_thread_resume, GC_start_world): Cast thread variable
to pointer via word type.
* darwin_stop_world.c (GC_stop_world): Cast stop_info.mach_thread to
pointer via word type.

8 years agoRefine README about library source downloading
Ivan Maidanski [Thu, 18 Aug 2016 18:34:22 +0000 (21:34 +0300)]
Refine README about library source downloading

* README.md (Download): New section.

8 years agoAdd CI (continuous integration) badges to README
Andy Li [Sat, 6 Aug 2016 16:27:00 +0000 (00:27 +0800)]
Add CI (continuous integration) badges to README

8 years agoFix compilation if configured with --enable-werror on OS X
Ivan Maidanski [Wed, 17 Aug 2016 22:15:20 +0000 (01:15 +0300)]
Fix compilation if configured with --enable-werror on OS X

GC_init_dyld uses _dyld_bind_fully_image_containing_address() which
is deprecated starting from OS X 10.5.

* configure.ac (werror): Add -Wno-deprecated-declarations to
WERROR_CFLAGS if host is darwin.

8 years agoFix 'GetVersion deprecated' compiler warning in os_dep (MS VC)
Ivan Maidanski [Wed, 17 Aug 2016 08:15:08 +0000 (11:15 +0300)]
Fix 'GetVersion deprecated' compiler warning in os_dep (MS VC)

* os_dep.c [MSWIN32] (GC_init_win32): Do not call GetVersion if
VS 2013+ or Win64 target (set GC_wnt to true instead).

8 years agoFix 'incompatible pointer' compiler warning in GC_init_dyld (OS X 64-bit)
Ivan Maidanski [Wed, 17 Aug 2016 06:44:31 +0000 (09:44 +0300)]
Fix 'incompatible pointer' compiler warning in GC_init_dyld (OS X 64-bit)

* dyn_load.c (GC_init_dyld): Cast _dyld_register_func_for_add_image
and _dyld_register_func_for_remove_image argument to void compiler
warning about incompatible pointer types; update relevant comment.

8 years agoTravis CI configuration: Remove default configure options;
Ivan Maidanski [Mon, 15 Aug 2016 21:28:08 +0000 (00:28 +0300)]
Travis CI configuration: Remove default configure options;
move configure to 'script' section

8 years agoAppveyor/Travis CI configuration: limit git clone depth to 50
Ivan Maidanski [Mon, 15 Aug 2016 20:50:43 +0000 (23:50 +0300)]
Appveyor/Travis CI configuration: limit git clone depth to 50

8 years agoAppveyor CI configuration: prefix build version with GC version
Ivan Maidanski [Mon, 15 Aug 2016 20:41:44 +0000 (23:41 +0300)]
Appveyor CI configuration: prefix build version with GC version

8 years agoInitial AppVeyor CI configuration
Andy Li [Sat, 6 Aug 2016 15:22:33 +0000 (23:22 +0800)]
Initial AppVeyor CI configuration

* appveyor.yml: New file (not a part of BDWGC dist).

8 years agoImprove Travis CI configuration (use both compilers, enable more features)
Ivan Maidanski [Thu, 11 Aug 2016 19:55:21 +0000 (22:55 +0300)]
Improve Travis CI configuration (use both compilers, enable more features)

* .travis.yml (compiler): Add (use both gcc and clang)
* .travis.yml (install): Use autogen.sh instead of autoreconf and
automake; add options to configure (to cover more code during testing);
do not invoke make.
* .travis.yml (script): Pass -j to make.

8 years agoWorkaround missing getcontext() in Docker osrf/ubuntu_32bit
Ivan Maidanski [Thu, 11 Aug 2016 08:56:44 +0000 (11:56 +0300)]
Workaround missing getcontext() in Docker osrf/ubuntu_32bit

* mach_dep.c [NO_GETCONTEXT] (GC_with_callee_saves_pushed): Call WARN
instead of ABORT if getcontext() failed; do not set context variable
if getcontext() failed; fallback to other register retrieval methods
(__builtin_unwind_init or setjmp) if context variable is NULL.
* mach_dep.c (GC_with_callee_saves_pushed): Reformat code.

8 years agoInitial configuration for Travis CI
Andy Li [Sat, 6 Aug 2016 15:11:20 +0000 (23:11 +0800)]
Initial configuration for Travis CI

* .travis.yml: New file.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Wed, 10 Aug 2016 10:35:52 +0000 (13:35 +0300)]
Update AUTHORS file

8 years agoCMake: add gctest as a test
Andy Li [Sat, 6 Aug 2016 16:23:11 +0000 (00:23 +0800)]
CMake: add gctest as a test

* CMakeLists.txt: Include CTest.
* tests/CMakeLists.txt: Add gctest as test.

8 years agoFix 'unknown type name GC_INNER' compilation error (FreeBSD)
Ivan Maidanski [Mon, 8 Aug 2016 18:49:20 +0000 (21:49 +0300)]
Fix 'unknown type name GC_INNER' compilation error (FreeBSD)
(fix commit f13a9559)

See issue #132.  The reason of compilation failure is GC_INNER macro
used before its definition.  The solution is to move
GC_FreeBSDGetDataStart prototype from gcconfig.h to gc_priv.h.

* include/private/gc_priv.h [DATASTART_USES_BSDGETDATASTART]
(GC_FreeBSDGetDataStart): Declare.
* include/private/gc_priv.h [DATASTART_USES_BSDGETDATASTART]
(DATASTART_IS_FUNC): Define macro.
* include/private/gcconfig.h [DATASTART_USES_BSDGETDATASTART]
(GC_FreeBSDGetDataStart, DATASTART_IS_FUNC): Remove.

8 years agoBump libgc version (for development)
Ivan Maidanski [Tue, 9 Aug 2016 07:52:36 +0000 (10:52 +0300)]
Bump libgc version (for development)

* README.md: Bump version to 7.7.0.
* configure.ac: Likewise.
* include/gc_version.h (GC_TMP_VERSION_MINOR): Likewise.

8 years ago[7.6.0] gc7_6_0
Ivan Maidanski [Tue, 2 Aug 2016 20:11:42 +0000 (23:11 +0300)]
[7.6.0]

Bump gc version to 7.6.0

* ChangeLog: Set release date.
* README.md: Bump minor version.
* configure.ac (AC_INIT): Likewise.
* include/gc_version.h (GC_TMP_VERSION_MINOR): Likewise.

8 years agoUpdate ChangeLog file (add gc-7.4.4 release date)
Ivan Maidanski [Tue, 2 Aug 2016 20:02:48 +0000 (23:02 +0300)]
Update ChangeLog file (add gc-7.4.4 release date)

8 years agoUpdate ChangeLog file
Ivan Maidanski [Tue, 2 Aug 2016 09:06:37 +0000 (12:06 +0300)]
Update ChangeLog file

8 years agoDo not allow SHORT_DBG_HDRS if KEEP_BACK_PTRS or MAKE_BACK_GRAPH
Ivan Maidanski [Tue, 2 Aug 2016 09:01:48 +0000 (12:01 +0300)]
Do not allow SHORT_DBG_HDRS if KEEP_BACK_PTRS or MAKE_BACK_GRAPH

Otherwise GC_HAS_DEBUG_INFO (defined as (p&1)) might return true
if a non-pointer is stored at the beginning of the tested object
leading further to its corruption by GC_store_back_pointer.
See issue #125 for details.

* include/private/dbg_mlc.h [KEEP_BACK_PTRS || MAKE_BACK_GRAPH]
(GC_HAS_DEBUG_INFO): Add #error (with the appropriate message) in
case of SHORT_DBG_HDRS defined.

8 years agoDo not report multiple load-seg-overflow warnings per one dl-iterate
Ivan Maidanski [Mon, 1 Aug 2016 19:36:57 +0000 (22:36 +0300)]
Do not report multiple load-seg-overflow warnings per one dl-iterate
(fix commit 017bd0a)

* dyn_load.c [HAVE_DL_ITERATE_PHDR && PT_GNU_RELRO]
(load_segs_overflow): New static variable.
* dyn_load.c [HAVE_DL_ITERATE_PHDR && PT_GNU_RELRO]
(GC_register_dynlib_callback): Do not call WARN if load_segs_overflow;
set load_segs_overflow to true after calling WARN.
* dyn_load.c [HAVE_DL_ITERATE_PHDR && PT_GNU_RELRO]
(GC_register_dynamic_libraries_dl_iterate_phdr): Reset
load_segs_overflow.