From: Ivan Maidanski Date: Sat, 28 Jan 2012 18:33:58 +0000 (+0400) Subject: Adjust GC_log_printf format specifiers (regarding signed/unsigned long) X-Git-Tag: gc7_3alpha2~168 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4cc17eb8fa505aa33c941dd19b78a411f32d2bd4;p=gc Adjust GC_log_printf format specifiers (regarding signed/unsigned long) * alloc.c (GC_maybe_gc, GC_expand_hp_inner): Change printf "%ld" format specifier to "%lu" one according to printed value. * backgraph.c (GC_print_back_graph_stats): Likewise. * blacklst.c (GC_default_print_heap_obj_proc, GC_promote_black_lists): Likewise. * gcj_mlc.c (GC_debug_gcj_malloc): Likewise. * mark_rts.c (GC_print_static_roots): Likewise. * alloc.c (GC_stopped_mark): Correct logged GC number. * dbg_mlc.c (GC_print_backtrace): Cast printed value to proper type. * mark.c (GC_mark_from): Likewise. * dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_malloc_stubborn, GC_debug_malloc_atomic, GC_debug_malloc_uncollectable): Change printf "%ld" format specifier for line number to "%d" one. * malloc.c (GC_free): Improve logged message (if LOG_ALLOCS). * thread_local_alloc.c (GC_malloc): Likewise. * os_dep.c (GC_dirty_init): Improve logged message (for VERBOSE level). --- diff --git a/alloc.c b/alloc.c index 360463af..2d6d6bf6 100644 --- a/alloc.c +++ b/alloc.c @@ -365,8 +365,8 @@ STATIC void GC_maybe_gc(void) if (GC_need_full_gc || n_partial_gcs >= GC_full_freq) { if (GC_print_stats) { GC_log_printf( - "***>Full mark for collection %lu after %ld allocd bytes\n", - (unsigned long)GC_gc_no + 1, (long)GC_bytes_allocd); + "***>Full mark for collection %lu after %lu allocd bytes\n", + (unsigned long)GC_gc_no + 1, (unsigned long)GC_bytes_allocd); } GC_promote_black_lists(); (void)GC_reclaim_all((GC_stop_func)0, TRUE); @@ -646,7 +646,7 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func) if (GC_print_stats) { GC_log_printf("Collection %lu reclaimed %ld bytes ---> heapsize = %lu" " bytes" IF_USE_MUNMAP(" (%lu unmapped)") "\n", - (unsigned long)(GC_gc_no - 1), (long)GC_bytes_found, + (unsigned long)GC_gc_no, (long)GC_bytes_found, (unsigned long)GC_heapsize /*, */ COMMA_IF_USE_MUNMAP((unsigned long)GC_unmapped_bytes)); } @@ -1135,7 +1135,7 @@ GC_INNER GC_bool GC_expand_hp_inner(word n) GC_add_to_our_memory((ptr_t)space, bytes); if (space == 0) { if (GC_print_stats) { - GC_log_printf("Failed to expand heap by %ld bytes\n", + GC_log_printf("Failed to expand heap by %lu bytes\n", (unsigned long)bytes); } return(FALSE); diff --git a/backgraph.c b/backgraph.c index cd2fdcd2..6090f8d2 100644 --- a/backgraph.c +++ b/backgraph.c @@ -458,7 +458,7 @@ GC_INNER void GC_traverse_back_graph(void) void GC_print_back_graph_stats(void) { - GC_printf("Maximum backwards height of reachable objects at GC %lu is %ld\n", + GC_printf("Maximum backwards height of reachable objects at GC %lu is %lu\n", (unsigned long) GC_gc_no, (unsigned long)GC_max_height); if (GC_max_height > GC_max_max_height) { GC_max_max_height = GC_max_height; diff --git a/blacklst.c b/blacklst.c index 9fd00167..234aae75 100644 --- a/blacklst.c +++ b/blacklst.c @@ -57,8 +57,8 @@ STATIC void GC_clear_bl(word *); GC_INNER void GC_default_print_heap_obj_proc(ptr_t p) { ptr_t base = GC_base(p); - GC_err_printf("start: %p, appr. length: %ld", base, - (unsigned long)GC_size(base)); + GC_err_printf("start: %p, appr. length: %lu", + base, (unsigned long)GC_size(base)); } GC_INNER void (*GC_print_heap_obj)(ptr_t p) = GC_default_print_heap_obj_proc; @@ -142,7 +142,7 @@ GC_INNER void GC_promote_black_lists(void) GC_incomplete_stack_bl = very_old_stack_bl; GC_total_stack_black_listed = total_stack_black_listed(); if (GC_print_stats == VERBOSE) - GC_log_printf("%ld bytes in heap blacklisted for interior pointers\n", + GC_log_printf("%lu bytes in heap blacklisted for interior pointers\n", (unsigned long)GC_total_stack_black_listed); if (GC_total_stack_black_listed != 0) { GC_black_list_spacing = diff --git a/dbg_mlc.c b/dbg_mlc.c index f061236d..daf8d23b 100644 --- a/dbg_mlc.c +++ b/dbg_mlc.c @@ -212,7 +212,7 @@ GC_err_printf("list of finalizable objects\n\n"); goto out; case GC_REFD_FROM_HEAP: - GC_err_printf("offset %ld in object:\n", (unsigned long)offset); + GC_err_printf("offset %ld in object:\n", (long)offset); /* Take GC_base(base) to get real base, i.e. header. */ GC_print_heap_obj(GC_base(base)); GC_err_printf("\n"); @@ -470,7 +470,7 @@ GC_API void * GC_CALL GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS) GC_err_printf("GC_debug_malloc(%lu) returning NULL (", (unsigned long) lb); GC_err_puts(s); - GC_err_printf(":%ld)\n", (unsigned long)i); + GC_err_printf(":%d)\n", i); return(0); } if (!GC_debugging_started) { @@ -489,7 +489,7 @@ GC_API void * GC_CALL GC_debug_malloc_ignore_off_page(size_t lb, GC_err_printf("GC_debug_malloc_ignore_off_page(%lu) returning NULL (", (unsigned long) lb); GC_err_puts(s); - GC_err_printf(":%lu)\n", (unsigned long)i); + GC_err_printf(":%d)\n", i); return(0); } if (!GC_debugging_started) { @@ -508,7 +508,7 @@ GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb, GC_err_printf("GC_debug_malloc_atomic_ignore_off_page(%lu)" " returning NULL (", (unsigned long)lb); GC_err_puts(s); - GC_err_printf(":%lu)\n", (unsigned long)i); + GC_err_printf(":%d)\n", i); return(0); } if (!GC_debugging_started) { @@ -562,7 +562,7 @@ GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb, GC_err_printf("GC_debug_malloc(%lu) returning NULL (", (unsigned long) lb); GC_err_puts(s); - GC_err_printf(":%lu)\n", (unsigned long)i); + GC_err_printf(":%d)\n", i); return(0); } if (!GC_debugging_started) { @@ -628,7 +628,7 @@ GC_API void * GC_CALL GC_debug_malloc_atomic(size_t lb, GC_EXTRA_PARAMS) GC_err_printf("GC_debug_malloc_atomic(%lu) returning NULL (", (unsigned long) lb); GC_err_puts(s); - GC_err_printf(":%lu)\n", (unsigned long)i); + GC_err_printf(":%d)\n", i); return(0); } if (!GC_debugging_started) { @@ -711,7 +711,7 @@ GC_API void * GC_CALL GC_debug_malloc_uncollectable(size_t lb, GC_err_printf("GC_debug_malloc_uncollectable(%lu) returning NULL (", (unsigned long) lb); GC_err_puts(s); - GC_err_printf(":%lu)\n", (unsigned long)i); + GC_err_printf(":%d)\n", i); return(0); } if (!GC_debugging_started) { @@ -733,7 +733,7 @@ GC_API void * GC_CALL GC_debug_malloc_uncollectable(size_t lb, "GC_debug_malloc_atomic_uncollectable(%lu) returning NULL (", (unsigned long) lb); GC_err_puts(s); - GC_err_printf(":%lu)\n", (unsigned long)i); + GC_err_printf(":%d)\n", i); return(0); } if (!GC_debugging_started) { diff --git a/gcj_mlc.c b/gcj_mlc.c index 5bbcbc69..a749c622 100644 --- a/gcj_mlc.c +++ b/gcj_mlc.c @@ -219,7 +219,7 @@ GC_API void * GC_CALL GC_debug_gcj_malloc(size_t lb, if (result == 0) { GC_oom_func oom_fn = GC_oom_fn; UNLOCK(); - GC_err_printf("GC_debug_gcj_malloc(%ld, %p) returning NULL (", + GC_err_printf("GC_debug_gcj_malloc(%lu, %p) returning NULL (", (unsigned long)lb, ptr_to_struct_containing_descr); GC_err_puts(s); GC_err_printf(":%d)\n", i); diff --git a/malloc.c b/malloc.c index 1400fc32..28ad8a93 100644 --- a/malloc.c +++ b/malloc.c @@ -451,7 +451,7 @@ GC_API void GC_CALL GC_free(void * p) if (p == 0) return; /* Required by ANSI. It's not my fault ... */ # ifdef LOG_ALLOCS - GC_err_printf("GC_free(%p): %lu\n", p, (unsigned long)GC_gc_no); + GC_err_printf("GC_free(%p), GC: %lu\n", p, (unsigned long)GC_gc_no); # endif h = HBLKPTR(p); hhdr = HDR(h); diff --git a/mark.c b/mark.c index 2d4f8dec..87e2b4a9 100644 --- a/mark.c +++ b/mark.c @@ -795,8 +795,8 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack, # ifdef ENABLE_TRACE if (GC_trace_addr >= current_p && GC_trace_addr < limit) { - GC_log_printf("GC:%u Tracing from %p len %lu\n", - (int)GC_gc_no, current_p, (unsigned long)descr); + GC_log_printf("GC:%u Tracing from %p, length is %lu\n", + (unsigned)GC_gc_no, current_p, (unsigned long)descr); } # endif /* ENABLE_TRACE */ /* The simple case in which we're scanning a range. */ diff --git a/mark_rts.c b/mark_rts.c index e95067ef..348d6143 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -53,10 +53,10 @@ static int n_root_sets = 0; GC_static_roots[i].r_tmp ? " (temporary)" : ""); total += GC_static_roots[i].r_end - GC_static_roots[i].r_start; } - GC_printf("Total size: %ld\n", (unsigned long) total); + GC_printf("Total size: %lu\n", (unsigned long) total); if (GC_root_size != total) { - GC_err_printf("GC_root_size incorrect: %ld!!\n", - (long) GC_root_size); + GC_err_printf("GC_root_size incorrect: %lu!!\n", + (unsigned long) GC_root_size); } } #endif /* !NO_DEBUGGING */ diff --git a/os_dep.c b/os_dep.c index 5f44f722..7cdd3bb5 100644 --- a/os_dep.c +++ b/os_dep.c @@ -3634,7 +3634,7 @@ GC_INNER void GC_dirty_init(void) if (GC_bytes_allocd != 0 || GC_bytes_allocd_before_gc != 0) { memset(GC_written_pages, 0xff, sizeof(page_hash_table)); if (GC_print_stats == VERBOSE) - GC_log_printf("Allocated bytes:%lu:all pages may have been written\n", + GC_log_printf("Allocated %lu bytes: all pages may have been written\n", (unsigned long)(GC_bytes_allocd + GC_bytes_allocd_before_gc)); } diff --git a/thread_local_alloc.c b/thread_local_alloc.c index 82523cd6..72d09c83 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -177,8 +177,8 @@ GC_API void * GC_CALL GC_malloc(size_t bytes) GC_FAST_MALLOC_GRANS(result, granules, tiny_fl, DIRECT_GRANULES, NORMAL, GC_core_malloc(bytes), obj_link(result)=0); # ifdef LOG_ALLOCS - GC_err_printf("GC_malloc(%u) = %p : %u\n", - (unsigned)bytes, result, (unsigned)GC_gc_no); + GC_err_printf("GC_malloc(%lu) = %p, GC: %lu\n", + (unsigned long)bytes, result, (unsigned long)GC_gc_no); # endif return result; }