From the Wireshark development branch:
commit
4f55543f6b6e5c5d15572889a2cac2b0ec28200e
Author: John Thacker <johnthacker@gmail.com>
Date: Fri Oct 10 11:10:13 2025 -0400
pidl: Check if a hf is used in a CODE block
If a field declared in a conformance file appears within a custom
CODE block in the conformance file, don't warn about the hf being
unused. This theoretically could have false negatives if a field
is mentioned only in a comment in the CODE block; we'd have to
remove the comments with something like Regexp::Common before
searching to avoid that.
The current conformance files in the Wireshark distribution don't
have any such false negative cases, but there are dozens of false
positives prevented by this change.
Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Nov 5 11:12:35 UTC 2025 on atb-devel-224
sub CheckUsed($$)
{
my ($self, $conformance) = @_;
+
+ # Check if some word appears inside a CODE block
+ # This has false positives if a word appears within a comment.
+ # We could use Regexp::Common to remove comments before searching.
+ local *CheckCode = sub {
+ my $name = shift;
+ return (exists ($conformance->{override}) and ($conformance->{override} =~ /\b$name\b/));
+ };
+
foreach (values %{$conformance->{header_fields}}) {
if (not defined($self->{hf_used}->{$_->{INDEX}})) {
- warning($_->{POS}, "hf field `$_->{INDEX}' not used");
+ if (not CheckCode($_->{INDEX})) {
+ warning($_->{POS}, "hf field `$_->{INDEX}' not used");
+ }
}
}