Switch to Go 1.23 and fix CI failures

Some new upcoming changes require us to use Go 1.23. However, if we switch to Go 1.23 some
new linter errors are showing up. This commit fixes most of the errors and adds an
exclusion for integer overflow errors.

Signed-off-by: Amit <ambarve@microsoft.com>
This commit is contained in:
Amit
2025-10-27 09:08:22 -07:00
committed by Amit Barve
parent bdc6c11280
commit fd34511314
52 changed files with 41 additions and 82 deletions
-1
View File
@@ -1,5 +1,4 @@
//go:build windows || linux
// +build windows linux
package wim
+12 -12
View File
@@ -100,7 +100,7 @@ func (f *decompressor) ensureAtLeast(n int) error {
}
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)
@@ -153,28 +153,28 @@ func buildTable(codelens []byte) *huffman {
// Determine the number of codes of each length, and the
// maximum length.
var count [maxTreePathLen + 1]uint
var max byte
var maxValue byte
for _, cl := range codelens {
count[cl]++
if max < cl {
max = cl
if maxValue < cl {
maxValue = cl
}
}
if max == 0 {
if maxValue == 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 <= maxValue; i++ {
code <<= 1
first[i] = code
code += count[i]
}
if code != 1<<max {
if code != 1<<maxValue {
return nil
}
@@ -182,14 +182,14 @@ func buildTable(codelens []byte) *huffman {
// 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: maxValue}
if maxValue > 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<<(maxValue-tablebits))
}
}
@@ -206,8 +206,8 @@ func buildTable(codelens []byte) *huffman {
} 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 << (maxValue - cl)
for j := uint(0); j < 1<<(maxValue-cl); j++ {
h.extra[h.table[prefix]][extendedCode+j] = v
}
}
-1
View File
@@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package main
-1
View File
@@ -1,5 +1,4 @@
//go:build windows
// +build windows
package main
-1
View File
@@ -1,5 +1,4 @@
//go:build windows || linux
// +build windows linux
// Package wim implements a WIM file parser.
//