From 6fd153181402f897577aebb3943a23c2666c2864 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 3 Feb 2018 13:32:50 -0800 Subject: Add a comment explaining why err is volatile. And also indicate that perhaps the right solution was just to close the CID as a false positive, as Coverity doesn't have a deep enough understanding of libnl to know that the loop isn't guaranteed to be infinite. Change-Id: Ieb0651c803a5939fb54f2bc68bdf8c5485dafaf2 Reviewed-on: https://code.wireshark.org/review/25582 Reviewed-by: Guy Harris --- caputils/ws80211_utils.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'caputils/ws80211_utils.c') diff --git a/caputils/ws80211_utils.c b/caputils/ws80211_utils.c index 2db068882b..cff2e88d90 100644 --- a/caputils/ws80211_utils.c +++ b/caputils/ws80211_utils.c @@ -142,6 +142,21 @@ static int ack_handler(struct nl_msg *msg _U_, void *arg) static int nl80211_do_cmd(struct nl_msg *msg, struct nl_cb *cb) { + /* + * XXX - Coverity doesn't understand how libnl works, so it + * doesn't know that nl_recvmsgs() calls the callback, and + * that the callback has had a pointer to err registered + * with it, and therefore that nl_recvmsgs() can change + * err as a side-effect, so it thinks this can loop + * infinitely. + * + * We declare err to be volatile to work around it. + * + * XXX - that workaround provokes a compiler complaint that + * casting a pointer to it to "void *" discards the + * volatile qualifier. Perhaps we should just re-close + * Coverity CID 997052 as "false positive". + */ volatile int err; if (!nl_state.nl_sock) -- cgit v1.2.3