Skip to content

Commit

Permalink
Fix go vet warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
maruel committed Apr 14, 2017
1 parent 59bba8a commit 6cde1dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions host/pmem/smoketest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestSmokeTest_fail(t *testing.T) {
return nil, errors.New("oops")
}
count--
return allocRam(size)
return allocRAM(size)
}

if CopyTest(1024, 1, alloc, copyOk) == nil {
Expand All @@ -31,59 +31,59 @@ func TestSmokeTest_fail(t *testing.T) {
copyFail := func(d, s uint64) error {
return errors.New("oops")
}
if CopyTest(1024, 1, allocRam, copyFail) == nil {
if CopyTest(1024, 1, allocRAM, copyFail) == nil {
t.Fatal("copy failed")
}

copyNop := func(d, s uint64) error {
return nil
}
if CopyTest(1024, 1, allocRam, copyNop) == nil {
if CopyTest(1024, 1, allocRAM, copyNop) == nil {
t.Fatal("no copy")
}

copyPartial := func(d, s uint64) error {
return copyRam(d, s, 1024, 2)
return copyRAM(d, s, 1024, 2)
}
if CopyTest(1024, 1, allocRam, copyPartial) == nil {
if CopyTest(1024, 1, allocRAM, copyPartial) == nil {
t.Fatal("copy corrupted")
}

copyHdr := func(d, s uint64) error {
toSlice(d)[0] = 0
return nil
}
if CopyTest(1024, 1, allocRam, copyHdr) == nil {
if CopyTest(1024, 1, allocRAM, copyHdr) == nil {
t.Fatal("header corrupted")
}

copyFtr := func(d, s uint64) error {
toSlice(d)[1023] = 0
return copyRam(d, s, 1024, 1)
return copyRAM(d, s, 1024, 1)
}
if CopyTest(1024, 1, allocRam, copyFtr) == nil {
if CopyTest(1024, 1, allocRAM, copyFtr) == nil {
t.Fatal("footer corrupted")
}

copyOffset := func(d, s uint64) error {
copyRam(d, s, 1024, 1)
copyRAM(d, s, 1024, 1)
toSlice(d)[3] = 0
return nil
}
if CopyTest(1024, 1, allocRam, copyOffset) == nil {
if CopyTest(1024, 1, allocRAM, copyOffset) == nil {
t.Fatal("copy corrupted")
}
}

func TestSmokeTest(t *testing.T) {
// Successfully copy the memory.
if err := CopyTest(1024, 1, allocRam, copyOk); err != nil {
if err := CopyTest(1024, 1, allocRAM, copyOk); err != nil {
t.Fatal(err)
}
}

// allocRam allocates memory and fake it is physical memory.
func allocRam(size int) (Mem, error) {
// allocRAM allocates memory and fake it is physical memory.
func allocRAM(size int) (Mem, error) {
p := make([]byte, size)
return &MemAlloc{
View: View{
Expand All @@ -95,11 +95,11 @@ func allocRam(size int) (Mem, error) {
}

func copyOk(d, s uint64) error {
return copyRam(d, s, 1024, 1)
return copyRAM(d, s, 1024, 1)
}

// copyRam copies the memory.
func copyRam(pDst, pSrc uint64, size, hole int) error {
// copyRAM copies the memory.
func copyRAM(pDst, pSrc uint64, size, hole int) error {
dst := toSlice(pDst)
src := toSlice(pSrc)
copy(dst[hole:size-hole], src)
Expand Down
2 changes: 1 addition & 1 deletion host/sysfs/spi.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (s *SPI) DevParams(maxHz int64, mode spi.Mode, bits int) error {
// Only the first 8 bits are used. This only works because the system is
// running in little endian.
if err := s.setFlag(spiIOCMode, uint64(m)); err != nil {
return fmt.Errorf("sysfs-spi: setting mode %s failed: %v", mode, err)
return fmt.Errorf("sysfs-spi: setting mode %v failed: %v", mode, err)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion host/videocore/videocore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"periph.io/x/periph/host/pmem"
)

func Example_Alloc() {
func ExampleAlloc() {
// Allocates physical memory on a Broadcom CPU by leveraging the GPU.
// This memory can be leveraged to do DMA operations.
m, err := Alloc(64536)
Expand Down

0 comments on commit 6cde1dc

Please sign in to comment.