From: John Thacker Date: Sun, 12 Oct 2025 19:14:47 +0000 (-0400) Subject: wireshark-pidl: Do not calculate functions replaced by manual code X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=18ba2316f8e223f50474d8a6e5b6ee1a287a4a9d;p=thirdparty%2Fsamba.git wireshark-pidl: Do not calculate functions replaced by manual code From the Wireshark development branch: commit d2232d7e51640e0e736d7b8df1b21598a21a1c85 Author: John Thacker Date: Fri Oct 10 23:02:58 2025 -0400 pidl: Do not produce a function that is replaced by MANUAL code If a MANUAL directive in a conformance file causes a function not to be emitted, do not bother calculating the function that will not be used. This is similar to the NOEMIT directive, but has different logic because MANUAL only prevents emitting the function for one level of an element instead of all the functions and variables. This does not change the dissectors produced at all, only skips some unnecessary compilation. In particular, the messages when compiling the pidl-dissectors target: dnsserver.idl:159: error: Inline arrays not supported eventlog.idl:54: error: Inline arrays not supported are no longer inaccurately produced. The inline arrays in those two IDL files have long been supported through the MANUAL code blocks. Expand on the error message to suggest the use of MANUAL directives for implementation. Signed-off-by: John Thacker Reviewed-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm index ce0010acc98..b7785d389ee 100644 --- a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm +++ b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm @@ -322,7 +322,7 @@ sub ElementLevel($$$$$$$$) $self->pidl_code("offset = dissect_ndr_$type\_pointer(tvb, offset, pinfo, tree, di, drep, $myname\_, $ptrtype_mappings{$l->{POINTER_TYPE}}, \"Pointer to ".field2name(StripPrefixes($e->{NAME}, $self->{conformance}->{strip_prefixes})) . " ($e->{TYPE})\",$hf);"); } elsif ($l->{TYPE} eq "ARRAY") { if ($l->{IS_INLINE}) { - error($e->{ORIGINAL}, "Inline arrays not supported"); + error($e->{ORIGINAL}, "Inline arrays not supported automatically. Use conformance file MANUAL directives for `$myname' and `$l->{SIZE_IS}' to implement them."); } elsif ($l->{IS_FIXED}) { $self->pidl_code("int i;"); $self->pidl_code("for (i = 0; i < $l->{SIZE_IS}; i++)"); @@ -564,22 +564,24 @@ sub Element($$$$$$) next if ($_->{TYPE} eq "SWITCH"); next if (defined($self->{conformance}->{noemit}->{"$dissectorname$add"})); $self->pidl_def("static int $dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_$moreparam);"); - $self->pidl_fn_start("$dissectorname$add"); - $self->pidl_code("static int"); - $self->pidl_code("$dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_$moreparam)"); - $self->pidl_code("{"); - $self->indent; + if (not defined($self->{conformance}->{manual}->{"$dissectorname$add"})) { + $self->pidl_fn_start("$dissectorname$add"); + $self->pidl_code("static int"); + $self->pidl_code("$dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, uint8_t *drep _U_$moreparam)"); + $self->pidl_code("{"); + $self->indent; + + $self->ElementLevel($e,$_,$hf,$dissectorname.$add,$pn,$ifname,$param); + if (defined $oldparam) { + $param = $oldparam; + } - $self->ElementLevel($e,$_,$hf,$dissectorname.$add,$pn,$ifname,$param); - if (defined $oldparam) { - $param = $oldparam; + $self->pidl_code(""); + $self->pidl_code("return offset;"); + $self->deindent; + $self->pidl_code("}\n"); + $self->pidl_fn_end("$dissectorname$add"); } - - $self->pidl_code(""); - $self->pidl_code("return offset;"); - $self->deindent; - $self->pidl_code("}\n"); - $self->pidl_fn_end("$dissectorname$add"); $add.="_"; last if ($_->{TYPE} eq "ARRAY" and $_->{IS_ZERO_TERMINATED}); }