Skip to content

Commit

Permalink
Please go vet (#257)
Browse files Browse the repository at this point in the history
* Remove unused function

This unused function triggered go vet

github.com/bio-routing/bio-rd/syscallwrappers
[error]syscallwrappers/syscalls_linux.go:75:9: possible misuse of unsafe.Pointer

* Remove unreachable code

* Use keyed syntax for composite literals

* Remove copies of mutex locks
  • Loading branch information
hikhvar authored Apr 15, 2020
1 parent f867f17 commit 8f75257
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 21 deletions.
6 changes: 3 additions & 3 deletions net/ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ func TestIPFromProtoIP(t *testing.T) {
},
}

for _, test := range tests {
res := IPFromProtoIP(&test.proto)
assert.Equal(t, test.expected, res, test.name)
for i := range tests {
res := IPFromProtoIP(&tests[i].proto)
assert.Equal(t, tests[i].expected, res, tests[i].name)
}
}

Expand Down
6 changes: 3 additions & 3 deletions net/prefix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ func TestNewPrefixFromProtoPrefix(t *testing.T) {
},
}

for _, test := range tests {
res := NewPrefixFromProtoPrefix(&test.proto)
assert.Equal(t, test.expected, *res, test.name)
for i := range tests {
res := NewPrefixFromProtoPrefix(&tests[i].proto)
assert.Equal(t, tests[i].expected, *res, tests[i].name)
}
}

Expand Down
2 changes: 1 addition & 1 deletion protocols/bgp/server/fsm_address_family_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestFSMAFIInitDispose(t *testing.T) {

wg := sync.WaitGroup{}
wg.Add(1)
assert.Equal(t, wg, f.updateSender.wg)
assert.EqualValues(t, &wg, &f.updateSender.wg)

assert.Equal(t, uint64(1), f.adjRIBOut.ClientCount())

Expand Down
2 changes: 0 additions & 2 deletions protocols/device/server_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ func (o *osAdapterLinux) monitorLinks(chLU chan netlink.LinkUpdate) {
o.processLinkUpdate(&lu)
}
}

return
}

func linkUpdateToDevice(attrs *netlink.LinkAttrs) *Device {
Expand Down
6 changes: 3 additions & 3 deletions routingtable/adjRIBIn/adj_rib_in_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ func TestUnregister(t *testing.T) {

r := mc.Removed()
assert.Equalf(t, 3, len(r), "Should have removed 3 paths, but only removed %d", len(r))
assert.Equal(t, &routingtable.RemovePathParams{pfxs[0], paths[0]}, r[0], "Withdraw 1")
assert.Equal(t, &routingtable.RemovePathParams{pfxs[0], paths[1]}, r[1], "Withdraw 2")
assert.Equal(t, &routingtable.RemovePathParams{pfxs[1], paths[2]}, r[2], "Withdraw 3")
assert.Equal(t, &routingtable.RemovePathParams{Pfx: pfxs[0], Path: paths[0]}, r[0], "Withdraw 1")
assert.Equal(t, &routingtable.RemovePathParams{Pfx: pfxs[0], Path: paths[1]}, r[1], "Withdraw 2")
assert.Equal(t, &routingtable.RemovePathParams{Pfx: pfxs[1], Path: paths[2]}, r[2], "Withdraw 3")
}
9 changes: 0 additions & 9 deletions syscallwrappers/syscalls_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,10 @@ int isis_multicast_join(int fd, int registerto, int ifindex)
*/
import "C"

import (
"unsafe"
)

func SetBPFFilter(sockfd int) int {
return int(C.reg_bpf(C.int(sockfd)))
}

func SetSockOpt(sockfd int, level int, optName int, optVal uintptr, optLen int) int {
ptr := unsafe.Pointer(optVal)
return int(C.setsockopt(C.int(sockfd), C.int(level), C.int(optName), ptr, C.uint(optLen)))
}

func JoinISISMcast(sockfd int, ifIndex int) int {
return int(C.isis_multicast_join(C.int(sockfd), 4, C.int(ifIndex)))
}
Expand Down

0 comments on commit 8f75257

Please sign in to comment.