Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: make errcheck works correctly #12381

Merged
merged 5 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ check-slow:tools/bin/gometalinter tools/bin/gosec

errcheck:tools/bin/errcheck
@echo "errcheck"
@GO111MODULE=on tools/bin/errcheck -exclude ./tools/check/errcheck_excludes.txt -blank $(PACKAGES) | grep -v "_test\.go" | awk '{print} END{if(NR>0) {exit 1}}'
@GO111MODULE=on tools/bin/errcheck -exclude ./tools/check/errcheck_excludes.txt -ignoretests -blank $(PACKAGES)

gogenerate:
@echo "go generate ./..."
Expand Down
4 changes: 3 additions & 1 deletion planner/core/rule_max_min_eliminate.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ func (a *maxMinEliminator) splitAggFuncAndCheckIndices(agg *LogicalAggregation)
newAgg := LogicalAggregation{AggFuncs: []*aggregation.AggFuncDesc{f}}.Init(agg.ctx, agg.blockOffset)
newAgg.SetChildren(a.cloneSubPlans(agg.children[0]))
newAgg.schema = expression.NewSchema(agg.schema.Columns[i])
newAgg.PruneColumns([]*expression.Column{newAgg.schema.Columns[0]})
if err := newAgg.PruneColumns([]*expression.Column{newAgg.schema.Columns[0]}); err != nil {
return nil, false
}
aggs = append(aggs, newAgg)
}
return aggs, true
Expand Down
4 changes: 3 additions & 1 deletion statistics/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ func ValueToString(value *types.Datum, idxCols int) (string, error) {
return value.ToString()
}
// Ignore the error and treat remaining part that cannot decode successfully as bytes.
decodedVals, remained, _ := codec.DecodeRange(value.GetBytes(), idxCols)
decodedVals, remained, err := codec.DecodeRange(value.GetBytes(), idxCols)
// Ignore err explicit to pass errcheck.
_ = err
Deardrops marked this conversation as resolved.
Show resolved Hide resolved
if len(remained) > 0 {
decodedVals = append(decodedVals, types.NewBytesDatum(remained))
}
Expand Down
7 changes: 3 additions & 4 deletions store/mockstore/mocktikv/mvcc_leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1498,14 +1498,13 @@ func (mvcc *MVCCLevelDB) MvccGetByStartTS(starTS uint64) (*kvrpcpb.MvccInfo, []b
var value mvccValue
err := value.UnmarshalBinary(iter.Value())
if err == nil && value.startTS == starTS {
_, key, _ = codec.DecodeBytes(iter.Key(), nil)
if _, key, err = codec.DecodeBytes(iter.Key(), nil); err != nil {
return nil, nil
}
break
}
iter.Next()
}
if key == nil {
return nil, nil
}

return mvcc.MvccGetByKey(key), key
}
Expand Down
1 change: 1 addition & 0 deletions tools/check/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/nicksnyder/go-i18n v1.10.0 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/securego/gosec v0.0.0-20181211171558-12400f9a1ca7
golang.org/x/tools v0.0.0-20190925020647-22afafe3322a // indirect
gopkg.in/alecthomas/gometalinter.v2 v2.0.12 // indirect
gopkg.in/alecthomas/gometalinter.v3 v3.0.0 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
Expand Down
8 changes: 8 additions & 0 deletions tools/check/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,23 @@ github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735/go.mod h1:807d1WS
github.com/securego/gosec v0.0.0-20181211171558-12400f9a1ca7 h1:Ca7U7/rZ+caxjW2na7wbmgmaPsoSCIlpc6sm0aWtFg0=
github.com/securego/gosec v0.0.0-20181211171558-12400f9a1ca7/go.mod h1:m3KbCTwh9vLhm6AKBjE+ALesKilKcQHezI1uVOti0Ks=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20170915142106-8351a756f30f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20171026204733-164713f0dfce/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.0.0-20170915090833-1cbadb444a80/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20170915040203-e531a2a1c15f/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180911133044-677d2ff680c1/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563 h1:NIou6eNFigscvKJmsbyez16S2cIS6idossORlFtSt2E=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190925020647-22afafe3322a h1:3GxqzBPBt1O2dIiPnzldQ5d25CAMWJFBZTpqxLPfjs8=
golang.org/x/tools v0.0.0-20190925020647-22afafe3322a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/alecthomas/gometalinter.v2 v2.0.12 h1:/xBWwtjmOmVxn8FXfIk9noV8m2E2Id9jFfUY/Mh9QAI=
gopkg.in/alecthomas/gometalinter.v2 v2.0.12/go.mod h1:NDRytsqEZyolNuAgTzJkZMkSQM7FIKyzVzGhjB/qfYo=
gopkg.in/alecthomas/gometalinter.v3 v3.0.0 h1:tKnpLD70cWDacxrv9JZ4atld7RPoPiHOBfad6mPmyBw=
Expand Down
7 changes: 5 additions & 2 deletions util/chunk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ var bufReaderPool = sync.Pool{
var tmpDir = path.Join(os.TempDir(), "tidb-server-"+path.Base(os.Args[0]))

func init() {
_ = os.RemoveAll(tmpDir) // clean the uncleared temp file during the last run.
err := os.Mkdir(tmpDir, 0755)
err := os.RemoveAll(tmpDir) // clean the uncleared temp file during the last run.
if err != nil {
SunRunAway marked this conversation as resolved.
Show resolved Hide resolved
log.Warn("Remove temporary file error", zap.String("tmpDir", tmpDir), zap.Error(err))
}
err = os.Mkdir(tmpDir, 0755)
if err != nil {
log.Warn("Mkdir temporary file error", zap.String("tmpDir", tmpDir), zap.Error(err))
}
Expand Down