Skip to content

Commit

Permalink
Fix nlreturn lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bodgit committed Apr 30, 2022
1 parent 5094747 commit f8bac7c
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/aes7z/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func (rc *readCloser) Close() error {
err = rc.rc.Close()
rc.rc, rc.br = nil, nil
}

return err
}

Expand All @@ -33,6 +34,7 @@ func (rc *readCloser) Password(p string) error {
return err
}
rc.br = cipherio.NewBlockReader(rc.rc, cipher.NewCBCDecrypter(block, rc.iv))

return nil
}

Expand All @@ -43,6 +45,7 @@ func (rc *readCloser) Read(p []byte) (int, error) {
if rc.br == nil {
return 0, errors.New("aes7z: no password set")
}

return rc.br.Read(p)
}

Expand Down
3 changes: 3 additions & 0 deletions internal/bcj2/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (rc *readCloser) Close() error {
if rc.main != nil {
err = multierror.Append(err, rc.main.Close(), rc.call.Close(), rc.jump.Close(), rc.rd.Close())
}

return err.ErrorOrNil()
}

Expand Down Expand Up @@ -127,6 +128,7 @@ func (rc *readCloser) decode(i int) (bool, error) {
if err := rc.update(); err != nil {
return false, err
}

return false, nil
}

Expand All @@ -136,6 +138,7 @@ func (rc *readCloser) decode(i int) (bool, error) {
if err := rc.update(); err != nil {
return false, err
}

return true, nil
}

Expand Down
2 changes: 2 additions & 0 deletions internal/bzip2/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ func (rc *readCloser) Close() error {
err = rc.c.Close()
rc.c, rc.r = nil, nil
}

return err
}

func (rc *readCloser) Read(p []byte) (int, error) {
if rc.r == nil {
return 0, errors.New("bzip2: Read after Close")
}

return rc.r.Read(p)
}

Expand Down
2 changes: 2 additions & 0 deletions internal/deflate/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (rc *readCloser) Close() error {
err = rc.c.Close()
rc.c, rc.fr = nil, nil
}

return err
}

Expand All @@ -36,6 +37,7 @@ func (rc *readCloser) Read(p []byte) (int, error) {
if rc.fr == nil {
return 0, errors.New("deflate: Read after Close")
}

return rc.fr.Read(p)
}

Expand Down
1 change: 1 addition & 0 deletions internal/delta/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func (rc *readCloser) Close() (err error) {
err = rc.rc.Close()
rc.rc = nil
}

return
}

Expand Down
2 changes: 2 additions & 0 deletions internal/lzma/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ func (rc *readCloser) Close() error {
err = rc.c.Close()
rc.c, rc.r = nil, nil
}

return err
}

func (rc *readCloser) Read(p []byte) (int, error) {
if rc.r == nil {
return 0, errors.New("lzma: Read after Close")
}

return rc.r.Read(p)
}

Expand Down
2 changes: 2 additions & 0 deletions internal/lzma2/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ func (rc *readCloser) Close() error {
err = rc.c.Close()
rc.c, rc.r = nil, nil
}

return err
}

func (rc *readCloser) Read(p []byte) (int, error) {
if rc.r == nil {
return 0, errors.New("lzma2: Read after Close")
}

return rc.r.Read(p)
}

Expand Down
2 changes: 2 additions & 0 deletions internal/util/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (rc *byteReadCloser) ReadByte() (byte, error) {
if n == 0 {
return 0, io.ErrNoProgress
}

return b[0], nil
}

Expand All @@ -50,5 +51,6 @@ func ByteReadCloser(r io.ReadCloser) ReadCloser {
if rc, ok := r.(ReadCloser); ok {
return rc
}

return &byteReadCloser{r}
}
12 changes: 12 additions & 0 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func OpenReaderWithPassword(name, password string) (*ReadCloser, error) {
info, err := f.Stat()
if err != nil {
err = multierror.Append(err, f.Close())

return nil, err
}

Expand All @@ -110,6 +111,7 @@ func OpenReaderWithPassword(name, password string) (*ReadCloser, error) {
for _, file := range files {
err = multierror.Append(err, file.Close())
}

return nil, err
}
files = append(files, f)
Expand All @@ -119,6 +121,7 @@ func OpenReaderWithPassword(name, password string) (*ReadCloser, error) {
for _, file := range files {
err = multierror.Append(err, file.Close())
}

return nil, err
}

Expand All @@ -134,6 +137,7 @@ func OpenReaderWithPassword(name, password string) (*ReadCloser, error) {
for _, file := range files {
err = multierror.Append(err, file.Close())
}

return nil, err
}
r.f = files
Expand Down Expand Up @@ -245,6 +249,7 @@ func readSizes(r io.ByteReader, count uint64) ([]uint64, error) {
}
sizes[i] = size
}

return sizes, nil
}

Expand Down Expand Up @@ -327,6 +332,7 @@ func readCoder(r util.Reader) (*coder, error) {
if err != nil {
return nil, err
}

return nil, errIncompleteRead
}

Expand Down Expand Up @@ -355,6 +361,7 @@ func readCoder(r util.Reader) (*coder, error) {
if err != nil {
return nil, err
}

return nil, errIncompleteRead
}
}
Expand Down Expand Up @@ -427,6 +434,7 @@ func readUnpackInfo(r util.Reader) (*unpackInfo, error) {
if err != nil {
return nil, err
}

return nil, errUnexpectedID
}

Expand Down Expand Up @@ -463,6 +471,7 @@ func readUnpackInfo(r util.Reader) (*unpackInfo, error) {
if err != nil {
return nil, err
}

return nil, errUnexpectedID
}

Expand Down Expand Up @@ -706,6 +715,7 @@ func readNames(r util.Reader, count, length uint64) ([]string, error) {
if i != count {
return nil, errors.New("sevenzip: wrong number of filenames")
}

return names, nil
}

Expand Down Expand Up @@ -1019,6 +1029,7 @@ func (z *Reader) init(r io.ReaderAt, size int64) error {
if err != nil {
return err
}

return errUnexpectedID
}

Expand Down Expand Up @@ -1074,5 +1085,6 @@ func (rc *ReadCloser) Close() error {
for _, f := range rc.f {
err = multierror.Append(err, f.Close())
}

return err.ErrorOrNil()
}
1 change: 1 addition & 0 deletions register.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ func decompressor(method []byte) Decompressor {
if !ok {
return nil
}

return di.(Decompressor)
}
10 changes: 10 additions & 0 deletions struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (f *folder) findInBindPair(i uint64) *bindPair {
return v
}
}

return nil
}

Expand All @@ -107,6 +108,7 @@ func (f *folder) findOutBindPair(i uint64) *bindPair {
return v
}
}

return nil
}

Expand Down Expand Up @@ -150,6 +152,7 @@ func newFolderReadCloser(rc io.ReadCloser) io.ReadCloser {
nrc := new(folderReadCloser)
nrc.h = crc32.NewIEEE()
nrc.rc = plumbing.TeeReadCloser(rc, nrc.h)

return nrc
}

Expand All @@ -162,6 +165,7 @@ func (f *folder) unpackSize() uint64 {
return f.size[i]
}
}

return f.size[len(f.size)-1]
}

Expand Down Expand Up @@ -202,6 +206,7 @@ func (si *streamsInfo) FileFolderAndSize(file int) (int, uint64) {
if streams == 1 {
return folder, si.unpackInfo.folder[folder].size[len(si.unpackInfo.folder[folder].coder)-1]
}

return folder, si.subStreamsInfo.size[file]
}

Expand All @@ -213,6 +218,7 @@ func (si *streamsInfo) folderOffset(folder int) int64 {
}
k += si.unpackInfo.folder[i].packedStreams
}

return int64(si.packInfo.position + offset)
}

Expand Down Expand Up @@ -278,6 +284,7 @@ func (si *streamsInfo) FolderReader(r io.ReaderAt, folder int, password string)
if si.unpackInfo.digest != nil {
return fr, si.unpackInfo.digest[folder], nil
}

return fr, 0, nil
}

Expand Down Expand Up @@ -363,6 +370,7 @@ func (h *FileHeader) Mode() (mode os.FileMode) {
} else {
mode = msdosModeToFileMode(h.Attributes)
}

return
}

Expand All @@ -375,6 +383,7 @@ func msdosModeToFileMode(m uint32) (mode os.FileMode) {
if m&msdosReadOnly != 0 {
mode &^= 0222
}

return mode
}

Expand Down Expand Up @@ -405,5 +414,6 @@ func unixModeToFileMode(m uint32) os.FileMode {
if m&sISVTX != 0 {
mode |= os.ModeSticky
}

return mode
}

0 comments on commit f8bac7c

Please sign in to comment.