fix: staticcheck and deadcode findings repo-wide, modernize counting loops

This commit is contained in:
2026-08-29 15:25:15 +02:00
parent 9a34733615
commit eacf33d0f7
33 changed files with 88 additions and 250 deletions
-5
View File
@@ -114,11 +114,6 @@ func (bm *Breakpoints) SetWithCond(addr uint64, label string, cond *Condition) (
return bp, nil
}
// Hits returns the number of times the breakpoint has been hit.
func (bp *Breakpoint) Hits() int {
return bp.hits
}
// Info returns a formatted list of all breakpoints.
func (bm *Breakpoints) Info() string {
if len(bm.bps) == 0 {
+1 -1
View File
@@ -36,7 +36,7 @@ func (s *Session) Disassemble(addr uint64) (string, int, error) {
func (s *Session) DisassembleN(addr uint64, n int) string {
var result string
pc := addr
for i := 0; i < n; i++ {
for range n {
text, length, err := s.Disassemble(pc)
if err != nil {
result += fmt.Sprintf(" %#08x: <error: %v>\n", pc, err)
+1 -1
View File
@@ -30,7 +30,7 @@ func (s *Session) Disassemble(addr uint64) (string, int, error) {
func (s *Session) DisassembleN(addr uint64, n int) string {
var result string
pc := addr
for i := 0; i < n; i++ {
for i := range n {
text, length, err := s.Disassemble(pc)
if err != nil {
result += fmt.Sprintf(" %#08x: <error: %v>\n", pc, err)
+1 -1
View File
@@ -30,7 +30,7 @@ func (s *Session) Disassemble(addr uint64) (string, int, error) {
func (s *Session) DisassembleN(addr uint64, n int) string {
var result string
pc := addr
for i := 0; i < n; i++ {
for i := range n {
text, length, err := s.Disassemble(pc)
if err != nil {
result += fmt.Sprintf(" %#08x: <error: %v>\n", pc, err)
+1 -1
View File
@@ -30,7 +30,7 @@ func (s *Session) Disassemble(addr uint64) (string, int, error) {
func (s *Session) DisassembleN(addr uint64, n int) string {
var result string
pc := addr
for i := 0; i < n; i++ {
for i := range n {
text, length, err := s.Disassemble(pc)
if err != nil {
result += fmt.Sprintf(" %#08x: <error: %v>\n", pc, err)
+1 -1
View File
@@ -72,7 +72,7 @@ func REPL(s *Session, bm *Breakpoints, codeBase uint64, funcOffset, funcSize, ar
if len(parts) > 1 {
n, _ = strconv.Atoi(parts[1])
}
for i := 0; i < n; i++ {
for range n {
if s.Exited() {
fmt.Println("debuggee exited")
break
+3 -3
View File
@@ -98,10 +98,10 @@ func RunTarget(asmPath, funcName, argsFile, tmpDir string) error {
stackArgs := make([]byte, fl.Args)
copy(stackArgs, args)
_, callErr := verify.Call(fnAddr, stackArgs)
if callErr != nil {
if _, callErr := verify.Call(fnAddr, stackArgs); callErr != nil {
os.Exit(1)
}
os.Exit(0)
// Success returns to the caller, which exits with status 0; the JIT
// code has already run to its own trampoline by the time Call returns.
return nil
}
+1 -1
View File
@@ -44,7 +44,7 @@ const (
)
func (s *Session) FindFreeWatchpointSlot() int {
for i := 0; i < maxWatchpoints; i++ {
for i := range maxWatchpoints {
if !wpSlots[i] {
return i
}
+1 -1
View File
@@ -27,7 +27,7 @@ var wpSlots [4]bool
const maxWatchpoints = 4
func (s *Session) FindFreeWatchpointSlot() int {
for i := 0; i < maxWatchpoints; i++ {
for i := range maxWatchpoints {
if !wpSlots[i] {
return i
}
+1 -1
View File
@@ -27,7 +27,7 @@ var wpSlots [4]bool
const maxWatchpoints = 4
func (s *Session) FindFreeWatchpointSlot() int {
for i := 0; i < maxWatchpoints; i++ {
for i := range maxWatchpoints {
if !wpSlots[i] {
return i
}