mirror of
https://github.com/go-delve/delve.git
synced 2025-10-28 04:35:19 +08:00
all: use "len == 0" rather than "len <= 0" when checking empty slice/string (#3439)
This commit is contained in:
@ -101,7 +101,7 @@ func (b *Builder) TagOpen(tag dwarf.Tag, name string) dwarf.Offset {
|
||||
|
||||
// SetHasChildren sets the current DIE as having children (even if none are added).
|
||||
func (b *Builder) SetHasChildren() {
|
||||
if len(b.tagStack) <= 0 {
|
||||
if len(b.tagStack) == 0 {
|
||||
panic("NoChildren with no open tags")
|
||||
}
|
||||
b.tagStack[len(b.tagStack)-1].children = true
|
||||
@ -109,7 +109,7 @@ func (b *Builder) SetHasChildren() {
|
||||
|
||||
// TagClose closes the current DIE.
|
||||
func (b *Builder) TagClose() {
|
||||
if len(b.tagStack) <= 0 {
|
||||
if len(b.tagStack) == 0 {
|
||||
panic("TagClose with no open tags")
|
||||
}
|
||||
tag := b.tagStack[len(b.tagStack)-1]
|
||||
|
||||
@ -348,7 +348,7 @@ func constu(opcode Opcode, ctxt *context) error {
|
||||
}
|
||||
|
||||
func dup(_ Opcode, ctxt *context) error {
|
||||
if len(ctxt.stack) <= 0 {
|
||||
if len(ctxt.stack) == 0 {
|
||||
return ErrStackUnderflow
|
||||
}
|
||||
ctxt.stack = append(ctxt.stack, ctxt.stack[len(ctxt.stack)-1])
|
||||
@ -356,7 +356,7 @@ func dup(_ Opcode, ctxt *context) error {
|
||||
}
|
||||
|
||||
func drop(_ Opcode, ctxt *context) error {
|
||||
if len(ctxt.stack) <= 0 {
|
||||
if len(ctxt.stack) == 0 {
|
||||
return ErrStackUnderflow
|
||||
}
|
||||
ctxt.stack = ctxt.stack[:len(ctxt.stack)-1]
|
||||
@ -541,7 +541,7 @@ func deref(op Opcode, ctxt *context) error {
|
||||
sz = int(n)
|
||||
}
|
||||
|
||||
if len(ctxt.stack) <= 0 {
|
||||
if len(ctxt.stack) == 0 {
|
||||
return ErrStackUnderflow
|
||||
}
|
||||
|
||||
@ -549,7 +549,7 @@ func deref(op Opcode, ctxt *context) error {
|
||||
ctxt.stack = ctxt.stack[:len(ctxt.stack)-1]
|
||||
|
||||
if op == DW_OP_xderef || op == DW_OP_xderef_size {
|
||||
if len(ctxt.stack) <= 0 {
|
||||
if len(ctxt.stack) == 0 {
|
||||
return ErrStackUnderflow
|
||||
}
|
||||
// the second element on the stack is the "address space identifier" which we don't do anything with
|
||||
|
||||
@ -72,7 +72,7 @@ func Parse(locStr string) (LocationSpec, error) {
|
||||
return fmt.Errorf("Malformed breakpoint location %q at %d: %s", locStr, len(locStr)-len(rest), reason)
|
||||
}
|
||||
|
||||
if len(rest) <= 0 {
|
||||
if len(rest) == 0 {
|
||||
return nil, malformed("empty string")
|
||||
}
|
||||
|
||||
@ -578,7 +578,7 @@ func SubstitutePath(path string, rules [][2]string) string {
|
||||
}
|
||||
|
||||
func addressesToLocation(addrs []uint64) api.Location {
|
||||
if len(addrs) <= 0 {
|
||||
if len(addrs) == 0 {
|
||||
return api.Location{}
|
||||
}
|
||||
return api.Location{PC: addrs[0], PCs: addrs}
|
||||
|
||||
@ -2539,7 +2539,7 @@ func (bi *BinaryInfo) loadDebugInfoMapsInlinedCalls(ctxt *loadDebugInfoMapsConte
|
||||
}
|
||||
|
||||
func uniq(s []string) []string {
|
||||
if len(s) <= 0 {
|
||||
if len(s) == 0 {
|
||||
return s
|
||||
}
|
||||
src, dst := 1, 1
|
||||
|
||||
@ -83,7 +83,7 @@ func firstPCAfterPrologueDisassembly(p Process, fn *Function, sameline bool) (ui
|
||||
return fn.Entry, err
|
||||
}
|
||||
|
||||
if len(text) <= 0 {
|
||||
if len(text) == 0 {
|
||||
return fn.Entry, nil
|
||||
}
|
||||
|
||||
|
||||
@ -292,7 +292,7 @@ func (scope *EvalScope) Locals(flags localsFlags) ([]*Variable, error) {
|
||||
depths = append(depths, depth)
|
||||
}
|
||||
|
||||
if len(vars) <= 0 {
|
||||
if len(vars) == 0 {
|
||||
return vars, nil
|
||||
}
|
||||
|
||||
|
||||
@ -1127,7 +1127,7 @@ func isCallInjectionStop(t *Target, thread Thread, loc *Location) bool {
|
||||
off = -int64(len(thread.BinInfo().Arch.breakpointInstruction))
|
||||
}
|
||||
text, err := disassembleCurrentInstruction(t, thread, off)
|
||||
if err != nil || len(text) <= 0 {
|
||||
if err != nil || len(text) == 0 {
|
||||
return false
|
||||
}
|
||||
return text[0].IsHardBreak()
|
||||
|
||||
@ -200,7 +200,7 @@ func (conn *gdbConn) qSupported(multiprocess bool) (features map[string]bool, er
|
||||
resp := strings.Split(string(respBuf), ";")
|
||||
features = make(map[string]bool)
|
||||
for _, stubfeature := range resp {
|
||||
if len(stubfeature) <= 0 {
|
||||
if len(stubfeature) == 0 {
|
||||
continue
|
||||
} else if equal := strings.Index(stubfeature, "="); equal >= 0 {
|
||||
if stubfeature[:equal] == "PacketSize" {
|
||||
|
||||
@ -899,7 +899,7 @@ func removePCsBetween(pcs []uint64, start, end uint64) []uint64 {
|
||||
}
|
||||
|
||||
func setStepIntoBreakpoint(dbp *Target, curfn *Function, text []AsmInstruction, cond ast.Expr) error {
|
||||
if len(text) <= 0 {
|
||||
if len(text) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -1414,7 +1414,7 @@ func (d *Debugger) Sources(filter string) ([]string, error) {
|
||||
}
|
||||
|
||||
func uniq(s []string) []string {
|
||||
if len(s) <= 0 {
|
||||
if len(s) == 0 {
|
||||
return s
|
||||
}
|
||||
src, dst := 1, 1
|
||||
|
||||
@ -484,7 +484,7 @@ func Test1ClientServer_traceContinue(t *testing.T) {
|
||||
t.Fatalf("No goroutine information")
|
||||
}
|
||||
|
||||
if len(bpi.Stacktrace) <= 0 {
|
||||
if len(bpi.Stacktrace) == 0 {
|
||||
t.Fatalf("No stacktrace\n")
|
||||
}
|
||||
|
||||
|
||||
@ -865,7 +865,7 @@ func TestClientServer_traceContinue(t *testing.T) {
|
||||
t.Fatalf("No goroutine information")
|
||||
}
|
||||
|
||||
if len(bpi.Stacktrace) <= 0 {
|
||||
if len(bpi.Stacktrace) == 0 {
|
||||
t.Fatalf("No stacktrace\n")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user