summaryrefslogtreecommitdiff
path: root/dbg_mlc.c
diff options
context:
space:
mode:
authorivmai <ivmai>2011-03-13 20:37:24 +0100
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:56 +0200
commit618a4c49d9c8c50e95f075e11e826aded68518cd (patch)
tree8c90cb5dd2fcf502fcdf9dde7f9ee6f5e6ad9276 /dbg_mlc.c
parent667fb0512a70f7756a2c64f0e71c03e1e49a8a4c (diff)
2011-03-13 Ivan Maidanski <ivmai@mail.ru>
* dbg_mlc.c (GC_get_back_ptr_info, GC_print_obj, GC_print_smashed_obj, GC_debug_free_inner): Add a code for a LINT-like tool to instruct it that the function is invoked only with valid parameters (otherwise a SEGV is ok); recognize LINT2 new macro. * misc.c (GC_abort): Instruct a LINT-like tool that the function never returns in fact. * os_dep.c (GC_linux_stack_base): Check for read buffer overflow; close the file immediately after read; use STRTOULL() instead of decoding the address number manually. * include/private/gc_priv.h (EXPECT): Don't specify outcome for a LINT-like tool. * include/private/gc_priv.h (GC_all_interior_pointers): Instruct a LINT-like tool that the value is restricted to zero and one only (required since the variable is global and its value is used as a part of array index expression is some places).
Diffstat (limited to 'dbg_mlc.c')
-rw-r--r--dbg_mlc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/dbg_mlc.c b/dbg_mlc.c
index 29e9a89..42561fc 100644
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -101,6 +101,13 @@ GC_API void GC_CALL GC_register_finalizer_no_order(void * obj,
oh * hdr = (oh *)GC_base(dest);
ptr_t bp;
ptr_t bp_base;
+
+# ifdef LINT2
+ /* Explicitly instruct the code analysis tool that */
+ /* GC_get_back_ptr_info is not expected to be called with an */
+ /* incorrect "dest" value. */
+ if (!hdr) ABORT("Invalid GC_get_back_ptr_info argument");
+# endif
if (!GC_HAS_DEBUG_INFO((ptr_t) hdr)) return GC_NO_SPACE;
bp = GC_REVEAL_POINTER(hdr -> oh_back_ptr);
if (MARKED_FOR_FINALIZATION == bp) return GC_FINALIZER_REFD;
@@ -386,6 +393,9 @@ STATIC void GC_print_obj(ptr_t p)
oh * ohdr = (oh *)GC_base(p);
GC_ASSERT(I_DONT_HOLD_LOCK());
+# ifdef LINT2
+ if (!ohdr) ABORT("Invalid GC_print_obj argument");
+# endif
GC_err_printf("%p (", ((ptr_t)ohdr + sizeof(oh)));
GC_err_puts(ohdr -> oh_string);
# ifdef SHORT_DBG_HDRS
@@ -418,6 +428,9 @@ STATIC void GC_debug_print_heap_obj_proc(ptr_t p)
oh * ohdr = (oh *)GC_base(p);
GC_ASSERT(I_DONT_HOLD_LOCK());
+# ifdef LINT2
+ if (!ohdr) ABORT("Invalid GC_print_smashed_obj argument");
+# endif
if (clobbered_addr <= (ptr_t)(&(ohdr -> oh_sz))
|| ohdr -> oh_string == 0) {
GC_err_printf(
@@ -773,6 +786,9 @@ GC_API void GC_CALL GC_debug_free(void * p)
{
ptr_t base = GC_base(p);
GC_ASSERT((ptr_t)p - (ptr_t)base == sizeof(oh));
+# ifdef LINT2
+ if (!base) ABORT("Invalid GC_debug_free_inner argument");
+# endif
# ifndef SHORT_DBG_HDRS
/* Invalidate size */
((oh *)base) -> oh_sz = GC_size(base);