From e1d458ff22f2ceb627e6ec015da6109c5f6fce4b Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 21 Apr 2017 10:10:58 +0300 Subject: [PATCH] Workaround 'resource leak' false positives in AO_malloc, add_elements * src/atomic_ops_stack.c [AO_HAVE_compare_double_and_swap_double && LINT2] (AO_noop_sink): New global volatile variable. * src/atomic_ops_stack.c [AO_HAVE_compare_double_and_swap_double && LINT2] (AO_stack_push_release): Store element value to AO_noop_sink; add comment. --- src/atomic_ops_stack.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/atomic_ops_stack.c b/src/atomic_ops_stack.c index e199bff..d59fac9 100644 --- a/src/atomic_ops_stack.c +++ b/src/atomic_ops_stack.c @@ -198,6 +198,10 @@ AO_stack_pop_explicit_aux_acquire(volatile AO_t *list, AO_stack_aux * a) #if defined(AO_HAVE_compare_double_and_swap_double) +#ifdef LINT2 + volatile /* non-static */ AO_t AO_noop_sink; +#endif + void AO_stack_push_release(AO_stack_t *list, AO_t *element) { AO_t next; @@ -211,6 +215,10 @@ void AO_stack_push_release(AO_stack_t *list, AO_t *element) /* by Treiber. Pop is still safe, since we run into the ABA */ /* problem only if there were both intervening "pop"s and "push"es. */ /* In that case we still see a change in the version number. */ +# ifdef LINT2 + /* Instruct static analyzer that element is not lost. */ + AO_noop_sink = (AO_t)element; +# endif } AO_t *AO_stack_pop_acquire(AO_stack_t *list) -- 2.50.1