Fix: x86 and s390 uatomic: __hp() macro warning with gcc 11
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 15 Jun 2021 19:28:24 +0000 (15:28 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 15 Jun 2021 19:43:06 +0000 (15:43 -0400)
commit835b9ab3ca3777fe42e37e92096226ebd19ca75b
treeffa753f175ce2a53aa3ae118dd6b14152ff1e7db
parent6558e7a3b5c0e808a8729bcc046e7639b888c30f
Fix: x86 and s390 uatomic: __hp() macro warning with gcc 11

The __hp() macro used in the x86 and s390 uatomic code generates the
following warning with gcc-11:

In file included from ../include/urcu/uatomic.h:27,
                 from ../include/urcu/static/wfcqueue.h:35,
                 from ../include/urcu/wfcqueue.h:133,
                 from workqueue.c:39:
workqueue.c: In function ‘workqueue_thread’:
../include/urcu/uatomic/x86.h:155:17: warning: array subscript ‘struct __uatomic_dummy[0]’ is partly outside array bounds of ‘struct cds_wfcq_tail[1]’ [-Warray-bounds]
  155 |                 __asm__ __volatile__(
      |                 ^~~~~~~
workqueue.c:184:38: note: while referencing ‘cbs_tmp_tail’
  184 |                 struct cds_wfcq_tail cbs_tmp_tail;
      |                                      ^~~~~~~~~~~~

The (previously undocumented) reason for this macro is to allow passing the
"void *" parameter as "m" or "+m" operand to the inline assembly. That
motivation was explained in commit 53b8ed6836363 ("s390 uatomic arch fix").

The out of bound access is detected by gcc because struct
__uatomic_dummy's length is quite large: an array of 10 unsigned long,
which is larger than the size pointed to by the void pointer.

So rather than using a fixed-size type, cast to a structure containing
an array of characters of a size matching the @addr input argument.

While we are at it and digging out git archeology, properly document the
__hp() macro for posterity.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I785e30661efe48be1806664a1a14fd3c9fdb0a32
include/urcu/uatomic/s390.h
include/urcu/uatomic/x86.h
This page took 0.025658 seconds and 4 git commands to generate.