Cleanup: fix cppcheck errors
[urcu.git] / tests / test_urcu_lfs.c
index 5886ce86de50c1ab2c25c61a172d895fa4a33a53..8c28c2ba4708f7d631241ee312556e1c03c6c3fb 100644 (file)
@@ -67,7 +67,6 @@ static inline pid_t gettid(void)
 #endif
 #include <urcu.h>
 #include <urcu/cds.h>
-#include <urcu-defer.h>
 
 static volatile int test_go, test_stop;
 
@@ -106,9 +105,10 @@ typedef unsigned long cpu_set_t;
 
 static void set_affinity(void)
 {
+#if HAVE_SCHED_SETAFFINITY
        cpu_set_t mask;
-       int cpu;
-       int ret;
+       int cpu, ret;
+#endif /* HAVE_SCHED_SETAFFINITY */
 
        if (!use_affinity)
                return;
@@ -221,18 +221,12 @@ void free_node_cb(struct rcu_head *head)
 void *thr_dequeuer(void *_count)
 {
        unsigned long long *count = _count;
-       int ret;
 
        printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
                        "dequeuer", pthread_self(), (unsigned long)gettid());
 
        set_affinity();
 
-       ret = rcu_defer_register_thread();
-       if (ret) {
-               printf("Error in rcu_defer_register_thread\n");
-               exit(-1);
-       }
        rcu_register_thread();
 
        while (!test_go)
@@ -242,13 +236,14 @@ void *thr_dequeuer(void *_count)
 
        for (;;) {
                struct cds_lfs_node_rcu *snode;
-               struct test *node;
 
                rcu_read_lock();
                snode = cds_lfs_pop_rcu(&s);
-               node = caa_container_of(snode, struct test, list);
                rcu_read_unlock();
-               if (node) {
+               if (snode) {
+                       struct test *node;
+
+                       node = caa_container_of(snode, struct test, list);
                        call_rcu(&node->rcu, free_node_cb);
                        URCU_TLS(nr_successful_dequeues)++;
                }
@@ -260,7 +255,6 @@ void *thr_dequeuer(void *_count)
        }
 
        rcu_unregister_thread();
-       rcu_defer_unregister_thread();
 
        printf_verbose("dequeuer thread_end, thread id : %lx, tid %lu, "
                       "dequeues %llu, successful_dequeues %llu\n",
This page took 0.022945 seconds and 4 git commands to generate.