From 6d60889e3b65edb17a47c6b6940db32df85c808f Mon Sep 17 00:00:00 2001 From: Yi Duan Date: Tue, 28 Feb 2023 19:13:19 +0800 Subject: [PATCH] build: omit checkptr detects on unsafe functions (#372) * build: omit `checkptr` detect on unsafe functions * update CI --- .github/workflows/license-check.yml | 2 +- .github/workflows/push-check-go118.yml | 6 +++--- .github/workflows/push-check-linux-arm64.yml | 4 ++-- .github/workflows/push-check-linux-x64.yml | 4 ++-- .github/workflows/push-check-qemu.yml | 2 +- .github/workflows/push-check-windows.yml | 2 +- ast/api_amd64.go | 1 + ast/decode.go | 7 +++++++ internal/rt/fastmem.go | 1 - 9 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/license-check.yml b/.github/workflows/license-check.yml index 5034c2b..a2142dc 100644 --- a/.github/workflows/license-check.yml +++ b/.github/workflows/license-check.yml @@ -12,6 +12,6 @@ jobs: - uses: actions/checkout@v2 - name: Check License Header - uses: apache/skywalking-eyes/header@main + uses: apache/skywalking-eyes/header@v0.4.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/push-check-go118.yml b/.github/workflows/push-check-go118.yml index cc758fb..7308fc7 100644 --- a/.github/workflows/push-check-go118.yml +++ b/.github/workflows/push-check-go118.yml @@ -25,8 +25,8 @@ jobs: - name: Unit Test run: | - GOMAXPROCS=4 go test -v -race -gcflags=-d=checkptr=0 ./... - GOMAXPROCS=4 go test -v -race -gcflags=-d=checkptr=0 ./external_jsonlib_test/... + GOMAXPROCS=4 go test -v -race ./... + GOMAXPROCS=4 go test -v -race ./external_jsonlib_test/... - name: Generic Test - run: GOMAXPROCS=4 go test -v -race -gcflags=-d=checkptr=0 ./generic_test \ No newline at end of file + run: GOMAXPROCS=4 go test -v -race ./generic_test \ No newline at end of file diff --git a/.github/workflows/push-check-linux-arm64.yml b/.github/workflows/push-check-linux-arm64.yml index 3a1ee13..07ef84b 100644 --- a/.github/workflows/push-check-linux-arm64.yml +++ b/.github/workflows/push-check-linux-arm64.yml @@ -28,7 +28,7 @@ jobs: ${{ runner.os }}-go- - name: Compatibility Test - main - run: GOMAXPROCS=4 go test -v -gcflags=-d=checkptr=0 -race github.com/bytedance/sonic + run: GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic - name: Compatibility Test - ast - run: GOMAXPROCS=4 go test -v -gcflags=-d=checkptr=0 -race github.com/bytedance/sonic/ast + run: GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic/ast diff --git a/.github/workflows/push-check-linux-x64.yml b/.github/workflows/push-check-linux-x64.yml index 84fc932..a9ea132 100644 --- a/.github/workflows/push-check-linux-x64.yml +++ b/.github/workflows/push-check-linux-x64.yml @@ -28,6 +28,6 @@ jobs: - name: Unit Test run: | - go test -v -gcflags=-d=checkptr=0 ./... + go test -v ./... cd ./external_jsonlib_test - go test -v -gcflags=-d=checkptr=0 ./... + go test -v ./... diff --git a/.github/workflows/push-check-qemu.yml b/.github/workflows/push-check-qemu.yml index 9939aa4..a8863fc 100644 --- a/.github/workflows/push-check-qemu.yml +++ b/.github/workflows/push-check-qemu.yml @@ -32,5 +32,5 @@ jobs: printf ' #!/bin/bash\n if [ ! -x "/usr/bin/qemu-x86_64" ];then\n sudo apt-get update\n sudo apt-get -y install make gcc g++ libglib2.0-dev libpixman-1-dev libfdt-dev python3-pip ninja-build\n sudo pip3 install meson\n wget https://download.qemu.org/qemu-6.2.0.tar.xz\n tar -xvf qemu-6.2.0.tar.xz\n cd qemu-6.2.0\n sudo ./configure\n sudo make -j 4\n sudo make install\n cd ..\n cp /usr/local/bin/qemu-x86_64 /usr/bin/qemu-x86_64\n fi\n' > qemu_install.sh chmod +x qemu_install.sh ./qemu_install.sh - GOARCH=amd64 go test -gcflags=-d=checkptr=0 -c . + GOARCH=amd64 go test -c . qemu-x86_64 -cpu max ./sonic.test -test.v \ No newline at end of file diff --git a/.github/workflows/push-check-windows.yml b/.github/workflows/push-check-windows.yml index 7dfbb47..c5d022f 100644 --- a/.github/workflows/push-check-windows.yml +++ b/.github/workflows/push-check-windows.yml @@ -24,4 +24,4 @@ jobs: ${{ runner.os }}-go- - name: Compatibility Test - run: go test -v -gcflags=-d=checkptr=0 . + run: go test -v . diff --git a/ast/api_amd64.go b/ast/api_amd64.go index 6b3458a..32a60bc 100644 --- a/ast/api_amd64.go +++ b/ast/api_amd64.go @@ -17,6 +17,7 @@ import ( var typeByte = rt.UnpackEface(byte(0)).Type +//go:nocheckptr func quote(buf *[]byte, val string) { *buf = append(*buf, '"') if len(val) == 0 { diff --git a/ast/decode.go b/ast/decode.go index d54e983..fe00f82 100644 --- a/ast/decode.go +++ b/ast/decode.go @@ -24,6 +24,7 @@ func isSpace(c byte) bool { return (int(1<= '0' && c <= '9' } +//go:nocheckptr func decodeInt64(src string, pos int) (ret int, v int64, err error) { sp := uintptr(rt.IndexChar(src, pos)) ss := uintptr(sp) @@ -161,6 +164,7 @@ func isNumberChars(c byte) bool { return (c >= '0' && c <= '9') || c == '+' || c == '-' || c == 'e' || c == 'E' || c == '.' } +//go:nocheckptr func decodeFloat64(src string, pos int) (ret int, v float64, err error) { sp := uintptr(rt.IndexChar(src, pos)) ss := uintptr(sp) @@ -255,6 +259,7 @@ func decodeValue(src string, pos int) (ret int, v types.JsonState) { } } +//go:nocheckptr func skipNumber(src string, pos int) (ret int) { sp := uintptr(rt.IndexChar(src, pos)) se := uintptr(rt.IndexChar(src, len(src))) @@ -319,6 +324,7 @@ func skipNumber(src string, pos int) (ret int) { return int(uintptr(sp) - uintptr((*rt.GoString)(unsafe.Pointer(&src)).Ptr)) } +//go:nocheckptr func skipString(src string, pos int) (ret int, ep int) { if pos+1 >= len(src) { return -int(types.ERR_EOF), -1 @@ -356,6 +362,7 @@ func skipString(src string, pos int) (ret int, ep int) { return int(uintptr(sp) - uintptr((*rt.GoString)(unsafe.Pointer(&src)).Ptr)), ep } +//go:nocheckptr func skipPair(src string, pos int, lchar byte, rchar byte) (ret int) { if pos+1 >= len(src) { return -int(types.ERR_EOF) diff --git a/internal/rt/fastmem.go b/internal/rt/fastmem.go index 358ce80..5bf80dd 100644 --- a/internal/rt/fastmem.go +++ b/internal/rt/fastmem.go @@ -87,7 +87,6 @@ func GuardSlice(buf *[]byte, n int) { copy(tmp, *buf) *buf = tmp } - return } //go:nosplit