Skip to content

Commit

Permalink
Narrow down the scope of a variable
Browse files Browse the repository at this point in the history
Otherwise "err" refers to a variable outside of this closure,
not even to the one used by the immediate caller.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Jul 6, 2024
1 parent 041936d commit 597d314
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions copy/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,7 @@ func (ic *imageCopier) copyLayers(ctx context.Context) ([]compressiontypes.Algor
defer copyGroup.Wait()

for i, srcLayer := range srcInfos {
err = ic.c.concurrentBlobCopiesSemaphore.Acquire(ctx, 1)
if err != nil {
if err := ic.c.concurrentBlobCopiesSemaphore.Acquire(ctx, 1); err != nil {
// This can only fail with ctx.Err(), so no need to blame acquiring the semaphore.
return fmt.Errorf("copying layer: %w", err)
}
Expand Down

0 comments on commit 597d314

Please sign in to comment.