From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202508 header.b=DAsRVhu1; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 27FA15A0276 for ; Wed, 01 Oct 2025 11:52:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1759312328; bh=8Ddg8s6S9DNbR9L4aQNMvcps4Y7EPMy38hZ3tFfyOH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DAsRVhu1sEAtPYBO9VPN4H4Rvo8zTr9RNaPT3Z4EvwYkTuLaySCJer2poU9vcq+o2 pmjo0tg2f3+qB/0+LdnvIXlzhgb/JkCSw3+9nHqQ+Ump3uA5Acc1MAQrYVD8aydz4G FF5pYpuE06njJ0hSUw356HCriqm23Sm6JRegqjVtMYtkUTKo7DUv6hXG+8OW7YuezL 8PJorZvxFbDm2mUi3NCdTorjFTx4wFx9fTDkBPadYMHAH6ezQ/PiMu32lfXbpEUqI6 DfHKv1RHF+BlPwPuAdmn96JCAH7cTmBBcJRA5CI4C80uEGeakmSMQI2Wmf33trwW3l OqhowKqYs6jNA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4cc9FN37vWz4wDP; Wed, 1 Oct 2025 19:52:08 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 6/6] cppcheck: Suppress variable scope warnings in dhcpv6() Date: Wed, 1 Oct 2025 19:52:02 +1000 Message-ID: <20251001095202.3875003-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251001095202.3875003-1-david@gibson.dropbear.id.au> References: <20251001095202.3875003-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: J3P2E6HQ5N6D7L36TRNTBSE6RRN6YHIC X-Message-ID-Hash: J3P2E6HQ5N6D7L36TRNTBSE6RRN6YHIC X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: At least some cppcheck versions (2.18.3 for me) complain that the _storage variables in dhcpv6() could be reduced in scope. That's not actually the case, because although we don't reference the variables, we may touch their memory via pointers after the blocks in question. There's no reasonable way for cppcheck to determine that, though, so suppress its warnings. Signed-off-by: David Gibson --- dhcpv6.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dhcpv6.c b/dhcpv6.c index c1a27aba..e4df0db5 100644 --- a/dhcpv6.c +++ b/dhcpv6.c @@ -550,10 +550,18 @@ int dhcpv6(struct ctx *c, struct iov_tail *data, { const struct opt_server_id *server_id = NULL; const struct opt_hdr *client_id = NULL; + /* The _storage variables can't be local to the blocks they're used in, + * because IOV_*_HEADER() may return pointers to them which are + * dereferenced afterwards. Since we don't have Rust-like lifetime + * tracking, cppcheck can't reasonably determine that, so we must + * suppress its warnings. */ + /* cppcheck-suppress [variableScope,unmatchedSuppression] */ struct opt_server_id server_id_storage; struct iov_tail opt, client_id_base; const struct opt_ia_na *ia = NULL; + /* cppcheck-suppress [variableScope,unmatchedSuppression] */ struct opt_hdr client_id_storage; + /* cppcheck-suppress [variableScope,unmatchedSuppression] */ struct opt_ia_na ia_storage; const struct in6_addr *src; struct msg_hdr mh_storage; -- 2.51.0