Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ linters-settings:
nolintlint:
require-explanation: true
require-specific: true
gosec:
excludes:
- G115 # G115: integer overflow conversion; TODO: currently too many (false) positives in generated code that need to be verified
Comment on lines +75 to +77
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a global ignore for this one for now; I think most of these are likely false positives in generated code, but would have to be reviewed by someone with more understanding of those parts of the code.

revive:
# revive is more configurable than static check, so likely the preferred alternative to static-check
# (once the perf issue is solved: https://github.com/golangci/golangci-lint/issues/2997)
Expand Down
10 changes: 5 additions & 5 deletions hvsock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@
case <-ch:
case <-t.C:
u.T.Helper()
u.T.Fatalf(msgJoin(msgs, "timed out after %v"), d)
u.T.Fatal(msgJoin(msgs, fmt.Sprintf("timed out after %v", d)))
}
}

Expand All @@ -619,7 +619,7 @@
case err := <-ch:
if err != nil {
u.T.Helper()
u.T.Fatalf(msgJoin(msgs, "%v"), err)
u.T.Fatalf(msgJoin(msgs, err.Error()))

Check failure on line 622 in hvsock_test.go

View workflow job for this annotation

GitHub Actions / Lint

SA1006: printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck)
}
case <-t.C:
u.T.Helper()
Expand All @@ -632,23 +632,23 @@
return
}
u.T.Helper()
u.T.Fatalf(msgJoin(msgs, "failed assertion"))
u.T.Fatal(msgJoin(msgs, "failed assertion"))
}

func (u testUtil) Is(err, target error, msgs ...string) {
if errors.Is(err, target) {
return
}
u.T.Helper()
u.T.Fatalf(msgJoin(msgs, "got error %q; wanted %q"), err, target)
u.T.Fatal(msgJoin(msgs, fmt.Sprintf("got error %q; wanted %q", err, target)))
}

func (u testUtil) Must(err error, msgs ...string) {
if err == nil {
return
}
u.T.Helper()
u.T.Fatalf(msgJoin(msgs, "%v"), err)
u.T.Fatal(msgJoin(msgs, err.Error()))
}

// Check stops execution if testing failed in another go-routine.
Expand Down
26 changes: 13 additions & 13 deletions wim/lzx/lzx.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
}
n, err := io.ReadAtLeast(f.r, f.b[f.bv-f.bo:], n)
if err != nil {
if err == io.EOF { //nolint:errorlint
if err == io.EOF {
err = io.ErrUnexpectedEOF
} else {
f.fail(err)
Expand All @@ -117,7 +117,7 @@
// Otherwise, on error, it sets f.err.
func (f *decompressor) feed() bool {
err := f.ensureAtLeast(2)
if err == io.ErrUnexpectedEOF { //nolint:errorlint // returns io.ErrUnexpectedEOF by contract
if err == io.ErrUnexpectedEOF {

Check failure on line 120 in wim/lzx/lzx.go

View workflow job for this annotation

GitHub Actions / Lint

comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
return false
}
f.c |= (uint32(f.b[f.bo+1])<<8 | uint32(f.b[f.bo])) << (16 - f.nbits)
Expand Down Expand Up @@ -153,43 +153,43 @@
// Determine the number of codes of each length, and the
// maximum length.
var count [maxTreePathLen + 1]uint
var max byte
var clMax byte
for _, cl := range codelens {
count[cl]++
if max < cl {
max = cl
if clMax < cl {
clMax = cl
}
}

if max == 0 {
if clMax == 0 {
return &huffman{}
}

// Determine the first code of each length.
var first [maxTreePathLen + 1]uint
code := uint(0)
for i := byte(1); i <= max; i++ {
for i := byte(1); i <= clMax; i++ {
code <<= 1
first[i] = code
code += count[i]
}

if code != 1<<max {
if code != 1<<clMax {
return nil
}

// Build a table for code lookup. For code sizes < max,
// put all possible suffixes for the code into the table, too.
// For max > tablebits, split long codes into additional tables
// of suffixes of max-tablebits length.
h := &huffman{maxbits: max}
if max > tablebits {
h := &huffman{maxbits: clMax}
if clMax > tablebits {
core := first[tablebits+1] / 2 // Number of codes that fit without extra tables
nextra := 1<<tablebits - core // Number of extra entries
h.extra = make([][]uint16, nextra)
for code := core; code < 1<<tablebits; code++ {
h.table[code] = uint16(code - core)
h.extra[code-core] = make([]uint16, 1<<(max-tablebits))
h.extra[code-core] = make([]uint16, 1<<(clMax-tablebits))
}
}

Expand All @@ -206,8 +206,8 @@
} else {
prefix := code >> (cl - tablebits)
suffix := code & (1<<(cl-tablebits) - 1)
extendedCode := suffix << (max - cl)
for j := uint(0); j < 1<<(max-cl); j++ {
extendedCode := suffix << (clMax - cl)
for j := uint(0); j < 1<<(clMax-cl); j++ {
h.extra[h.table[prefix]][extendedCode+j] = v
}
}
Expand Down
Loading