Explicitly ignore error at many call sites for clarity

Used the following:
  go get github.com/kisielk/errcheck
  errcheck -ignore 'Close|rintf' ./...

While some are irrelevant, there were some genuine issues so this is worth
enforcing, hence a few innocuous places were 'fixed' so that the list could go
down to zero.

Do not enforce this in travis yet, but should be done soon.
pull/1/head
Marc-Antoine Ruel 8 years ago
parent 161a9035d2
commit 5b5d0de02f

@ -1079,7 +1079,9 @@ func BenchmarkHalt(b *testing.B) {
d, _ := New(spitest.NewRecordRaw(ioutil.Discard), &DefaultOpts) d, _ := New(spitest.NewRecordRaw(ioutil.Discard), &DefaultOpts)
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
d.Halt() if err := d.Halt(); err != nil {
b.Fatal(err)
}
} }
} }

@ -91,8 +91,9 @@ func (m *MPU9250) Init() error {
// Calibrate Calibrates the device using maximum precision for both Gyroscope and Accelerometer. // Calibrate Calibrates the device using maximum precision for both Gyroscope and Accelerometer.
func (m *MPU9250) Calibrate() error { func (m *MPU9250) Calibrate() error {
m.transferBatch(calibrateSequence, "error calibrating %d: [%x:%x] => %v") if err := m.transferBatch(calibrateSequence, "error calibrating %d: [%x:%x] => %v"); err != nil {
return err
}
reads, err := m.GetFIFOCount() // read FIFO sample count reads, err := m.GetFIFOCount() // read FIFO sample count
if err != nil { if err != nil {
return wrapf("can't get FIFO => %v", err) return wrapf("can't get FIFO => %v", err)

@ -59,8 +59,7 @@ func (device *Dev) String() string {
// Halting the unicorn HD sets all the pixels to black. Error is always nil. // Halting the unicorn HD sets all the pixels to black. Error is always nil.
func (device *Dev) Halt() error { func (device *Dev) Halt() error {
black := color.RGBA{0, 0, 0, 0} black := color.RGBA{0, 0, 0, 0}
device.Draw(device.Bounds(), &image.Uniform{black}, image.ZP) return device.Draw(device.Bounds(), &image.Uniform{black}, image.ZP)
return nil
} }
// ColorModel implements devices.Display. There's no surprise, it is // ColorModel implements devices.Display. There's no surprise, it is

@ -82,8 +82,9 @@ func TestHalt(t *testing.T) {
} }
buf := bytes.Buffer{} buf := bytes.Buffer{}
dev, _ := NewUnicornhd(spitest.NewRecordRaw(&buf)) dev, _ := NewUnicornhd(spitest.NewRecordRaw(&buf))
if err := dev.Halt(); err != nil {
dev.Halt() t.Fatal(err)
}
if !bytes.Equal(expectedAllBlack, buf.Bytes()) { if !bytes.Equal(expectedAllBlack, buf.Bytes()) {
t.Fatalf("%#v != %#v", expectedAllBlack, buf.Bytes()) t.Fatalf("%#v != %#v", expectedAllBlack, buf.Bytes())
@ -163,8 +164,9 @@ func TestDrawWritesBlackImageToSpi(t *testing.T) {
buf := bytes.Buffer{} buf := bytes.Buffer{}
dev, _ := NewUnicornhd(spitest.NewRecordRaw(&buf)) dev, _ := NewUnicornhd(spitest.NewRecordRaw(&buf))
black := color.RGBA{0, 0, 0, 0} black := color.RGBA{0, 0, 0, 0}
if err := dev.Draw(dev.Bounds(), &image.Uniform{black}, image.ZP); err != nil {
dev.Draw(dev.Bounds(), &image.Uniform{black}, image.ZP) t.Fatal(err)
}
if !bytes.Equal(expectedAllBlack, buf.Bytes()) { if !bytes.Equal(expectedAllBlack, buf.Bytes()) {
t.Fatalf("%#v != %#v", expectedAllBlack, buf.Bytes()) t.Fatalf("%#v != %#v", expectedAllBlack, buf.Bytes())
@ -217,8 +219,9 @@ func TestDrawWritesWhiteImageToSpi(t *testing.T) {
buf := bytes.Buffer{} buf := bytes.Buffer{}
dev, _ := NewUnicornhd(spitest.NewRecordRaw(&buf)) dev, _ := NewUnicornhd(spitest.NewRecordRaw(&buf))
white := color.RGBA{255, 255, 255, 255} white := color.RGBA{255, 255, 255, 255}
if err := dev.Draw(dev.Bounds(), &image.Uniform{white}, image.ZP); err != nil {
dev.Draw(dev.Bounds(), &image.Uniform{white}, image.ZP) t.Fatal(err)
}
if !bytes.Equal(expectedAllWhite, buf.Bytes()) { if !bytes.Equal(expectedAllWhite, buf.Bytes()) {
t.Fatalf("%#v != %#v", expectedAllWhite, buf.Bytes()) t.Fatalf("%#v != %#v", expectedAllWhite, buf.Bytes())
@ -288,7 +291,9 @@ func TestDrawWritesSequenceImageToSpi(t *testing.T) {
img.Set(x, y, clr) img.Set(x, y, clr)
} }
} }
dev.Draw(dev.Bounds(), img, image.ZP) if err := dev.Draw(dev.Bounds(), img, image.ZP); err != nil {
t.Fatal(err)
}
if !bytes.Equal(expectedSequence, buf.Bytes()) { if !bytes.Equal(expectedSequence, buf.Bytes()) {
t.Fatalf("%#v != %#v", expectedSequence, buf.Bytes()) t.Fatalf("%#v != %#v", expectedSequence, buf.Bytes())
@ -349,8 +354,9 @@ func TestDrawSupportsPartialUpdates(t *testing.T) {
buf := bytes.Buffer{} buf := bytes.Buffer{}
dev, _ := NewUnicornhd(spitest.NewRecordRaw(&buf)) dev, _ := NewUnicornhd(spitest.NewRecordRaw(&buf))
white := color.RGBA{0xFF, 0xFF, 0xFF, 0xFF} white := color.RGBA{0xFF, 0xFF, 0xFF, 0xFF}
if err := dev.Draw(image.Rect(0, 0, 3, 3), &image.Uniform{white}, image.ZP); err != nil {
dev.Draw(image.Rect(0, 0, 3, 3), &image.Uniform{white}, image.ZP) t.Fatal(err)
}
if !bytes.Equal(expectedWhiteSquare, buf.Bytes()) { if !bytes.Equal(expectedWhiteSquare, buf.Bytes()) {
t.Fatalf("%#v != %#v", expectedWhiteSquare, buf.Bytes()) t.Fatalf("%#v != %#v", expectedWhiteSquare, buf.Bytes())

Loading…
Cancel
Save