Skip to content

Commit

Permalink
switch: Remove unused local variable
Browse files Browse the repository at this point in the history
`make lint` complains about an unused variable. Since 'n' is only useful
when `err` is not `nil`, it should be harmless to remove it.

https://pkg.go.dev/io#ReadFull
> On return, n == len(buf) if and only if err == nil

This fixes this error:

pkg/tap/switch.go:196:3: ineffectual assignment to n (ineffassign)
		n, err := io.ReadFull(conn, sizeBuf)
		^
  • Loading branch information
cfergeau committed Aug 16, 2021
1 parent 57b68ed commit 1c01c6a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/tap/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ loop:
default:
// passthrough
}
n, err := io.ReadFull(conn, sizeBuf)
_, err := io.ReadFull(conn, sizeBuf)
if err != nil {
return errors.Wrap(err, "cannot read size from socket")
}
size := int(e.protocol.Read(sizeBuf))

buf := make([]byte, size)
n, err = io.ReadFull(conn, buf)
n, err := io.ReadFull(conn, buf)
if err != nil {
return errors.Wrap(err, "cannot read packet from socket")
}
Expand Down

0 comments on commit 1c01c6a

Please sign in to comment.