From: Mathieu Desnoyers Date: Mon, 21 Sep 2015 19:32:57 +0000 (-0400) Subject: Cleanup: tests: Branch condition evaluates to a garbage value X-Git-Tag: v0.9.0~30 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6a00c945d10d68e174c9fe96b2a98eb124b0d77e;p=urcu.git Cleanup: tests: Branch condition evaluates to a garbage value scan-build reported this: Logic error Branch condition evaluates to a garbage value tests /benchmark /test_urcu_hash_rw.c 170 Logic error Branch condition evaluates to a garbage value tests /benchmark /test_urcu_hash_rw.c 274 It should never happen based on code review, but silence this warning by initializing to NULL. Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/benchmark/test_urcu_hash_rw.c b/tests/benchmark/test_urcu_hash_rw.c index 8802b9c..d2bd0b4 100644 --- a/tests/benchmark/test_urcu_hash_rw.c +++ b/tests/benchmark/test_urcu_hash_rw.c @@ -121,7 +121,6 @@ void *test_hash_rw_thr_reader(void *_count) void *test_hash_rw_thr_writer(void *_count) { struct lfht_test_node *node; - struct cds_lfht_node *ret_node; struct cds_lfht_iter iter; struct wr_count *count = _count; int ret; @@ -141,6 +140,8 @@ void *test_hash_rw_thr_writer(void *_count) cmm_smp_mb(); for (;;) { + struct cds_lfht_node *ret_node = NULL; + if ((addremove == AR_ADD || add_only) || (addremove == AR_RANDOM && rand_r(&URCU_TLS(rand_lookup)) & 1)) { node = malloc(sizeof(struct lfht_test_node)); @@ -231,7 +232,6 @@ void *test_hash_rw_thr_writer(void *_count) int test_hash_rw_populate_hash(void) { struct lfht_test_node *node; - struct cds_lfht_node *ret_node; if (!init_populate) return 0; @@ -247,6 +247,8 @@ int test_hash_rw_populate_hash(void) } while (URCU_TLS(nr_add) < init_populate) { + struct cds_lfht_node *ret_node = NULL; + node = malloc(sizeof(struct lfht_test_node)); lfht_test_node_init(node, (void *)(((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % init_pool_size) + init_pool_offset),