Fix go vet errors

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov 2015-02-12 11:00:59 -08:00
parent d710fe886a
commit e29807a4d5
5 changed files with 34 additions and 35 deletions

View File

@ -62,10 +62,10 @@ func testLinkAddDel(t *testing.T, link Link) {
var peer *Veth
other, err := LinkByName(veth.PeerName)
if err != nil {
t.Fatal("Peer %s not created", veth.PeerName)
t.Fatalf("Peer %s not created", veth.PeerName)
}
if peer, ok = other.(*Veth); !ok {
t.Fatal("Peer %s is incorrect type", veth.PeerName)
t.Fatalf("Peer %s is incorrect type", veth.PeerName)
}
if peer.TxQLen != testTxQLen {
t.Fatalf("TxQLen of peer is %d, should be %d", peer.TxQLen, testTxQLen)
@ -108,54 +108,54 @@ func testLinkAddDel(t *testing.T, link Link) {
func compareVxlan(t *testing.T, expected, actual *Vxlan) {
if actual.VxlanId != expected.VxlanId {
t.Fatalf("Vxlan.VxlanId doesn't match")
t.Fatal("Vxlan.VxlanId doesn't match")
}
if expected.SrcAddr != nil && !actual.SrcAddr.Equal(expected.SrcAddr) {
t.Fatalf("Vxlan.SrcAddr doesn't match")
t.Fatal("Vxlan.SrcAddr doesn't match")
}
if expected.Group != nil && !actual.Group.Equal(expected.Group) {
t.Fatalf("Vxlan.Group doesn't match")
t.Fatal("Vxlan.Group doesn't match")
}
if expected.TTL != -1 && actual.TTL != expected.TTL {
t.Fatalf("Vxlan.TTL doesn't match")
t.Fatal("Vxlan.TTL doesn't match")
}
if expected.TOS != -1 && actual.TOS != expected.TOS {
t.Fatalf("Vxlan.TOS doesn't match")
t.Fatal("Vxlan.TOS doesn't match")
}
if actual.Learning != expected.Learning {
t.Fatalf("Vxlan.Learning doesn't match")
t.Fatal("Vxlan.Learning doesn't match")
}
if actual.Proxy != expected.Proxy {
t.Fatalf("Vxlan.Proxy doesn't match")
t.Fatal("Vxlan.Proxy doesn't match")
}
if actual.RSC != expected.RSC {
t.Fatalf("Vxlan.RSC doesn't match", actual, expected)
t.Fatal("Vxlan.RSC doesn't match")
}
if actual.L2miss != expected.L2miss {
t.Fatalf("Vxlan.L2miss doesn't match")
t.Fatal("Vxlan.L2miss doesn't match")
}
if actual.L3miss != expected.L3miss {
t.Fatalf("Vxlan.L3miss doesn't match")
t.Fatal("Vxlan.L3miss doesn't match")
}
if expected.NoAge {
if !actual.NoAge {
t.Fatalf("Vxlan.NoAge doesn't match")
t.Fatal("Vxlan.NoAge doesn't match")
}
} else if expected.Age > 0 && actual.Age != expected.Age {
t.Fatalf("Vxlan.Age doesn't match")
t.Fatal("Vxlan.Age doesn't match")
}
if expected.Limit > 0 && actual.Limit != expected.Limit {
t.Fatalf("Vxlan.Limit doesn't match")
t.Fatal("Vxlan.Limit doesn't match")
}
if expected.Port > 0 && actual.Port != expected.Port {
t.Fatalf("Vxlan.Port doesn't match")
t.Fatal("Vxlan.Port doesn't match")
}
if expected.PortLow > 0 || expected.PortHigh > 0 {
if actual.PortLow != expected.PortLow {
t.Fatalf("Vxlan.PortLow doesn't match")
t.Fatal("Vxlan.PortLow doesn't match")
}
if actual.PortHigh != expected.PortHigh {
t.Fatalf("Vxlan.PortHigh doesn't match")
t.Fatal("Vxlan.PortHigh doesn't match")
}
}
}

View File

@ -72,8 +72,6 @@ func TestNeighAddDel(t *testing.T) {
}
}
return
// Delete the arpTable
for _, entry := range arpTable {
err := NeighDel(&Neigh{
@ -87,17 +85,18 @@ func TestNeighAddDel(t *testing.T) {
}
}
// Dump and see that none of deleted entries are there
dump, err = NeighList(dummy.Index, 0)
if err != nil {
t.Errorf("Failed to NeighList: %v", err)
}
// TODO: seems not working because of cache
//// Dump and see that none of deleted entries are there
//dump, err = NeighList(dummy.Index, 0)
//if err != nil {
//t.Errorf("Failed to NeighList: %v", err)
//}
for _, entry := range arpTable {
if dumpContains(dump, entry) {
t.Errorf("Dump contains: %v", entry)
}
}
//for _, entry := range arpTable {
//if dumpContains(dump, entry) {
//t.Errorf("Dump contains: %v", entry)
//}
//}
if err := LinkDel(&dummy); err != nil {
t.Fatal(err)

View File

@ -30,10 +30,10 @@ func ParseIPNet(s string) (*net.IPNet, error) {
if err != nil {
return nil, err
}
return &net.IPNet{ip, ipNet.Mask}, nil
return &net.IPNet{IP: ip, Mask: ipNet.Mask}, nil
}
// NewIPNet generates an IPNet from an ip address using a netmask of 32.
func NewIPNet(ip net.IP) *net.IPNet {
return &net.IPNet{ip, net.CIDRMask(32, 32)}
return &net.IPNet{IP: ip, Mask: net.CIDRMask(32, 32)}
}

View File

@ -103,9 +103,9 @@ func (x *XfrmAddress) ToIP() net.IP {
func (x *XfrmAddress) ToIPNet(prefixlen uint8) *net.IPNet {
ip := x.ToIP()
if GetIPFamily(ip) == FAMILY_V4 {
return &net.IPNet{ip, net.CIDRMask(int(prefixlen), 32)}
return &net.IPNet{IP: ip, Mask: net.CIDRMask(int(prefixlen), 32)}
} else {
return &net.IPNet{ip, net.CIDRMask(int(prefixlen), 128)}
return &net.IPNet{IP: ip, Mask: net.CIDRMask(int(prefixlen), 128)}
}
}

View File

@ -71,6 +71,6 @@ func TestProtinfo(t *testing.T) {
}
if err := LinkSetProtinfo(iface3, pi3); err == nil || err.Error() != "operation not supported" {
t.Fatal("Set protinfo for link without master is not supported, but err: %s", err)
t.Fatalf("Set protinfo for link without master is not supported, but err: %s", err)
}
}