queue: redefine TAILQ_REMOVE for scan-build
scan-build can't follow double pointers in tailqs and often assumes that removed elements are still on the list, so now if we detect __clang_analyzer__ we'll redefine TAILQ_REMOVE with extra asserts to silence those scan-build errors. Change-Id: I14134d8e75f7829e178b74d19f711f77cf018f14 Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459285 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: yidong0635 <dongx.yi@intel.com>
This commit is contained in:
parent
825ae66bd0
commit
490b06e24b
@ -50,6 +50,28 @@ extern "C" {
|
||||
#include "spdk/queue_extras.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* scan-build can't follow double pointers in queues and often assumes
|
||||
* that removed elements are still on the list. We redefine TAILQ_REMOVE
|
||||
* with extra asserts to silence it.
|
||||
*/
|
||||
#ifdef __clang_analyzer__
|
||||
#undef TAILQ_REMOVE
|
||||
#define TAILQ_REMOVE(head, elm, field) do { \
|
||||
__typeof__(elm) _elm; \
|
||||
if (((elm)->field.tqe_next) != NULL) \
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
(elm)->field.tqe_prev; \
|
||||
else \
|
||||
(head)->tqh_last = (elm)->field.tqe_prev; \
|
||||
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
|
||||
/* make sure the removed elm is not on the list anymore */ \
|
||||
TAILQ_FOREACH(_elm, head, field) { \
|
||||
assert(_elm != elm); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user