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:51 +0000 (15:43 -0400)
commitf97344e0254e1157bfcc8969b67332c1d5bfec57
tree3a21420dd886c72b333c1a0563806a98b26f9837
parent313a8d6e4dc39c47fbc253802f60415b5f37e0d3
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.026052 seconds and 4 git commands to generate.