+14
−0
Loading
Newer versions of gcc (13) are reporting bogus warnings when doing a
TAILQ_SWAP() with a tailq declared on stack. For example:
In file included from /src/spdk-2/include/spdk/queue.h:22,
from /src/spdk-2/include/spdk/dma.h:14,
from /src/spdk-2/include/spdk/accel.h:15,
from /src/spdk-2/include/spdk/accel_module.h:12,
from accel.c:9:
accel.c: In function ‘spdk_accel_sequence_reverse’:
/src/spdk-2/include/spdk/queue_extras.h:344:27: error: storing the address of local variable ‘tasks’ in ‘*seq.tasks.tqh_last’ [-Werror=dangling-pointer=]
344 | (head2)->tqh_last = swap_last; \
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
accel.c:1926:9: note: in expansion of macro ‘TAILQ_SWAP’
1926 | TAILQ_SWAP(&tasks, &seq->tasks, spdk_accel_task, seq_link);
| ^~~~~~~~~~
accel.c:1922:37: note: ‘tasks’ declared here
1922 | struct accel_sequence_tasks tasks = TAILQ_HEAD_INITIALIZER(tasks);
| ^~~~~
The address of a local variable is indeed stored in tqh_last, but a few
lines later it is overwritten (tqh_first is NULL in this case, because
it's initialized by TAILQ_HEAD_INITIALIZER):
if ((swap_first = (head2)->tqh_first) != NULL) \
swap_first->field.tqe_prev = &(head2)->tqh_first; \
else \
(head2)->tqh_last = &(head2)->tqh_first; \
So, suppress those warnings if using gcc-13 and up.
Fixes #3030.
Signed-off-by:
Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I0c6d68bcfef29b345f968832ba62114e5a639ffa
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/18439
Reviewed-by:
Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by:
Ben Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by:
Kamil Godzwon <kamilx.godzwon@intel.com>
Tested-by:
SPDK CI Jenkins <sys_sgci@intel.com>