summaryrefslogtreecommitdiff
path: root/darwin_stop_world.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-01-01 01:01:21 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-01-01 01:01:21 +0300
commit6f07b96cf488db20a4de4f10cea0675743b2621c (patch)
tree9308bf6018ec71dd567c93c7d165914456efb7e1 /darwin_stop_world.c
parent2cd04cd95cef35180a021e83f7fb9ac268e6ab3b (diff)
downloadbdwgc-6f07b96cf488db20a4de4f10cea0675743b2621c.tar.gz
Fix 'unused crtn var' and 'possible null dereference' cppcheck warnings
(fix of commits 7eb49a4e6, 128c0ec3) Issue #362 (bdwgc). * darwin_stop_world.c (GC_stack_range_for): Define crtn local variable only if DARWIN_DONT_PARSE_STACK. * darwin_stop_world.c [DARWIN_DONT_PARSE_STACK && CPPCHECK] (GC_stack_range_for): Call ABORT if p is NULL (before crtn = p->crtn).
Diffstat (limited to 'darwin_stop_world.c')
-rw-r--r--darwin_stop_world.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/darwin_stop_world.c b/darwin_stop_world.c
index 53824970..c64b4bfb 100644
--- a/darwin_stop_world.c
+++ b/darwin_stop_world.c
@@ -142,7 +142,9 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
mach_port_t my_thread, ptr_t *paltstack_lo,
ptr_t *paltstack_hi, GC_bool *pfound_me)
{
- GC_stack_context_t crtn;
+# ifdef DARWIN_DONT_PARSE_STACK
+ GC_stack_context_t crtn;
+# endif
ptr_t lo;
if (thread == my_thread) {
@@ -327,6 +329,9 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
UNUSED_ARG(paltstack_hi);
# else
/* p is guaranteed to be non-NULL regardless of GC_query_task_threads. */
+# ifdef CPPCHECK
+ if (NULL == p) ABORT("Bad GC_stack_range_for call");
+# endif
crtn = p -> crtn;
*phi = EXPECT((p -> flags & MAIN_THREAD) == 0, TRUE) ? crtn -> stack_end
: GC_stackbottom;