Cleanup: fix cppcheck errors
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 22 Oct 2012 21:34:31 +0000 (17:34 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 22 Oct 2012 21:34:31 +0000 (17:34 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
18 files changed:
rculfhash.c
tests/test_mutex.c
tests/test_perthreadlock.c
tests/test_rwlock.c
tests/test_uatomic.c
tests/test_urcu.c
tests/test_urcu_assign.c
tests/test_urcu_bp.c
tests/test_urcu_defer.c
tests/test_urcu_gc.c
tests/test_urcu_hash.c
tests/test_urcu_lfq.c
tests/test_urcu_lfs.c
tests/test_urcu_qsbr.c
tests/test_urcu_qsbr_gc.c
tests/test_urcu_wfcq.c
tests/test_urcu_wfq.c
tests/test_urcu_wfs.c

index b8fbb6481d9291a6226f2200f8374b810ffd34af..7050d5c47b224c9d91b21610478a3a903aa74789 100644 (file)
@@ -381,7 +381,8 @@ uint8_t bit_reverse_u8(uint8_t v)
        return BitReverseTable256[v];
 }
 
-static __attribute__((unused))
+#if (CAA_BITS_PER_LONG == 32)
+static
 uint32_t bit_reverse_u32(uint32_t v)
 {
        return ((uint32_t) bit_reverse_u8(v) << 24) | 
@@ -389,8 +390,8 @@ uint32_t bit_reverse_u32(uint32_t v)
                ((uint32_t) bit_reverse_u8(v >> 16) << 8) | 
                ((uint32_t) bit_reverse_u8(v >> 24));
 }
-
-static __attribute__((unused))
+#else
+static
 uint64_t bit_reverse_u64(uint64_t v)
 {
        return ((uint64_t) bit_reverse_u8(v) << 56) | 
@@ -402,6 +403,7 @@ uint64_t bit_reverse_u64(uint64_t v)
                ((uint64_t) bit_reverse_u8(v >> 48) << 8) |
                ((uint64_t) bit_reverse_u8(v >> 56));
 }
+#endif
 
 static
 unsigned long bit_reverse_ulong(unsigned long v)
@@ -589,8 +591,6 @@ static void ht_init_nr_cpus_mask(void)
 static
 void alloc_split_items_count(struct cds_lfht *ht)
 {
-       struct ht_items_count *count;
-
        if (nr_cpus_mask == -1) {
                ht_init_nr_cpus_mask();
                if (nr_cpus_mask < 0)
@@ -602,7 +602,8 @@ void alloc_split_items_count(struct cds_lfht *ht)
        assert(split_count_mask >= 0);
 
        if (ht->flags & CDS_LFHT_ACCOUNTING) {
-               ht->split_count = calloc(split_count_mask + 1, sizeof(*count));
+               ht->split_count = calloc(split_count_mask + 1,
+                                       sizeof(struct ht_items_count));
                assert(ht->split_count);
        } else {
                ht->split_count = NULL;
@@ -1667,12 +1668,14 @@ int cds_lfht_replace(struct cds_lfht *ht,
 
 int cds_lfht_del(struct cds_lfht *ht, struct cds_lfht_node *node)
 {
-       unsigned long size, hash;
+       unsigned long size;
        int ret;
 
        size = rcu_dereference(ht->size);
        ret = _cds_lfht_del(ht, size, node);
        if (!ret) {
+               unsigned long hash;
+
                hash = bit_reverse_ulong(node->reverse_hash);
                ht_count_del(ht, size, hash);
        }
index f7605343d9ad29e75f2dccf1c2134eb9768ec9e9..43d0dace7169d7d8e30ea502400cb2072d1721eb 100644 (file)
@@ -114,9 +114,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;
index 32204dc16ee95b7195d8a85d824ad7623afd094a..47eaff6918faa324009888738c05900c98b86e04 100644 (file)
@@ -118,9 +118,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;
index 1f267e677e48c4e586680ab0c8a8f7dffc11db7f..45dad7869427fc434a021f5bddc60f3f7590ea06 100644 (file)
@@ -114,9 +114,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;
index 4f48276ae53d147897cb2b5095dd2510170fc815..804ce7bd8a79b1945f9fcd9ea5098d3f34a7a971 100644 (file)
 #include <urcu/uatomic.h>
 
 struct testvals {
+#ifdef UATOMIC_HAS_ATOMIC_BYTE
        unsigned char c;
+#endif
+#ifdef UATOMIC_HAS_ATOMIC_SHORT
        unsigned short s;
+#endif
        unsigned int i;
        unsigned long l;
 };
index e79e2726cdb7d746b14973c4c07dc3e98f960517..eed3dfbdcdc295c880e626eff8f5802a30356dda 100644 (file)
@@ -112,9 +112,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;
index 9d46caf4e1b26e042e58970d3a9a9b02a4ad85d4..68e84bd1f48273f365c9be49a1b35f0ba517a6d9 100644 (file)
@@ -112,9 +112,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;
index 85ccb7899b3fade57b51f85e96e1d6cec783eb91..afbc1a247691421dd5ce44962e41061e9efd8168 100644 (file)
@@ -112,9 +112,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;
index a711959a4ea19dbc19310f17d5450d54f6a96da4..1fbb15461be45d96fc9626634fb4afc030b66524 100644 (file)
@@ -113,9 +113,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;
index c20f6fcfe5112327086a3138d28d06455023ffdc..f8244238beb93acbf12f76f880e9efce76d4e522 100644 (file)
@@ -121,9 +121,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;
index 5710de08135f8e0f58be45bfec59cca94636031e..f24566e1776fa2234079581a70a27dce058c72ad 100644 (file)
@@ -136,9 +136,10 @@ static pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 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;
index ec5d822d1b1dde350af55b99fd8dd009bed5c293..6b2bf051da80f5af9887a80797ee57fa8fca28d0 100644 (file)
@@ -105,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;
index 61abaad4567cf2c79a080d98e5eec99947f2162b..8c28c2ba4708f7d631241ee312556e1c03c6c3fb 100644 (file)
@@ -105,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;
index 039031a35819a5284026f8b3af6597a735f3f007..7f27038d2fbf8455f84aa25915698b818ed33088 100644 (file)
@@ -112,9 +112,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;
index aa0e2a74aeabdd54bb3c30e3ec276d3b9120f46d..f8cf784ccd2a455c1afce76ec7dc7449cb671412 100644 (file)
@@ -117,9 +117,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;
index 6c2e4e827707f80ce7af9a29a1480f7ee49c4fb3..3158d2d3d0a5fa89257edbd6722e3b8130ef778d 100644 (file)
@@ -105,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;
index 0116d5f6fd2edcc86eec781dbf40e5b19bcd44c0..b3f03b9d680f9946193283d0eaec451a4c50922b 100644 (file)
@@ -105,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;
index 66710e2b688123a1b0ce5d672b55e3d6f7f33b04..4cf919699da4791688f1dc0e1b344f9a5061a824 100644 (file)
@@ -105,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;
This page took 0.033498 seconds and 4 git commands to generate.