]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pidl:Wireshark Get rid of Boolean "flags" with no bit set
authorJohn Thacker <johnthacker@gmail.com>
Tue, 25 Jun 2024 22:37:28 +0000 (18:37 -0400)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 3 Jul 2024 01:35:31 +0000 (01:35 +0000)
Picked from Wireshark's fork:

    commit 5ae9af9e50c89d8700e5a166a9c345fc46b3a4ca
    Author: Guy Harris <guy@alum.mit.edu>
    Date:   Sun Nov 6 11:02:51 2016 -0800

        Get rid of Boolean "flags" that don't have any bit set.

        And tweak the Pidl generator for Wireshark not to generate "flags" like
        that.

        (The generator also does field name and true/false strings' case
        differently, so I didn't use it to regenerate the dissectors; that needs
        to be looked at.)

        Change-Id: Ie1657a782ebdb107e58792cedd29bbaa79b17bd4
        Reviewed-on: https://code.wireshark.org/review/18695
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
pidl/lib/Parse/Pidl/Wireshark/NDR.pm

index 65ebcac555dba7d6df4f7270018fe03477dbc0b7..760dd1539f8be174ce31f14087bb8f907a8c7f4f 100644 (file)
@@ -227,8 +227,10 @@ sub Bitmap($$$$)
                        my $hf_bitname = "hf_$ifname\_$name\_$1";
 
                        $ev =~ s/[()\s]//g;
-                       $total_ev += hex($ev);
-                       $self->pidl_code("&$hf_bitname,");
+                       if (hex($ev) != 0) {
+                               $total_ev += hex($ev);
+                               $self->pidl_code("&$hf_bitname,");
+                       }
                }
                $self->pidl_code("NULL");
                $self->deindent;
@@ -268,18 +270,21 @@ sub Bitmap($$$$)
 
                $self->{hf_used}->{$hf_bitname} = 1;
 
-               $self->register_hf_field($hf_bitname, field2name($en), $filtername, "FT_BOOLEAN", $e->{ALIGN} * 8, "TFS(&$name\_$en\_tfs)", $ev, "");
+               $ev =~ s/[()\s]//g;
+               if (hex($ev) != 0) {
+                       $self->register_hf_field($hf_bitname, field2name($en), $filtername, "FT_BOOLEAN", $e->{ALIGN} * 8, "TFS(&$name\_$en\_tfs)", "( $ev )", "");
 
-               $self->pidl_def("static const true_false_string $name\_$en\_tfs = {");
-               if (defined($self->{conformance}->{tfs}->{$hf_bitname})) {
-                       $self->pidl_def("   $self->{conformance}->{tfs}->{$hf_bitname}->{TRUE_STRING},");
-                       $self->pidl_def("   $self->{conformance}->{tfs}->{$hf_bitname}->{FALSE_STRING},");
-                       $self->{conformance}->{tfs}->{$hf_bitname}->{USED} = 1;
-               } else {
-                       $self->pidl_def("   \"$en is SET\",");
-                       $self->pidl_def("   \"$en is NOT SET\",");
+                       $self->pidl_def("static const true_false_string $name\_$en\_tfs = {");
+                       if (defined($self->{conformance}->{tfs}->{$hf_bitname})) {
+                               $self->pidl_def("   $self->{conformance}->{tfs}->{$hf_bitname}->{TRUE_STRING},");
+                               $self->pidl_def("   $self->{conformance}->{tfs}->{$hf_bitname}->{FALSE_STRING},");
+                               $self->{conformance}->{tfs}->{$hf_bitname}->{USED} = 1;
+                       } else {
+                               $self->pidl_def("   \"$en is SET\",");
+                               $self->pidl_def("   \"$en is NOT SET\",");
+                       }
+                       $self->pidl_def("};");
                }
-               $self->pidl_def("};");
        }
 
        if ($element_count > 0) {