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=uSkDYf2f; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id CBB2D5A0276 for ; Thu, 02 Oct 2025 07:04:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1759381478; bh=8Ddg8s6S9DNbR9L4aQNMvcps4Y7EPMy38hZ3tFfyOH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uSkDYf2fAL6d5QO02jD2Bm1wgjN0kcGrIRWrsfgARkt3kaWMBe/sv6xnyvqhSgjz5 71BlE3IMR0xqcetuJlHrG5rSL1CasVtJ2Xu+FtE5IrlFIh+wI4cRbnbeQPIG4SRMP2 31i+CMIrNaM+o7nvnI5UaG4cjVL+LgYtQ0GGJY0xx57Uj0NRfBKWHFk1ISiqhN+u/R Nus/JyYjfqKJt525KHv/anDBl78WpXKRKchs3t9uzSkEhzRnoS20SJN8OLsBbDc5Rq JNVdasjY+LgfrWWgcSVSX4rT49PBYGtUjsGDvekVdRc/R78LxhWo5ZXaaONCpdS9JN r2p03N28q2FCQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ccfqB5SBwz4wDQ; Thu, 2 Oct 2025 15:04:38 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v3 4/6] cppcheck: Suppress variable scope warnings in dhcpv6() Date: Thu, 2 Oct 2025 15:04:35 +1000 Message-ID: <20251002050437.4175553-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251002050437.4175553-1-david@gibson.dropbear.id.au> References: <20251002050437.4175553-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: XUAREBMAS5XUG7ZRHWYO37MZCLLM2GWM X-Message-ID-Hash: XUAREBMAS5XUG7ZRHWYO37MZCLLM2GWM 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