Skip to content
Snippets Groups Projects
Unverified Commit d7a798d4 authored by GuokeCui's avatar GuokeCui Committed by GitHub
Browse files

Static check: fix apparent cases for `errcheck`; (#2520)

parent ee33d93e
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,10 @@ func startCPUProfile() func() {
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
err = pprof.StartCPUProfile(f)
if err != nil {
panic(err)
}
logutil.Infof("CPU profiling enabled, writing to %s", cpuProfilePath)
return func() {
pprof.StopCPUProfile()
......
......@@ -67,13 +67,15 @@ func TestString(t *testing.T) {
func TestPrepare(t *testing.T) {
for _, tc := range tcs {
Prepare(tc.proc, tc.arg)
err := Prepare(tc.proc, tc.arg)
require.NoError(t, err)
}
}
func TestOffset(t *testing.T) {
for _, tc := range tcs {
Prepare(tc.proc, tc.arg)
err := Prepare(tc.proc, tc.arg)
require.NoError(t, err)
tc.proc.Reg.MergeReceivers[0].Ch <- newBatch(t, tc.types, tc.proc, Rows)
tc.proc.Reg.MergeReceivers[0].Ch <- &batch.Batch{}
tc.proc.Reg.MergeReceivers[0].Ch <- nil
......@@ -100,7 +102,8 @@ func BenchmarkOffset(b *testing.B) {
t := new(testing.T)
for _, tc := range tcs {
Prepare(tc.proc, tc.arg)
err := Prepare(tc.proc, tc.arg)
require.NoError(t, err)
tc.proc.Reg.MergeReceivers[0].Ch <- newBatch(t, tc.types, tc.proc, BenchmarkRows)
tc.proc.Reg.MergeReceivers[0].Ch <- &batch.Batch{}
tc.proc.Reg.MergeReceivers[0].Ch <- nil
......
......@@ -42,7 +42,9 @@ func init() {
func startProfile() {
f, _ := os.Create(cpuprofile)
pprof.StartCPUProfile(f)
if err := pprof.StartCPUProfile(f); err != nil {
panic(err)
}
}
func stopProfile() {
......
......@@ -44,7 +44,9 @@ func init() {
func startProfile() {
f, _ := os.Create(cpuprofile)
pprof.StartCPUProfile(f)
if err := pprof.StartCPUProfile(f); err != nil {
panic(err)
}
}
func stopProfile() {
......
......@@ -103,7 +103,7 @@ func WriteUint32Array(w io.Writer, array []uint32) (n int64, err error) {
}
n = 4
for _, i := range array {
if binary.Write(w, binary.BigEndian, i); err != nil {
if err = binary.Write(w, binary.BigEndian, i); err != nil {
return
}
n += 4
......@@ -119,7 +119,7 @@ func ReadUint32Array(r io.Reader) (array []uint32, n int64, err error) {
n = 4
array = make([]uint32, length)
for i := 0; i < int(length); i++ {
if binary.Read(r, binary.BigEndian, &array[i]); err != nil {
if err = binary.Read(r, binary.BigEndian, &array[i]); err != nil {
return
}
n += 4
......
......@@ -99,7 +99,7 @@ func UnmarshalBatchFrom(r io.Reader) (vecTypes []types.Type, bat batch.IBatch, n
var size uint32
var vecs uint16
pos := 0
if binary.Read(r, binary.BigEndian, &size); err != nil {
if err = binary.Read(r, binary.BigEndian, &size); err != nil {
return
}
buf := make([]byte, size-4)
......@@ -107,11 +107,11 @@ func UnmarshalBatchFrom(r io.Reader) (vecTypes []types.Type, bat batch.IBatch, n
return
}
bbuf := bytes.NewBuffer(buf)
if binary.Read(bbuf, binary.BigEndian, &vecs); err != nil {
if err = binary.Read(bbuf, binary.BigEndian, &vecs); err != nil {
return
}
var rows uint32
if binary.Read(bbuf, binary.BigEndian, &rows); err != nil {
if err = binary.Read(bbuf, binary.BigEndian, &rows); err != nil {
return
}
pos += 2 + 4
......@@ -131,7 +131,7 @@ func UnmarshalBatchFrom(r io.Reader) (vecTypes []types.Type, bat batch.IBatch, n
col := vector.NewVector(vecTypes[i], uint64(rows))
cols[i] = col
attrs[i] = i
if col.(vector.IVectorNode).Unmarshal(buf[pos : pos+int(lens[i])]); err != nil {
if err = col.(vector.IVectorNode).Unmarshal(buf[pos : pos+int(lens[i])]); err != nil {
return
}
pos += int(lens[i])
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment