]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
util/find-doc-nits: do not check files in submodules in check_env_vars
authorEugene Syromiatnikov <esyr@openssl.org>
Fri, 29 Aug 2025 07:11:23 +0000 (09:11 +0200)
committerNeil Horman <nhorman@openssl.org>
Tue, 9 Sep 2025 13:47:11 +0000 (09:47 -0400)
The reports about undocumented environment variables coming from files
in submodules are superfluous;  get the list of directories
from .gitmodules and exclude them from processing.

Resolves: https://github.com/openssl/openssl/issues/28109
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28378)

util/find-doc-nits

index f1805f3bf01795dbdcfccd0c7eee06dce60ba8ae..6b541c2741171afcf465dd17b435248a2b895b62 100755 (executable)
@@ -1281,6 +1281,10 @@ sub check_env_vars {
     # initialized with the list of "untracable" variables
     my %env_list = ("SSL_CERT_FILE" => 1);
     my @env_files;
+    my @except_dirs = (
+        "$config{sourcedir}/demos",
+        "$config{sourcedir}/test",
+    );
     my @except_env_files = (
         "$config{sourcedir}/providers/implementations/keymgmt/template_kmgmt.c",
         "$config{sourcedir}/providers/implementations/kem/template_kem.c",
@@ -1289,12 +1293,42 @@ sub check_env_vars {
     my @env_headers;
     my @env_macro;
 
+    # Add submodules to the except_dirs
+    my $git_ok = 0;
+    open my $gs_pipe, '-|', "git config get --all "
+                            . "--file \"$config{sourcedir}/.gitmodules\" "
+                            . "--regexp '.*.path\$'";
+    while (<$gs_pipe>) {
+        $git_ok = 1;
+        s/\R$//; # better chomp
+        print STDERR "DEBUG[check_env_vars]: adding \"$config{sourcedir}/$_\""
+                     . " to except_dirs\n"
+            if $debug;
+        push @except_dirs, "$config{sourcedir}/$_";
+    }
+    # git call has failed, trying to parse .gitmodules manually
+    if (!$git_ok) {
+        print STDERR "DEBUG[check_env_vars]: .gitmodules parsing fallback\n"
+            if $debug;
+        if (open my $gs_file, '<', "$config{sourcedir}/.gitmodules") {
+            while (<$gs_file>) {
+                s/\R$//; # better chomp
+                if ($_ =~ /\s*path\s*=\s*(.*)$/) {
+                    print STDERR "DEBUG[check_env_vars]: adding "
+                                 . "\"$config{sourcedir}/$1\" to except_dirs\n"
+                        if $debug;
+                    push @except_dirs, "$config{sourcedir}/$1";
+                }
+            }
+        }
+    }
+
     # look for source files
     find(sub { push @env_files, $File::Find::name if /\.c$|\.in$/; },
          $config{sourcedir});
 
     foreach my $filename (@env_files) {
-        next if $filename =~ /test\/|demos\//
+        next if (grep { $filename =~ /^$_\// } @except_dirs)
                 || grep { $_ eq $filename } @except_env_files;
 
         open my $fh, '<', $filename or die "Can't open $filename: $!";