Skip to content

Commit

Permalink
lintpkgsrc: rename safe_chdir to chdir_or_fail
Browse files Browse the repository at this point in the history
The word 'safe' was too ambiguous.
While here, remove the source code location from the error message.
This error is not expected to occur during normal usage.
  • Loading branch information
rillig committed Jul 30, 2022
1 parent 444502e commit 57ffca2
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions pkgtools/lintpkgsrc/files/lintpkgsrc.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!@PERL5@

# $NetBSD: lintpkgsrc.pl,v 1.38 2022/07/30 15:11:26 rillig Exp $
# $NetBSD: lintpkgsrc.pl,v 1.39 2022/07/30 16:26:14 rillig Exp $

# Written by David Brownlee <abs@netbsd.org>.
#
Expand Down Expand Up @@ -1148,15 +1148,11 @@ ($)
}


# chdir() || fail()
#
sub safe_chdir($) {
sub chdir_or_fail($) {
my ($dir) = @_;

debug("chdir: $dir");
if (!chdir($dir)) {
fail("Unable to chdir($dir): $!");
}
chdir($dir) or fail("Cannot chdir($dir): $!\n");
}

sub load_pkgsrc_makefiles($) {
Expand Down Expand Up @@ -1331,7 +1327,7 @@ ($$$$)
}

verbose("checksum mismatches\n");
safe_chdir($pkgdistdir);
chdir_or_fail($pkgdistdir);
foreach my $sum (keys %sumfiles) {
if ($sum eq 'Size') {
foreach my $file (@{$sumfiles{$sum}}) {
Expand Down Expand Up @@ -1365,7 +1361,7 @@ ($$$$)
waitpid($pid, 0) || fail "xargs digest $sum";
waitpid($pid2, 0) || fail "pipe write to xargs";
}
safe_chdir('/'); # Do not want to stay in $pkgdistdir
chdir_or_fail('/'); # Do not want to stay in $pkgdistdir
}
(sort keys %bad_distfiles);
}
Expand Down Expand Up @@ -1615,7 +1611,7 @@ ()
}

if ($opt{r}) {
safe_chdir("$pkgdistdir");
chdir_or_fail("$pkgdistdir");
verbose("Unlinking 'orphaned' distfiles\n");
foreach my $distfile (@orphan) {
unlink($distfile)
Expand All @@ -1642,7 +1638,7 @@ ()
}

if ($opt{r}) {
safe_chdir("$pkgdistdir");
chdir_or_fail("$pkgdistdir");
verbose("Unlinking 'parented' distfiles\n");
foreach my $distfile (@parent) {
unlink($distfile);
Expand Down Expand Up @@ -1779,7 +1775,7 @@ ()
}

print "$pkgsrcdir/$pkgdir\n";
safe_chdir("$pkgsrcdir/$pkgdir");
chdir_or_fail("$pkgsrcdir/$pkgdir");
system("$conf_make fetch-list | sh");
}
}
Expand Down

0 comments on commit 57ffca2

Please sign in to comment.