From: Mathieu Desnoyers Date: Mon, 22 Oct 2012 21:34:31 +0000 (-0400) Subject: Cleanup: fix cppcheck errors X-Git-Tag: v0.8.0~186 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=95bc7fb90c36ee10dc171a23e8783eff30072b7b;p=userspace-rcu.git Cleanup: fix cppcheck errors Signed-off-by: Mathieu Desnoyers --- diff --git a/rculfhash.c b/rculfhash.c index b8fbb64..7050d5c 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -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); } diff --git a/tests/test_mutex.c b/tests/test_mutex.c index f760534..43d0dac 100644 --- a/tests/test_mutex.c +++ b/tests/test_mutex.c @@ -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; diff --git a/tests/test_perthreadlock.c b/tests/test_perthreadlock.c index 32204dc..47eaff6 100644 --- a/tests/test_perthreadlock.c +++ b/tests/test_perthreadlock.c @@ -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; diff --git a/tests/test_rwlock.c b/tests/test_rwlock.c index 1f267e6..45dad78 100644 --- a/tests/test_rwlock.c +++ b/tests/test_rwlock.c @@ -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; diff --git a/tests/test_uatomic.c b/tests/test_uatomic.c index 4f48276..804ce7b 100644 --- a/tests/test_uatomic.c +++ b/tests/test_uatomic.c @@ -25,8 +25,12 @@ #include 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; }; diff --git a/tests/test_urcu.c b/tests/test_urcu.c index e79e272..eed3dfb 100644 --- a/tests/test_urcu.c +++ b/tests/test_urcu.c @@ -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; diff --git a/tests/test_urcu_assign.c b/tests/test_urcu_assign.c index 9d46caf..68e84bd 100644 --- a/tests/test_urcu_assign.c +++ b/tests/test_urcu_assign.c @@ -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; diff --git a/tests/test_urcu_bp.c b/tests/test_urcu_bp.c index 85ccb78..afbc1a2 100644 --- a/tests/test_urcu_bp.c +++ b/tests/test_urcu_bp.c @@ -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; diff --git a/tests/test_urcu_defer.c b/tests/test_urcu_defer.c index a711959..1fbb154 100644 --- a/tests/test_urcu_defer.c +++ b/tests/test_urcu_defer.c @@ -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; diff --git a/tests/test_urcu_gc.c b/tests/test_urcu_gc.c index c20f6fc..f824423 100644 --- a/tests/test_urcu_gc.c +++ b/tests/test_urcu_gc.c @@ -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; diff --git a/tests/test_urcu_hash.c b/tests/test_urcu_hash.c index 5710de0..f24566e 100644 --- a/tests/test_urcu_hash.c +++ b/tests/test_urcu_hash.c @@ -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; diff --git a/tests/test_urcu_lfq.c b/tests/test_urcu_lfq.c index ec5d822..6b2bf05 100644 --- a/tests/test_urcu_lfq.c +++ b/tests/test_urcu_lfq.c @@ -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; diff --git a/tests/test_urcu_lfs.c b/tests/test_urcu_lfs.c index 61abaad..8c28c2b 100644 --- a/tests/test_urcu_lfs.c +++ b/tests/test_urcu_lfs.c @@ -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; diff --git a/tests/test_urcu_qsbr.c b/tests/test_urcu_qsbr.c index 039031a..7f27038 100644 --- a/tests/test_urcu_qsbr.c +++ b/tests/test_urcu_qsbr.c @@ -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; diff --git a/tests/test_urcu_qsbr_gc.c b/tests/test_urcu_qsbr_gc.c index aa0e2a7..f8cf784 100644 --- a/tests/test_urcu_qsbr_gc.c +++ b/tests/test_urcu_qsbr_gc.c @@ -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; diff --git a/tests/test_urcu_wfcq.c b/tests/test_urcu_wfcq.c index 6c2e4e8..3158d2d 100644 --- a/tests/test_urcu_wfcq.c +++ b/tests/test_urcu_wfcq.c @@ -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; diff --git a/tests/test_urcu_wfq.c b/tests/test_urcu_wfq.c index 0116d5f..b3f03b9 100644 --- a/tests/test_urcu_wfq.c +++ b/tests/test_urcu_wfq.c @@ -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; diff --git a/tests/test_urcu_wfs.c b/tests/test_urcu_wfs.c index 66710e2..4cf9196 100644 --- a/tests/test_urcu_wfs.c +++ b/tests/test_urcu_wfs.c @@ -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;