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=Nv+8FhZc; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id C078C5A0621 for ; Thu, 02 Oct 2025 06:50:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1759380614; bh=8Ddg8s6S9DNbR9L4aQNMvcps4Y7EPMy38hZ3tFfyOH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nv+8FhZcsrk96ilf0YgmTEPqdd0ADQ6yNTQmVq0+PZHNpMhzi+yohM3HVBhtSW4dF rHD88/J5l70bl9cbagcMdf0Psnuy9jWV3s+fL/7dG6NvF2m2+NlICjMvjmB9xmuAZm kIPRtvmAj0nwX8+QpdYywXH1vE8Q8EkJQCFatb0hfe0HIp7mPdSCiPgyTcNvCFB8Nz 94BleJHLqKimqa4+T7ImGYA1ioIKvhprU/Ir/HQEsByuX17Pf9dkqOJkctyPvuB71d qY+aBhSfQqZMo/LTYLN05hxgZbKCZ3KrF3vOiYfjZMPuXhggtH021LEIz2YDcXh0E5 q30QeDiPHSh0w== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ccfVZ5tsWz4wDT; Thu, 2 Oct 2025 14:50:14 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 5/6] cppcheck: Suppress variable scope warnings in dhcpv6() Date: Thu, 2 Oct 2025 14:50:11 +1000 Message-ID: <20251002045012.4047974-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251002045012.4047974-1-david@gibson.dropbear.id.au> References: <20251002045012.4047974-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 4BHSEJRDE7LFW7XCKWFMQR2DHJCRMVUD X-Message-ID-Hash: 4BHSEJRDE7LFW7XCKWFMQR2DHJCRMVUD 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