perlcritic: each() called at line 752, column 35. The each function may cause undefined behavior when operating on the hash while iterating. Use a foreach loop over the hash's keys or values instead.

This commit is contained in:
Graham Christensen
2021-10-20 11:56:16 -04:00
parent 7dcf6a01c6
commit 4dfe787bc2
4 changed files with 16 additions and 8 deletions

View File

@ -753,7 +753,8 @@ sub checkJobsetWrapped {
if ($jobsetChanged) {
# Create JobsetEvalMembers mappings.
while (my ($id, $x) = each %buildMap) {
foreach my $id (keys %buildMap) {
my $x = $buildMap{$id};
$ev->jobsetevalmembers->create({ build => $id, isnew => $x->{new} });
}
@ -762,7 +763,8 @@ sub checkJobsetWrapped {
# builds for the same derivation, pick the one with the
# shortest name.
my %drvPathToId;
while (my ($id, $x) = each %buildMap) {
foreach my $id (keys %buildMap) {
my $x = $buildMap{$id};
my $y = $drvPathToId{$x->{drvPath}};
if (defined $y) {
next if length $x->{jobName} > length $y->{jobName};
@ -806,7 +808,8 @@ sub checkJobsetWrapped {
# Wake up hydra-queue-runner.
my $lowestId;
while (my ($id, $x) = each %buildMap) {
foreach my $id (keys %buildMap) {
my $x = $buildMap{$id};
$lowestId = $id if $x->{new} && (!defined $lowestId || $id < $lowestId);
}
$notifyAdded->execute($lowestId) if defined $lowestId;