diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2025-10-02 15:04:35 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2025-10-07 15:33:34 +0200 |
commit | 2274c3a520dfa41e440db93f15153ff426694331 (patch) | |
tree | 39a7aeb4ccea982baad08918c8a44ada0a5a6bc2 | |
parent | ee9b2361d04027669bff8df4dc10722bda1c1333 (diff) | |
download | passt-2274c3a520dfa41e440db93f15153ff426694331.tar passt-2274c3a520dfa41e440db93f15153ff426694331.tar.gz passt-2274c3a520dfa41e440db93f15153ff426694331.tar.bz2 passt-2274c3a520dfa41e440db93f15153ff426694331.tar.lz passt-2274c3a520dfa41e440db93f15153ff426694331.tar.xz passt-2274c3a520dfa41e440db93f15153ff426694331.tar.zst passt-2274c3a520dfa41e440db93f15153ff426694331.zip |
cppcheck: Suppress variable scope warnings in dhcpv6()
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 <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r-- | dhcpv6.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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; |