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:45:26 +0000 (15:45 -0400)
commit03155c0d2f1fd52ee863dc1059fc662993983fa9
tree028349c5404898f841d4280b690d5ad845e01029
parentbff8f20a08150c51a6f1425a0314d73ed47628e1
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.026542 seconds and 4 git commands to generate.