From: John Thacker Date: Sun, 12 Oct 2025 19:18:11 +0000 (-0400) Subject: wireshark-pidl: Don't warn about unused hfs used in CODE blocks X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eeaa1163b79b5c0b786becf6ddf759011b19ce20;p=thirdparty%2Fsamba.git wireshark-pidl: Don't warn about unused hfs used in CODE blocks From the Wireshark development branch: commit 4f55543f6b6e5c5d15572889a2cac2b0ec28200e Author: John Thacker 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 Reviewed-by: Stefan Metzmacher Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Wed Nov 5 11:12:35 UTC 2025 on atb-devel-224 --- diff --git a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm index b7785d389ee..b8833def613 100644 --- a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm +++ b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm @@ -1371,9 +1371,20 @@ sub DumpFunctionTable($) 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"); + } } }