]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pidl:Samba4/Header: only include ntstatus.h if required
authorStefan Metzmacher <metze@samba.org>
Fri, 23 Aug 2024 15:25:34 +0000 (17:25 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 27 Aug 2024 07:19:32 +0000 (07:19 +0000)
Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
pidl/lib/Parse/Pidl/Samba4/Header.pm

index a0b002f67248168e26d521a1be4c87256e10d61e..aef3338e90bdf57acce0bc0d61cfb346265442bd 100644 (file)
@@ -13,7 +13,7 @@ require Exporter;
 use strict;
 use warnings;
 use Parse::Pidl qw(fatal);
-use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
+use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference scalarTypeUsed);
 use Parse::Pidl::Util qw(has_property is_constant unmake_str ParseExpr);
 use Parse::Pidl::Samba4 qw(is_intree ElementStars ArrayBrackets choose_header);
 
@@ -437,7 +437,6 @@ sub Parse($)
 
        $res = "";
        %headerstructs = ();
-       pidl "/* header auto-generated by pidl */\n\n";
 
        my $ifacename = "";
 
@@ -449,6 +448,17 @@ sub Parse($)
                }
        }
 
+       foreach (@{$ndr}) {
+               ($_->{TYPE} eq "CPP_QUOTE") && HeaderQuote($_);
+               ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_);
+               ($_->{TYPE} eq "IMPORT") && HeaderImport(@{$_->{PATHS}});
+               ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}});
+       }
+
+       my $res2 = $res;
+       $res = "";
+       pidl "/* header auto-generated by pidl */\n\n";
+
        pidl "#ifndef _PIDL_HEADER_$ifacename\n";
        pidl "#define _PIDL_HEADER_$ifacename\n\n";
 
@@ -457,16 +467,12 @@ sub Parse($)
        }
        pidl "#include <stdint.h>\n";
        pidl "\n";
-       # FIXME: Include this only if NTSTATUS was actually used
-       pidl choose_header("libcli/util/ntstatus.h", "core/ntstatus.h") . "\n";
+       if (scalarTypeUsed("NTSTATUS")) {
+               pidl choose_header("libcli/util/ntstatus.h", "core/ntstatus.h") . "\n";
+       }
        pidl "\n";
 
-       foreach (@{$ndr}) {
-               ($_->{TYPE} eq "CPP_QUOTE") && HeaderQuote($_);
-               ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_);
-               ($_->{TYPE} eq "IMPORT") && HeaderImport(@{$_->{PATHS}});
-               ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}});
-       }
+       $res .= $res2;
 
        pidl "#endif /* _PIDL_HEADER_$ifacename */\n";