]> git.lttng.org Git - userspace-rcu.git/commitdiff
Fix undefined NULL pointer arithmetic
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 28 Nov 2013 17:41:13 +0000 (18:41 +0100)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 28 Nov 2013 17:47:00 +0000 (18:47 +0100)
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 <soariez@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
urcu/rculfhash.h

index 7a411ad688ee92cbd753a7f04f798f355179beca..d8c85bce3822e3cda716571257ca810dac0d7d9f 100644 (file)
@@ -471,7 +471,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))
@@ -481,7 +481,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))
This page took 0.029002 seconds and 4 git commands to generate.