From 23a11df3824c0e2868cff8775369f3cbd3430226 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Wed, 13 Oct 2021 20:04:33 +0900 Subject: [PATCH] fix fmt.Errorf("%w", err) on err == nil 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 --- fs/copy_linux.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/copy_linux.go b/fs/copy_linux.go index 64602e07..395d0950 100644 --- a/fs/copy_linux.go +++ b/fs/copy_linux.go @@ -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