This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=31697fc6f6599ee2632540f51868f851d57a29ed

commit 31697fc6f6599ee2632540f51868f851d57a29ed
Author: Guillem Jover <[email protected]>
AuthorDate: Tue Aug 26 05:54:25 2025 +0200

    perl: Move File::Find::find() options into an actual hashref variable
    
    Instead of passing the options via an anonymous hashref, move that out
    into a hashref variable. This should make the code a bit more clear,
    and avoids weird indentation for the arguments to the function.
---
 lib/dpkg/t/t-tarextract.t          | 22 +++++++++++++---------
 lib/dpkg/t/t-treewalk.t            | 13 ++++++++-----
 scripts/Dpkg/Path.pm               |  5 +++--
 scripts/Dpkg/Source/Archive.pm     |  5 +++--
 scripts/Dpkg/Source/BinaryFiles.pm |  8 ++++++--
 scripts/Dpkg/Source/Patch.pm       | 16 ++++++++++++----
 scripts/Dpkg/Source/Quilt.pm       |  7 ++++---
 scripts/Dpkg/Vendor/Debian.pm      | 11 +++++++++--
 scripts/Test/Dpkg.pm               |  5 +++--
 scripts/dpkg-scanpackages.pl       | 11 +++++++----
 scripts/dpkg-scansources.pl        | 11 +++++++----
 11 files changed, 75 insertions(+), 39 deletions(-)

diff --git a/lib/dpkg/t/t-tarextract.t b/lib/dpkg/t/t-tarextract.t
index 85292bd87..89287a77c 100755
--- a/lib/dpkg/t/t-tarextract.t
+++ b/lib/dpkg/t/t-tarextract.t
@@ -121,15 +121,19 @@ TAR
         mkdir $dirtree;
         chdir $dirtree;
         tar_create_tree($type);
-        find({ no_chdir => 1, wanted => sub {
-                   return if $type eq 'v7' and length > 99;
-                   return if $type eq 'v7' and -l and length readlink > 99;
-                   return if $type eq 'v7' and not (-f or -l or -d);
-                   return if $type eq 'ustar' and length > 256;
-                   return if $type eq 'ustar' and -l and length readlink > 100;
-                   push @paths, $_;
-               },
-               preprocess => sub { my (@files) = sort @_; @files } }, '.');
+        my $scan_tar = {
+            wanted => sub {
+                return if $type eq 'v7' and length > 99;
+                return if $type eq 'v7' and -l and length readlink > 99;
+                return if $type eq 'v7' and not (-f or -l or -d);
+                return if $type eq 'ustar' and length > 256;
+                return if $type eq 'ustar' and -l and length readlink > 100;
+                push @paths, $_;
+            },
+            preprocess => sub { my (@files) = sort @_; @files },
+            no_chdir => 1,
+        };
+        find($scan_tar, '.');
         chdir $cwd;
 
         my $paths_list = join "\0", @paths;
diff --git a/lib/dpkg/t/t-treewalk.t b/lib/dpkg/t/t-treewalk.t
index fec656590..0e54bf32c 100755
--- a/lib/dpkg/t/t-treewalk.t
+++ b/lib/dpkg/t/t-treewalk.t
@@ -114,11 +114,14 @@ sub test_treewalker {
 
         make_tree($dirtree);
 
-        find({ no_chdir => 1, wanted => sub {
-                   return if $type eq 'skip' and m{^\Q$dirtree\E/cccc};
-                   push @paths, s{\./}{}r;
-               },
-        }, $dirtree);
+        my $scan_tree = {
+            wanted => sub {
+                return if $type eq 'skip' and m{^\Q$dirtree\E/cccc};
+                push @paths, s{\./}{}r;
+            },
+            no_chdir => 1,
+        };
+        find($scan_tree, $dirtree);
 
         my $expected;
 
diff --git a/scripts/Dpkg/Path.pm b/scripts/Dpkg/Path.pm
index f596d3d16..785d44e91 100644
--- a/scripts/Dpkg/Path.pm
+++ b/scripts/Dpkg/Path.pm
@@ -237,12 +237,13 @@ sub check_directory_traversal {
               $_, $canon_pathname);
     };
 
-    find({
+    my $scan_symlinks = {
         wanted => $check_symlinks,
         no_chdir => 1,
         follow => 1,
         follow_skip => 2,
-    }, $dir);
+    };
+    find($scan_symlinks, $dir);
 
     return;
 }
diff --git a/scripts/Dpkg/Source/Archive.pm b/scripts/Dpkg/Source/Archive.pm
index 9ff968086..efcf42b37 100644
--- a/scripts/Dpkg/Source/Archive.pm
+++ b/scripts/Dpkg/Source/Archive.pm
@@ -229,11 +229,12 @@ sub extract {
                 or syserr(g_('cannot move %s to %s'), $File::Find::name, 
$destpath);
         };
 
-        find({
+        my $scan_move_in_place = {
             wanted => $move_in_place,
             no_chdir => 1,
             dangling_symlinks => 0,
-        }, $tmpdir);
+        };
+        find($scan_move_in_place, $tmpdir);
     } else {
         # Rename extracted directory
         opendir my $dir_dh, $tmpdir
diff --git a/scripts/Dpkg/Source/BinaryFiles.pm 
b/scripts/Dpkg/Source/BinaryFiles.pm
index 734a098b4..342e23dad 100644
--- a/scripts/Dpkg/Source/BinaryFiles.pm
+++ b/scripts/Dpkg/Source/BinaryFiles.pm
@@ -160,8 +160,12 @@ sub detect_binary_files {
         }
         return @result;
     };
-    find({ wanted => $check_binary, preprocess => $filter_ignore,
-           no_chdir => 1 }, File::Spec->catdir($self->{dir}, 'debian'));
+    my $scan_binaries = {
+        wanted => $check_binary,
+        preprocess => $filter_ignore,
+        no_chdir => 1,
+    };
+    find($scan_binaries, File::Spec->catdir($self->{dir}, 'debian'));
     error(P_('detected %d unwanted binary file (add it in ' .
              'debian/source/include-binaries to allow its inclusion).',
              'detected %d unwanted binary files (add them in ' .
diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm
index c4c17db76..8913ad46a 100644
--- a/scripts/Dpkg/Source/Patch.pm
+++ b/scripts/Dpkg/Source/Patch.pm
@@ -180,7 +180,7 @@ sub add_diff_directory {
 
     my @diff_files;
     my %files_in_new;
-    my $scan_new = sub {
+    my $add_new = sub {
         my $fn = (length > length($new)) ? substr($_, length($new) + 1) : '.';
         return if $diff_ignore->($fn);
         $files_in_new{$fn} = 1;
@@ -240,7 +240,7 @@ sub add_diff_directory {
             $self->_fail_with_msg("$new/$fn", g_('unknown file type'));
         }
     };
-    my $scan_old = sub {
+    my $add_old = sub {
         my $fn = (length > length($old)) ? substr($_, length($old) + 1) : '.';
         return if $diff_ignore->($fn);
         return if $files_in_new{$fn};
@@ -263,8 +263,16 @@ sub add_diff_directory {
         }
     };
 
-    find({ wanted => $scan_new, no_chdir => 1 }, $new);
-    find({ wanted => $scan_old, no_chdir => 1 }, $old);
+    my $scan_new = {
+        wanted => $add_new,
+        no_chdir => 1,
+    };
+    find($scan_new, $new);
+    my $scan_old = {
+        wanted => $add_old,
+        no_chdir => 1,
+    };
+    find($scan_old, $old);
 
     if ($opts{order_from} and -e $opts{order_from}) {
         my $order_from = Dpkg::Source::Patch->new(
diff --git a/scripts/Dpkg/Source/Quilt.pm b/scripts/Dpkg/Source/Quilt.pm
index c472b283a..7d3241191 100644
--- a/scripts/Dpkg/Source/Quilt.pm
+++ b/scripts/Dpkg/Source/Quilt.pm
@@ -372,7 +372,7 @@ sub restore_quilt_backup_files {
     my $patch_dir = $self->get_db_file($patch);
     return unless -d $patch_dir;
     info(g_('restoring quilt backup files for %s'), $patch) if $opts{verbose};
-    find({
+    my $scan_quilt = {
         no_chdir => 1,
         wanted => sub {
             return if -d;
@@ -391,8 +391,9 @@ sub restore_quilt_backup_files {
                 # empty files are "backups" for new files that patch created
                 unlink($target);
             }
-        }
-    }, $patch_dir);
+        },
+    };
+    find($scan_quilt, $patch_dir);
 }
 
 =head1 CHANGES
diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm
index 6d6163127..d1f351d26 100644
--- a/scripts/Dpkg/Vendor/Debian.pm
+++ b/scripts/Dpkg/Vendor/Debian.pm
@@ -679,10 +679,17 @@ sub _build_tainted_by {
         libraries => [ qw(lib) ],
     );
     foreach my $type (keys %usr_local_types) {
-        File::Find::find({
+        my $scan_tainted = {
             wanted => sub { $tainted{"usr-local-has-$type"} = 1 if -f },
             no_chdir => 1,
-        }, grep { -d } map { "/usr/local/$_" } @{$usr_local_types{$type}});
+        };
+        my @dirs_taintable = grep {
+            -d
+        } map {
+            "/usr/local/$_"
+        } @{$usr_local_types{$type}};
+
+        File::Find::find($scan_tainted, @dirs_taintable);
     }
 
     my @tainted = sort keys %tainted;
diff --git a/scripts/Test/Dpkg.pm b/scripts/Test/Dpkg.pm
index 5dfaedac8..49e281f15 100644
--- a/scripts/Test/Dpkg.pm
+++ b/scripts/Test/Dpkg.pm
@@ -134,10 +134,11 @@ sub _test_get_perl_dirs
 
 sub _test_scan_files($visit_func, $dirs)
 {
-    find({
+    my $scan_files = {
         wanted => $visit_func,
         no_chdir => 1,
-    }, @{$dirs});
+    };
+    find($scan_files, @{$dirs});
 }
 
 sub _test_get_files($keep_func, $dirs)
diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl
index 744e41f32..36269ab78 100755
--- a/scripts/dpkg-scanpackages.pl
+++ b/scripts/dpkg-scanpackages.pl
@@ -252,11 +252,14 @@ if ($options{arch}) {
     $find_filter = qr/\.$type$/;
 }
 my @archives;
-my $scan_archives = sub {
-    push @archives, $File::Find::name if m/$find_filter/;
+my $scan_archives = {
+    wanted => sub {
+        push @archives, $File::Find::name if m/$find_filter/;
+    },
+    follow => 1,
+    follow_skip => 2,
 };
-
-find({ follow => 1, follow_skip => 2, wanted => $scan_archives}, $binarypath);
+find($scan_archives, $binarypath);
 foreach my $fn (@archives) {
     process_deb($pathprefix, $fn);
 }
diff --git a/scripts/dpkg-scansources.pl b/scripts/dpkg-scansources.pl
index f13b12275..9a5686f54 100755
--- a/scripts/dpkg-scansources.pl
+++ b/scripts/dpkg-scansources.pl
@@ -300,11 +300,14 @@ load_src_override $src_override, $override;
 load_override_extra $extra_override_file if defined $extra_override_file;
 
 my @dsc;
-my $scan_dsc = sub {
-    push @dsc, $File::Find::name if m/\.dsc$/;
+my $scan_dsc = {
+    wanted => sub {
+        push @dsc, $File::Find::name if m/\.dsc$/;
+    },
+    follow => 1,
+    follow_skip => 2,
 };
-
-find({ follow => 1, follow_skip => 2, wanted => $scan_dsc }, $dir);
+find($scan_dsc, $dir);
 foreach my $fn (@dsc) {
     # FIXME: Fix it instead to not die on syntax and general errors?
     eval {

-- 
Dpkg.Org's dpkg

Reply via email to