]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
wireshark-pidl: Reduce false positive warnings when compiling
authorJohn Thacker <johnthacker@gmail.com>
Sun, 12 Oct 2025 18:53:49 +0000 (14:53 -0400)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 5 Nov 2025 10:08:28 +0000 (10:08 +0000)
From the Wireshark git repository, to reduce false positive warnings when
compiling dissectors with pidl:

    commit 919f15ab2ea313d69cc2578426430f22f65a51b5
    Author: John Thacker <johnthacker@gmail.com>
    Date:   Wed Oct 8 16:52:09 2025 -0400

        pidl: Don't warn about params that are used

        The "USED" indicator is never set for params, which results in many
        bogus "warning: dissector param never used" messages when compiling
        the pidl dissectors. Set it when used, to reduce the number of messages.

Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
pidl/lib/Parse/Pidl/Wireshark/NDR.pm

index 3d8b74bab45cdaa750196a00fad73f20f50c3b19..78320e8d093c675ba4ff016334a8fe6bfbeff15b 100644 (file)
@@ -389,13 +389,19 @@ sub ElementLevel($$$$$$$$)
                                        $t = $l->{DATA_TYPE};
                                }
 
+                               if ($param ne 0) {
+                                       $self->{conformance}->{dissectorparams}->{$myname}->{USED} = 1;
+                               }
                                $self->pidl_code("offset = $ifname\_dissect_struct_" . $t . "(tvb,offset,pinfo,tree,di,drep,$hf,$param);");
 
                                return;
                        }
 
                        $call =~ s/\@HF\@/$hf/g;
-                       $call =~ s/\@PARAM\@/$param/g;
+                       my $replacements = ($call =~ s/\@PARAM\@/$param/g);
+                       if ($param ne 0 and $replacements ne 0) {
+                               $self->{conformance}->{dissectorparams}->{$myname}->{USED} = 1;
+                       }
                        $self->pidl_code($call);
                }
        } elsif ($_->{TYPE} eq "SUBCONTEXT") {
@@ -424,6 +430,7 @@ sub ElementLevel($$$$$$$$)
 
                $self->pidl_code("subtvb = tvb_new_subset_length_caplen(tvb, offset, (const int)size, -1);");
                if ($param ne 0) {
+                       $self->{conformance}->{dissectorparams}->{$myname}->{USED} = 1;
                        $self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, di, drep, $param);");
                } else {
                        $self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, di, drep);");