@@ -7,6 +7,7 @@ package device
7
7
8
8
import (
9
9
"bufio"
10
+ "errors"
10
11
"fmt"
11
12
"io"
12
13
"net"
@@ -31,7 +32,7 @@ func (s IPCError) ErrorCode() int64 {
31
32
return s .int64
32
33
}
33
34
34
- func (device * Device ) IpcGetOperation (socket * bufio.Writer ) * IPCError {
35
+ func (device * Device ) IpcGetOperation (socket * bufio.Writer ) error {
35
36
lines := make ([]string , 0 , 100 )
36
37
send := func (line string ) {
37
38
lines = append (lines , line )
@@ -106,7 +107,7 @@ func (device *Device) IpcGetOperation(socket *bufio.Writer) *IPCError {
106
107
return nil
107
108
}
108
109
109
- func (device * Device ) IpcSetOperation (socket * bufio.Reader ) * IPCError {
110
+ func (device * Device ) IpcSetOperation (socket * bufio.Reader ) error {
110
111
scanner := bufio .NewScanner (socket )
111
112
logError := device .log .Error
112
113
logDebug := device .log .Debug
@@ -421,10 +422,20 @@ func (device *Device) IpcHandle(socket net.Conn) {
421
422
422
423
switch op {
423
424
case "set=1\n " :
424
- status = device .IpcSetOperation (buffered .Reader )
425
+ err = device .IpcSetOperation (buffered .Reader )
426
+ if ! errors .As (err , & status ) {
427
+ // should never happen
428
+ device .log .Error .Println ("Invalid UAPI error:" , err )
429
+ status = & IPCError {1 }
430
+ }
425
431
426
432
case "get=1\n " :
427
- status = device .IpcGetOperation (buffered .Writer )
433
+ err = device .IpcGetOperation (buffered .Writer )
434
+ if ! errors .As (err , & status ) {
435
+ // should never happen
436
+ device .log .Error .Println ("Invalid UAPI error:" , err )
437
+ status = & IPCError {1 }
438
+ }
428
439
429
440
default :
430
441
device .log .Error .Println ("Invalid UAPI operation:" , op )
0 commit comments