Skip to content

Commit

Permalink
pkg/proc: simplify code with trivial changes (#3436)
Browse files Browse the repository at this point in the history
  • Loading branch information
callthingsoff authored Jul 9, 2023
1 parent 326c451 commit cbc45e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/proc/core/delve_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ func threadsFromDelveNotes(p *process, notes []*note) (proc.Thread, error) {
readerr = fmt.Errorf("maximum len exceeded (%d) reading %s", len, kind)
return nil
}
buf := make([]byte, len)
if readerr != nil {
return nil
}
buf := make([]byte, len)
_, readerr = body.Read(buf)
return buf
}
Expand Down
10 changes: 6 additions & 4 deletions pkg/proc/gdbserial/gdbserver_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ func (conn *gdbConn) exec(cmd []byte, context string) ([]byte, error) {
return conn.recv(cmd, context, false)
}

var hexdigit = []byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}
const hexdigit = "0123456789abcdef"

func (conn *gdbConn) send(cmd []byte) error {
if len(cmd) == 0 || cmd[0] != '$' {
Expand Down Expand Up @@ -1344,9 +1344,11 @@ func (conn *gdbConn) recv(cmd []byte, context string, binary bool) (resp []byte,
if logflags.GdbWire() {
out := resp
partial := false
if idx := bytes.Index(out, []byte{'\n'}); idx >= 0 && !binary {
out = resp[:idx]
partial = true
if !binary {
if idx := bytes.Index(out, []byte{'\n'}); idx >= 0 {
out = resp[:idx]
partial = true
}
}
if len(out) > gdbWireMaxLen {
out = out[:gdbWireMaxLen]
Expand Down

0 comments on commit cbc45e1

Please sign in to comment.