Skip to content

Commit 5e8c201

Browse files
committed
err check fix
1 parent 447c64a commit 5e8c201

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

packets.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ func (mc *mysqlConn) readPacket() (data []byte, err error) {
3434
}
3535

3636
// Packet Length
37-
var pktLen uint32
38-
pktLen |= uint32(data[0])
39-
pktLen |= uint32(data[1]) << 8
40-
pktLen |= uint32(data[2]) << 16
37+
pktLen := uint32(data[0]) | uint32(data[1])<<8 | uint32(data[2])<<16
4138

4239
if pktLen == 0 {
4340
errLog.Print(errMalformPkt.Error())
@@ -69,7 +66,7 @@ func (mc *mysqlConn) readPacket() (data []byte, err error) {
6966
func (mc *mysqlConn) writePacket(data []byte) error {
7067
// Write packet
7168
n, err := mc.netConn.Write(data)
72-
if err == nil || n == len(data) {
69+
if err == nil && n == len(data) {
7370
mc.sequence++
7471
return nil
7572
}

0 commit comments

Comments
 (0)