Skip to content

Commit

Permalink
fix fmt.Errorf("%w", err) on err == nil
Browse files Browse the repository at this point in the history
When err is nil, `fmt.Errorf("....: %w", err)` should not be returned

Reported in rancher-sandbox/rancher-desktop issue 771

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
  • Loading branch information
AkihiroSuda committed Oct 13, 2021
1 parent 7e9eee8 commit 23a11df
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/copy_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ func copyFileContent(dst, src *os.File) error {
buf := bufferPool.Get().(*[]byte)
_, err = io.CopyBuffer(dst, src, *buf)
bufferPool.Put(buf)
return fmt.Errorf("userspace copy failed: %w", err)
if err != nil {
return fmt.Errorf("userspace copy failed: %w", err)
}
return nil
}

first = false
Expand Down

0 comments on commit 23a11df

Please sign in to comment.