device: fix shadowing of err in IpcHandle

The declaration of err in

	nextByte, err := buffered.ReadByte

shadows the declaration of err in

	op, err := buffered.ReadString('\n')

above. As a result, the assignments to err in

	err = ipcErrorf(ipc.IpcErrorInvalid, "trailing character in UAPI get: %c", nextByte)

and in

	err = device.IpcGetOperation(buffered.Writer)

do not modify the correct err variable.

Found by staticcheck.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder 2021-01-26 10:35:25 -08:00 committed by Jason A. Donenfeld
parent d3a2b74df2
commit 37efdcaccf

View file

@ -403,7 +403,8 @@ func (device *Device) IpcHandle(socket net.Conn) {
case "set=1\n": case "set=1\n":
err = device.IpcSetOperation(buffered.Reader) err = device.IpcSetOperation(buffered.Reader)
case "get=1\n": case "get=1\n":
nextByte, err := buffered.ReadByte() var nextByte byte
nextByte, err = buffered.ReadByte()
if err != nil { if err != nil {
return return
} }