r10116: Print out a couple more warnings.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 9 Sep 2005 16:23:50 +0000 (16:23 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:38:01 +0000 (13:38 -0500)
(This used to be commit 0628dfa5c3c74614a86b4f61b8d1555ef41c41bb)

source4/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm
source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm

index 9e6147b1665141b00c67d5a455bdad601e5d1e9a..47107b5969cd73505827d6281db6d37e59106d55 100644 (file)
@@ -57,7 +57,12 @@ sub handle_hf_rename($$$$)
                return;
        }
 
-       $data->{hf_renames}->{$old} = $new;
+       $data->{hf_renames}->{$old} = {
+               OLDNAME => $old,
+               NEWNAME => $new,
+               POS => $pos,
+               USED => 0
+       };
 }
 
 sub handle_param_value($$$$)
index 119dc46707a5be7d7c14fd7e1c740ec963a30181..de936eb97d05ae6ebf043c21c115010f9eda8a5d 100644 (file)
@@ -18,6 +18,9 @@ use Parse::Pidl::Ethereal::Conformance qw(ReadConformance);
 my %types;
 my @ett;
 
+my %hf_used = ();
+my %dissector_used = ();
+
 my $conformance = undef;
 
 my %ptrtype_mappings = (
@@ -196,6 +199,8 @@ sub Bitmap($$$)
                my ($en,$ev) = ($1,$2);
                my $hf_bitname = "hf_$ifname\_$name\_$en";
                my $filtername = "$ifname\.$name\.$en";
+
+               $hf_used{$hf_bitname} = 1;
                
                register_hf_field($hf_bitname, field2name($en), $filtername, "FT_BOOLEAN", $e->{ALIGN} * 8, "TFS(&$name\_$en\_tfs)", $ev, "");
 
@@ -321,6 +326,7 @@ sub Element($$$)
        my $call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, drep);";
 
        my $hf = register_hf_field("hf_$ifname\_$pn\_$e->{NAME}", field2name($e->{NAME}), "$ifname.$pn.$e->{NAME}", type2ft($e->{TYPE}), "BASE_HEX", "NULL", 0, "");
+       $hf_used{$hf} = 1;
 
        my $eltname = StripPrefixes($pn) . ".$e->{NAME}";
        if (defined($conformance->{noemit}->{$eltname})) {
@@ -378,9 +384,14 @@ sub Function($$$)
        if (not defined($fn->{RETURN_TYPE})) {
        } elsif ($fn->{RETURN_TYPE} eq "NTSTATUS") {
                pidl_code "offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep, hf\_$ifname\_status, NULL);";
+               $hf_used{"hf\_$ifname\_status"} = 1;
        } elsif ($fn->{RETURN_TYPE} eq "WERROR") {
                pidl_code "offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep, hf\_$ifname\_werror, NULL);";
+               $hf_used{"hf\_$ifname\_werror"} = 1;
+       } else {
+               print "$fn->{FILE}:$fn->{LINE}: error: return type `$fn->{RETURN_TYPE}' not yet supported\n";
        }
+               
 
        pidl_code "return offset;";
        deindent;
@@ -587,6 +598,8 @@ sub RegisterInterfaceHandoff($)
            pidl_code "\t$x->{NAME}_dissectors, hf_$x->{NAME}_opnum);";
            deindent;
            pidl_code "}";
+
+               $hf_used{"hf_$x->{NAME}_opnum"} = 1;
        }
 }
 
@@ -611,8 +624,6 @@ sub ProcessInterface($)
        pidl_def "static gint proto_dcerpc_$x->{NAME} = -1;";
        register_ett("ett_dcerpc_$x->{NAME}");
        register_hf_field("hf_$x->{NAME}_opnum", "Operation", "$x->{NAME}.opnum", "FT_UINT16", "BASE_DEC", "NULL", 0, "");
-       register_hf_field("hf_$x->{NAME}_status", "Status", "$x->{NAME}.status", "FT_UINT32", "BASE_HEX", "VALS(NT_errors)", 0, "");
-       register_hf_field("hf_$x->{NAME}_werror", "Windows Error", "$x->{NAME}.werror", "FT_UINT32", "BASE_HEX", "NULL", 0, "");
 
        if (defined($x->{UUID})) {
                my $if_uuid = $x->{UUID};
@@ -643,6 +654,15 @@ sub ProcessInterface($)
 
        pidl_code "\n".DumpFunctionTable($x);
 
+       # Only register these two return types if they were actually used
+       if (defined($hf_used{"hf_$x->{NAME}_status"})) {
+               register_hf_field("hf_$x->{NAME}_status", "Status", "$x->{NAME}.status", "FT_UINT32", "BASE_HEX", "VALS(NT_errors)", 0, "");
+       }
+
+       if (defined($hf_used{"hf_$x->{NAME}_werror"})) {
+               register_hf_field("hf_$x->{NAME}_werror", "Windows Error", "$x->{NAME}.werror", "FT_UINT32", "BASE_HEX", "NULL", 0, "");
+       }
+
        RegisterInterface($x);
        RegisterInterfaceHandoff($x);
 
@@ -770,6 +790,8 @@ sub Parse($$$$)
 
        my $header = "/* autogenerated by pidl */\n\n";
        $header.=$res{hdr};
+
+       CheckUsed($conformance);
     
        return ($parser,$header);
 }
@@ -813,7 +835,10 @@ sub register_hf_field($$$$$$$$)
 {
        my ($index,$name,$filter_name,$ft_type,$base_type,$valsstring,$mask,$blurb) = @_;
 
-       return $conformance->{hf_renames}->{$index} if defined ($conformance->{hf_renames}->{$index});
+       if (defined ($conformance->{hf_renames}->{$index})) {
+               $conformance->{hf_renames}->{$index}->{USED} = 1;
+               return $conformance->{hf_renames}->{$index}->{NEWNAME};
+       }
 
        $conformance->{header_fields}->{$index} = {
                INDEX => $index,
@@ -885,4 +910,27 @@ sub DumpFunctionTable($)
        return "$res};\n";
 }
 
+sub CheckUsed($)
+{
+       my $conformance = shift;
+       foreach (values %{$conformance->{header_fields}}) {
+               if (not defined($hf_used{$_->{INDEX}})) {
+                       print "$_->{POS}: warning: hf field `$_->{INDEX}' not used\n";
+               }
+       }
+
+       foreach (values %{$conformance->{hf_renames}}) {
+               if (not $_->{USED}) {
+                       print "$_->{POS}: warning: hf field `$_->{OLDNAME}' not used\n";
+               }
+       }
+
+       #FIXME: PARAM_VALUE's
+       #FIXME: TYPE
+       #FIXME: FIELDDESCRIPTION
+       #FIXME: Import
+}
+
+
+
 1;