Skip to content

Commit

Permalink
Update golangci-lint.
Browse files Browse the repository at this point in the history
Signed-off-by: Nuno Cruces <[email protected]>
  • Loading branch information
ncruces committed Aug 14, 2024
1 parent 81b68be commit b2c6068
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- 'netlify.toml'

env: # Update this prior to requiring a higher minor version in go.mod
GO_VERSION: "1.22"
GO_VERSION: "1.23"

defaults:
run: # use bash for all operating systems unless overridden
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

gofumpt := mvdan.cc/gofumpt@v0.5.0
gofumpt := mvdan.cc/gofumpt@v0.6.0
gosimports := github.com/rinchsan/gosimports/cmd/[email protected]
golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2
golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1
asmfmt := github.com/klauspost/asmfmt/cmd/[email protected]
# sync this with netlify.toml!
hugo := github.com/gohugoio/[email protected]
Expand Down
3 changes: 2 additions & 1 deletion internal/engine/wazevo/backend/isa/amd64/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func stackView(rbp, top uintptr) []byte {
l := int(top - rbp)
var stackBuf []byte
{
//nolint:staticcheck
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&stackBuf))
hdr.Data = rbp
hdr.Len = l
Expand Down Expand Up @@ -75,7 +76,7 @@ func GoCallStackView(stackPointerBeforeGoCall *uint64) []uint64 {
// (low address)
data := unsafe.Add(unsafe.Pointer(stackPointerBeforeGoCall), 8)
size := *stackPointerBeforeGoCall / 8
return unsafe.Slice((*uint64)(data), int(size))
return unsafe.Slice((*uint64)(data), size)
}

func AdjustClonedStack(oldRsp, oldTop, rsp, rbp, top uintptr) {
Expand Down
11 changes: 3 additions & 8 deletions internal/engine/wazevo/backend/isa/arm64/unwind_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func UnwindStack(sp, _, top uintptr, returnAddresses []uintptr) []uintptr {

var stackBuf []byte
{
//nolint:staticcheck
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&stackBuf))
hdr.Data = sp
hdr.Len = l
Expand Down Expand Up @@ -77,13 +78,7 @@ func GoCallStackView(stackPointerBeforeGoCall *uint64) []uint64 {
// +-----------------+ <---- stackPointerBeforeGoCall
// (low address)
ptr := unsafe.Pointer(stackPointerBeforeGoCall)
data := (*uint64)(unsafe.Add(ptr, 16)) // skips the (frame_size, sliceSize).
size := *(*uint64)(unsafe.Add(ptr, 8))
var view []uint64
{
sh := (*reflect.SliceHeader)(unsafe.Pointer(&view))
sh.Data = uintptr(unsafe.Add(ptr, 16)) // skips the (frame_size, sliceSize).
sh.Len = int(size)
sh.Cap = int(size)
}
return view
return unsafe.Slice(data, size)
}
2 changes: 2 additions & 0 deletions internal/engine/wazevo/call_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ func (c *callEngine) cloneStack(l uintptr) (newSP, newFP, newTop uintptr, newSta
// Copy the existing contents in the previous Go-allocated stack into the new one.
var prevStackAligned, newStackAligned []byte
{
//nolint:staticcheck
sh := (*reflect.SliceHeader)(unsafe.Pointer(&prevStackAligned))
sh.Data = c.stackTop - relSp
sh.Len = int(relSp)
Expand All @@ -563,6 +564,7 @@ func (c *callEngine) cloneStack(l uintptr) (newSP, newFP, newTop uintptr, newSta
{
newSP = newTop - relSp
newFP = newTop - relFp
//nolint:staticcheck
sh := (*reflect.SliceHeader)(unsafe.Pointer(&newStackAligned))
sh.Data = newSP
sh.Len = int(relSp)
Expand Down
1 change: 1 addition & 0 deletions internal/engine/wazevo/call_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestCallEngine_growStack(t *testing.T) {

var view []byte
{
//nolint:staticcheck
sh := (*reflect.SliceHeader)(unsafe.Pointer(&view))
sh.Data = newSP
sh.Len = 5
Expand Down
1 change: 1 addition & 0 deletions internal/engine/wazevo/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func TestCompiledModule_functionIndexOf(t *testing.T) {
const executableAddr = 0xaaaa
var executable []byte
{
//nolint:staticcheck
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&executable))
hdr.Data = executableAddr
hdr.Len = 0xffff
Expand Down
5 changes: 5 additions & 0 deletions internal/engine/wazevo/hostmodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func buildHostModuleOpaque(m *wasm.Module, listeners []experimental.FunctionList
binary.LittleEndian.PutUint64(ret[0:], uint64(uintptr(unsafe.Pointer(m))))

if len(listeners) > 0 {
//nolint:staticcheck
sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&listeners))
binary.LittleEndian.PutUint64(ret[8:], uint64(sliceHeader.Data))
binary.LittleEndian.PutUint64(ret[16:], uint64(sliceHeader.Len))
Expand All @@ -33,6 +34,7 @@ func buildHostModuleOpaque(m *wasm.Module, listeners []experimental.FunctionList

func hostModuleFromOpaque(opaqueBegin uintptr) *wasm.Module {
var opaqueViewOverSlice []byte
//nolint:staticcheck
sh := (*reflect.SliceHeader)(unsafe.Pointer(&opaqueViewOverSlice))
sh.Data = opaqueBegin
sh.Len = 32
Expand All @@ -42,6 +44,7 @@ func hostModuleFromOpaque(opaqueBegin uintptr) *wasm.Module {

func hostModuleListenersSliceFromOpaque(opaqueBegin uintptr) []experimental.FunctionListener {
var opaqueViewOverSlice []byte
//nolint:staticcheck
sh := (*reflect.SliceHeader)(unsafe.Pointer(&opaqueViewOverSlice))
sh.Data = opaqueBegin
sh.Len = 32
Expand All @@ -51,6 +54,7 @@ func hostModuleListenersSliceFromOpaque(opaqueBegin uintptr) []experimental.Func
l := binary.LittleEndian.Uint64(opaqueViewOverSlice[16:])
c := binary.LittleEndian.Uint64(opaqueViewOverSlice[24:])
var ret []experimental.FunctionListener
//nolint:staticcheck
sh = (*reflect.SliceHeader)(unsafe.Pointer(&ret))
sh.Data = uintptr(b)
sh.Len = int(l)
Expand All @@ -63,6 +67,7 @@ func hostModuleGoFuncFromOpaque[T any](index int, opaqueBegin uintptr) T {
ptr := opaqueBegin + offset

var opaqueViewOverFunction []byte
//nolint:staticcheck
sh := (*reflect.SliceHeader)(unsafe.Pointer(&opaqueViewOverFunction))
sh.Data = ptr
sh.Len = 16
Expand Down
2 changes: 2 additions & 0 deletions internal/wasm/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ func PagesToUnitOfBytes(pages uint32) string {

// Uses atomic write to update the length of a slice.
func atomicStoreLengthAndCap(slice *[]byte, length uintptr, cap uintptr) {
//nolint:staticcheck
slicePtr := (*reflect.SliceHeader)(unsafe.Pointer(slice))
capPtr := (*uintptr)(unsafe.Pointer(&slicePtr.Cap))
atomic.StoreUintptr(capPtr, cap)
Expand All @@ -314,6 +315,7 @@ func atomicStoreLengthAndCap(slice *[]byte, length uintptr, cap uintptr) {

// Uses atomic write to update the length of a slice.
func atomicStoreLength(slice *[]byte, length uintptr) {
//nolint:staticcheck
slicePtr := (*reflect.SliceHeader)(unsafe.Pointer(slice))
lenPtr := (*uintptr)(unsafe.Pointer(&slicePtr.Len))
atomic.StoreUintptr(lenPtr, length)
Expand Down
1 change: 1 addition & 0 deletions internal/wasm/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ func TestMemoryInstance_Write_overflow(t *testing.T) {
}

buf := []byte{16, 0, 0, 4}
//nolint:staticcheck
header := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
header.Len = int(huge)
header.Cap = int(huge)
Expand Down
1 change: 0 additions & 1 deletion internal/wasmdebug/dwarf.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ entry:
// Advance the line reader for the found position.
lineReader.Seek(ln.pos)
err = lineReader.Next(&le)

if err != nil {
// If we reach this block, that means there's a bug in the []line creation logic above.
panic("BUG: stored dwarf.LineReaderPos is invalid")
Expand Down

0 comments on commit b2c6068

Please sign in to comment.