From: David Goulet Date: Thu, 28 Nov 2013 19:55:07 +0000 (-0500) Subject: Fix: backported from urcu commit 92af1a30 X-Git-Tag: v2.4.0-rc2~14 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3915217875be40ea3b137dec855bed62f7fdbae9;p=lttng-tools.git Fix: backported from urcu commit 92af1a30 commit 92af1a30ca6a70945b167c31631c8598a626c71a Author: Mathieu Desnoyers Date: Thu Nov 28 18:41:13 2013 +0100 Fix undefined NULL pointer arithmetic Clang 3.3 with -O2 optimisations is especially picky about arithmetic on NULL pointers. This undefined behavior is turned into optimized out NULL checks by clang 3.3. Fix the undefined behavior by checking against the pointer directly, without going back and forth around NULL with pointer arithmetic. Reported-by: Zifei Tong Signed-off-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/src/common/hashtable/rculfhash.h b/src/common/hashtable/rculfhash.h index 17cf6db84..adb5d9d4f 100644 --- a/src/common/hashtable/rculfhash.h +++ b/src/common/hashtable/rculfhash.h @@ -458,7 +458,7 @@ void cds_lfht_resize(struct cds_lfht *ht, unsigned long new_size); for (cds_lfht_first(ht, iter), \ pos = caa_container_of(cds_lfht_iter_get_node(iter), \ __typeof__(*(pos)), member); \ - &(pos)->member != NULL; \ + cds_lfht_iter_get_node(iter) != NULL; \ cds_lfht_next(ht, iter), \ pos = caa_container_of(cds_lfht_iter_get_node(iter), \ __typeof__(*(pos)), member)) @@ -468,7 +468,7 @@ void cds_lfht_resize(struct cds_lfht *ht, unsigned long new_size); for (cds_lfht_lookup(ht, hash, match, key, iter), \ pos = caa_container_of(cds_lfht_iter_get_node(iter), \ __typeof__(*(pos)), member); \ - &(pos)->member != NULL; \ + cds_lfht_iter_get_node(iter) != NULL; \ cds_lfht_next_duplicate(ht, match, key, iter), \ pos = caa_container_of(cds_lfht_iter_get_node(iter), \ __typeof__(*(pos)), member))