]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
compact: fix uninitialized var for basic inboxes master
authorEric Wong <e@80x24.org>
Fri, 19 Sep 2025 01:03:12 +0000 (01:03 +0000)
committerEric Wong <e@80x24.org>
Mon, 22 Sep 2025 20:50:01 +0000 (20:50 +0000)
While it currently makes no sense to compact basic inboxes with
no Xapian index, it shouldn't warn on uninitialized variables,
either.

lib/PublicInbox/Xapcmd.pm
t/indexlevels-mirror.t

index 02b16a045bd695cc47b65b170187882c43fbaa51..7de71ee39262ae669d3ba773f19a7986a381e965 100644 (file)
@@ -35,9 +35,11 @@ sub commit_changes ($$$$) {
                my ($y) = ($b =~ m!/([0-9]+)/*\z!);
                ($y // -1) <=> ($x // -1) # we may have non-shards
        } keys %$tmp;
-
-       my ($dname) = ($order[0] =~ m!(.*/)[^/]+/*\z!);
-       my $mode = (stat($dname))[2];
+       my ($xpfx, $mode);
+       if (@order) {
+               ($xpfx) = ($order[0] =~ m!(.*/)[^/]+/*\z!);
+               $mode = (stat($xpfx))[2];
+       }
        for my $old (@order) {
                next if $old eq ''; # no invalid paths
                my $newdir = $tmp->{$old};
index cf813d0887bf90a061891e82eb796021e3eefae3..ba1c27700ce1771e52969f9ca407c735687bd40c 100644 (file)
@@ -38,6 +38,7 @@ my $import_index_incremental = sub {
                $ibx->{inboxdir}, "-L$level");
        push @cmd, '-c' if have_xapian_compact;
        ok(run_script(\@cmd, undef, { 2 => \$err }), 'index master');
+       unlike $err, qr/Use of uninitialized/, 'no uninitialized warnings';
        my $ro_master = PublicInbox::Inbox->new({
                inboxdir => $ibx->{inboxdir},
                indexlevel => $level
@@ -166,6 +167,8 @@ my $import_index_incremental = sub {
                my $cmd = [ qw(-compact), $mirror ];
                ok(run_script($cmd, undef, { 2 => \$err}), "compact $level")
                        or diag $err;
+               unlike $err, qr/Use of uninitialized/,
+                               'no uninitialized warnings';
        }
 };