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)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Receive: %v", err)
|
||||
return nil, fmt.Errorf("receiveAckAware: %v", err)
|
||||
}
|
||||
|
||||
return reply, nil
|
||||
|
|
|
@ -62,29 +62,27 @@ func TestMonitor(t *testing.T) {
|
|||
defer wg.Done()
|
||||
count := int32(0)
|
||||
for {
|
||||
select {
|
||||
case event, ok := <-events:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if event.Error != nil {
|
||||
err = fmt.Errorf("monitor err: %s", event.Error)
|
||||
return
|
||||
}
|
||||
switch event.Type {
|
||||
case nftables.MonitorEventTypeNewTable:
|
||||
gotTable = event.Data.(*nftables.Table)
|
||||
atomic.AddInt32(&count, 1)
|
||||
case nftables.MonitorEventTypeNewChain:
|
||||
gotChain = event.Data.(*nftables.Chain)
|
||||
atomic.AddInt32(&count, 1)
|
||||
case nftables.MonitorEventTypeNewRule:
|
||||
gotRule = event.Data.(*nftables.Rule)
|
||||
atomic.AddInt32(&count, 1)
|
||||
}
|
||||
if atomic.LoadInt32(&count) == 3 {
|
||||
return
|
||||
}
|
||||
event, ok := <-events
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if event.Error != nil {
|
||||
err = fmt.Errorf("monitor err: %s", event.Error)
|
||||
return
|
||||
}
|
||||
switch event.Type {
|
||||
case nftables.MonitorEventTypeNewTable:
|
||||
gotTable = event.Data.(*nftables.Table)
|
||||
atomic.AddInt32(&count, 1)
|
||||
case nftables.MonitorEventTypeNewChain:
|
||||
gotChain = event.Data.(*nftables.Chain)
|
||||
atomic.AddInt32(&count, 1)
|
||||
case nftables.MonitorEventTypeNewRule:
|
||||
gotRule = event.Data.(*nftables.Rule)
|
||||
atomic.AddInt32(&count, 1)
|
||||
}
|
||||
if atomic.LoadInt32(&count) == 3 {
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Receive: %v", err)
|
||||
return nil, fmt.Errorf("receiveAckAware: %v", err)
|
||||
}
|
||||
var objs []Obj
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Receive: %v", err)
|
||||
return nil, fmt.Errorf("receiveAckAware: %v", err)
|
||||
}
|
||||
var rules []*Rule
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Receive: %v", err)
|
||||
return nil, fmt.Errorf("receiveAckAware: %v", err)
|
||||
}
|
||||
var sets []*Set
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Receive: %w", err)
|
||||
return nil, fmt.Errorf("receiveAckAware: %w", err)
|
||||
}
|
||||
|
||||
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])
|
||||
if err != nil {
|
||||
|
@ -922,7 +922,7 @@ func (cc *Conn) GetSetElements(s *Set) ([]SetElement, error) {
|
|||
|
||||
reply, err := receiveAckAware(conn, message.Header.Flags)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Receive: %v", err)
|
||||
return nil, fmt.Errorf("receiveAckAware: %v", err)
|
||||
}
|
||||
var elems []SetElement
|
||||
for _, msg := range reply {
|
||||
|
|
Loading…
Reference in New Issue