From bc1624cbfc717d1e44865c48160dfa1dea0fe49e Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Sat, 25 Mar 2023 20:20:49 -0400 Subject: [PATCH] archive/tar: linting errors I intend to not make changes to this `archive/tar` that aren't from upstream, or are not directly related to the usage by this project... Signed-off-by: Vincent Batts --- archive/tar/reader.go | 12 +++++++----- archive/tar/tar_test.go | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/archive/tar/reader.go b/archive/tar/reader.go index ea64a38..fcf3215 100644 --- a/archive/tar/reader.go +++ b/archive/tar/reader.go @@ -41,7 +41,7 @@ type fileReader interface { // RawBytes accesses the raw bytes of the archive, apart from the file payload itself. // This includes the header and padding. // -// This call resets the current rawbytes buffer +// # This call resets the current rawbytes buffer // // Only when RawAccounting is enabled, otherwise this returns nil func (tr *Reader) RawBytes() []byte { @@ -126,7 +126,9 @@ func (tr *Reader) next() (*Header, error) { return nil, err } if hdr.Typeflag == TypeXGlobalHeader { - mergePAX(hdr, paxHdrs) + if err = mergePAX(hdr, paxHdrs); err != nil { + return nil, err + } return &Header{ Name: hdr.Name, Typeflag: hdr.Typeflag, @@ -381,9 +383,9 @@ func parsePAX(r io.Reader) (map[string]string, error) { // header in case further processing is required. // // The err will be set to io.EOF only when one of the following occurs: -// * Exactly 0 bytes are read and EOF is hit. -// * Exactly 1 block of zeros is read and EOF is hit. -// * At least 2 blocks of zeros are read. +// - Exactly 0 bytes are read and EOF is hit. +// - Exactly 1 block of zeros is read and EOF is hit. +// - At least 2 blocks of zeros are read. func (tr *Reader) readHeader() (*Header, *block, error) { // Two blocks of zero bytes marks the end of the archive. n, err := io.ReadFull(tr.r, tr.blk[:]) diff --git a/archive/tar/tar_test.go b/archive/tar/tar_test.go index 6227e24..f1ce7fb 100644 --- a/archive/tar/tar_test.go +++ b/archive/tar/tar_test.go @@ -833,8 +833,8 @@ func Benchmark(b *testing.B) { // Write the archive to a byte buffer. tw := NewWriter(&buf) for _, file := range v.files { - tw.WriteHeader(file.hdr) - tw.Write(file.body) + _ = tw.WriteHeader(file.hdr) + _, _ = tw.Write(file.body) } tw.Close() b.Run(v.label, func(b *testing.B) {