Fix staticcheck issues (#266)
This commit is contained in:
parent
b76fdc8f90
commit
4d451ef75f
|
@ -219,7 +219,7 @@ func (cc *Conn) getFlowtables(t *Table) ([]netlink.Message, error) {
|
||||||
|
|
||||||
reply, err := receiveAckAware(conn, message.Header.Flags)
|
reply, err := receiveAckAware(conn, message.Header.Flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Receive: %v", err)
|
return nil, fmt.Errorf("receiveAckAware: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return reply, nil
|
return reply, nil
|
||||||
|
|
|
@ -62,29 +62,27 @@ func TestMonitor(t *testing.T) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
count := int32(0)
|
count := int32(0)
|
||||||
for {
|
for {
|
||||||
select {
|
event, ok := <-events
|
||||||
case event, ok := <-events:
|
if !ok {
|
||||||
if !ok {
|
return
|
||||||
return
|
}
|
||||||
}
|
if event.Error != nil {
|
||||||
if event.Error != nil {
|
err = fmt.Errorf("monitor err: %s", event.Error)
|
||||||
err = fmt.Errorf("monitor err: %s", event.Error)
|
return
|
||||||
return
|
}
|
||||||
}
|
switch event.Type {
|
||||||
switch event.Type {
|
case nftables.MonitorEventTypeNewTable:
|
||||||
case nftables.MonitorEventTypeNewTable:
|
gotTable = event.Data.(*nftables.Table)
|
||||||
gotTable = event.Data.(*nftables.Table)
|
atomic.AddInt32(&count, 1)
|
||||||
atomic.AddInt32(&count, 1)
|
case nftables.MonitorEventTypeNewChain:
|
||||||
case nftables.MonitorEventTypeNewChain:
|
gotChain = event.Data.(*nftables.Chain)
|
||||||
gotChain = event.Data.(*nftables.Chain)
|
atomic.AddInt32(&count, 1)
|
||||||
atomic.AddInt32(&count, 1)
|
case nftables.MonitorEventTypeNewRule:
|
||||||
case nftables.MonitorEventTypeNewRule:
|
gotRule = event.Data.(*nftables.Rule)
|
||||||
gotRule = event.Data.(*nftables.Rule)
|
atomic.AddInt32(&count, 1)
|
||||||
atomic.AddInt32(&count, 1)
|
}
|
||||||
}
|
if atomic.LoadInt32(&count) == 3 {
|
||||||
if atomic.LoadInt32(&count) == 3 {
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
2
obj.go
2
obj.go
|
@ -354,7 +354,7 @@ func (cc *Conn) getObjWithLegacyType(o Obj, t *Table, msgType uint16, returnLega
|
||||||
|
|
||||||
reply, err := receiveAckAware(conn, message.Header.Flags)
|
reply, err := receiveAckAware(conn, message.Header.Flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Receive: %v", err)
|
return nil, fmt.Errorf("receiveAckAware: %v", err)
|
||||||
}
|
}
|
||||||
var objs []Obj
|
var objs []Obj
|
||||||
for _, msg := range reply {
|
for _, msg := range reply {
|
||||||
|
|
2
rule.go
2
rule.go
|
@ -92,7 +92,7 @@ func (cc *Conn) GetRules(t *Table, c *Chain) ([]*Rule, error) {
|
||||||
|
|
||||||
reply, err := receiveAckAware(conn, message.Header.Flags)
|
reply, err := receiveAckAware(conn, message.Header.Flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Receive: %v", err)
|
return nil, fmt.Errorf("receiveAckAware: %v", err)
|
||||||
}
|
}
|
||||||
var rules []*Rule
|
var rules []*Rule
|
||||||
for _, msg := range reply {
|
for _, msg := range reply {
|
||||||
|
|
8
set.go
8
set.go
|
@ -832,7 +832,7 @@ func (cc *Conn) GetSets(t *Table) ([]*Set, error) {
|
||||||
|
|
||||||
reply, err := receiveAckAware(conn, message.Header.Flags)
|
reply, err := receiveAckAware(conn, message.Header.Flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Receive: %v", err)
|
return nil, fmt.Errorf("receiveAckAware: %v", err)
|
||||||
}
|
}
|
||||||
var sets []*Set
|
var sets []*Set
|
||||||
for _, msg := range reply {
|
for _, msg := range reply {
|
||||||
|
@ -877,11 +877,11 @@ func (cc *Conn) GetSetByName(t *Table, name string) (*Set, error) {
|
||||||
|
|
||||||
reply, err := receiveAckAware(conn, message.Header.Flags)
|
reply, err := receiveAckAware(conn, message.Header.Flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Receive: %w", err)
|
return nil, fmt.Errorf("receiveAckAware: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(reply) != 1 {
|
if len(reply) != 1 {
|
||||||
return nil, fmt.Errorf("Receive: expected to receive 1 message but got %d", len(reply))
|
return nil, fmt.Errorf("receiveAckAware: expected to receive 1 message but got %d", len(reply))
|
||||||
}
|
}
|
||||||
rs, err := setsFromMsg(reply[0])
|
rs, err := setsFromMsg(reply[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -922,7 +922,7 @@ func (cc *Conn) GetSetElements(s *Set) ([]SetElement, error) {
|
||||||
|
|
||||||
reply, err := receiveAckAware(conn, message.Header.Flags)
|
reply, err := receiveAckAware(conn, message.Header.Flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Receive: %v", err)
|
return nil, fmt.Errorf("receiveAckAware: %v", err)
|
||||||
}
|
}
|
||||||
var elems []SetElement
|
var elems []SetElement
|
||||||
for _, msg := range reply {
|
for _, msg := range reply {
|
||||||
|
|
Loading…
Reference in New Issue