[google/syzkaller] 645284: tools/syz-linter: add custom linter rule for range...

0 views
Skip to first unread message

Alexander Potapenko

unread,
Apr 21, 2026, 5:32:46 AM (3 days ago) Apr 21
to syzk...@googlegroups.com
Branch: refs/heads/gh-readonly-queue/master/pr-7086-9a9f31c13b6106946815aba9c4eb47e4bf7b2a24
Home: https://github.com/google/syzkaller
Commit: 645284786b77300429d9d93c22cbbec375ac93c1
https://github.com/google/syzkaller/commit/645284786b77300429d9d93c22cbbec375ac93c1
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M tools/syz-linter/linter.go
M tools/syz-linter/testdata/src/lintertest/lintertest.go

Log Message:
-----------
tools/syz-linter: add custom linter rule for range over integers

Add a custom linter rule to detect traditional for loops that can be replaced with range over integers.


Commit: cf656f574d92c135c70de153aac70e90483fa2f8
https://github.com/google/syzkaller/commit/cf656f574d92c135c70de153aac70e90483fa2f8
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M dashboard/app/access_test.go
M dashboard/app/ai_test.go
M dashboard/app/app_test.go
M dashboard/app/bisect_test.go
M dashboard/app/cache.go
M dashboard/app/commit_poll_test.go
M dashboard/app/discussion_test.go
M dashboard/app/dungeon_test.go
M dashboard/app/email_test.go
M dashboard/app/entities_datastore.go
M dashboard/app/graphs_test.go
M dashboard/app/jobs_test.go
M dashboard/app/local_ui_test.go
M dashboard/app/main_test.go
M dashboard/app/reporting_test.go
M dashboard/app/repro_test.go
M dashboard/app/subsystem_test.go
M dashboard/app/tree.go
M pkg/aflow/llm_agent.go
M pkg/aflow/llm_agent_test.go
M pkg/aflow/loop.go
M pkg/ast/scanner.go
M pkg/auth/auth.go
M pkg/bisect/bisect.go
M pkg/bisect/bisect_test.go
M pkg/bisect/minimize/slice.go
M pkg/bisect/minimize/slice_test.go
M pkg/build/linux_linux.go
M pkg/clangtool/clangtool.go
M pkg/compiler/attrs.go
M pkg/corpus/corpus_test.go
M pkg/corpus/prio_test.go
M pkg/cover/backend/dwarf.go
M pkg/cover/report_test.go
M pkg/coveragedb/time_period.go
M pkg/covermerger/covermerger.go
M pkg/csource/csource.go
M pkg/csource/options_test.go
M pkg/db/db_test.go
M pkg/declextract/fileops.go
M pkg/flatrpc/conn.go
M pkg/flatrpc/conn_test.go
M pkg/flatrpc/helpers.go
M pkg/fuzzer/fuzzer_test.go
M pkg/fuzzer/job.go
M pkg/fuzzer/queue/retry_test.go
M pkg/ifuzz/ifuzz.go
M pkg/ifuzz/ifuzz_test.go
M pkg/ifuzz/powerpc/pseudo.go
M pkg/ifuzz/x86/x86.go
M pkg/image/compression_test.go
M pkg/instance/dump.go
M pkg/instance/instance.go
M pkg/kconfig/parser.go
M pkg/manager/crash.go
M pkg/manager/crash_test.go
M pkg/manager/diff/manager.go
M pkg/manager/diff/patch_test.go
M pkg/manager/repro_test.go
M pkg/manager/seeds.go
M pkg/osutil/fileutil_test.go
M pkg/osutil/semaphore.go
M pkg/report/gvisor.go
M pkg/repro/repro.go
M pkg/repro/repro_test.go
M pkg/runtest/executor_test.go
M pkg/serializer/serializer.go
M pkg/stat/set.go
M pkg/stat/set_test.go
M pkg/subsystem/linux/coincidence.go
M pkg/subsystem/linux/names.go
M pkg/subsystem/linux/parents_test.go
M pkg/subsystem/linux/path_coincidence.go
M pkg/symbolizer/addr2line.go
M pkg/testutil/testutil.go
M pkg/vcs/git_repo_test.go
M pkg/vminfo/linux_syscalls.go
M pkg/vminfo/syscalls.go
M prog/alloc_test.go
M prog/any_test.go
M prog/checksum_test.go
M prog/collide_test.go
M prog/encoding.go
M prog/encoding_test.go
M prog/encodingexec_test.go
M prog/expr_test.go
M prog/heatmap_test.go
M prog/hints.go
M prog/hints_test.go
M prog/minimization.go
M prog/minimization_test.go
M prog/mutation.go
M prog/mutation_test.go
M prog/prio_test.go
M prog/prog.go
M prog/prog_test.go
M prog/rand_test.go
M prog/resources_test.go
M prog/rotation_test.go
M prog/size_test.go
M prog/types.go
M sys/syz-extract/extract.go
M sys/syz-sysgen/sysgen.go
M syz-ci/manager_test.go
M syz-cluster/controller/processor_test.go
M syz-cluster/dashboard/local_ui_test.go
M syz-cluster/pkg/blob/storage_test.go
M syz-cluster/pkg/controller/testutil.go
M syz-cluster/pkg/db/report_reply_repo_test.go
M syz-cluster/pkg/db/report_repo.go
M syz-cluster/pkg/db/report_repo_test.go
M syz-cluster/pkg/db/session_repo_test.go
M syz-cluster/pkg/db/session_test_repo_test.go
M syz-cluster/tools/db-mgmt/main.go
M syz-cluster/workflow/boot/main.go
M tools/arm64/registers.go
M tools/syz-check/dwarf.go
M tools/syz-crush/crush.go
M tools/syz-db-export/reprolist.go
M tools/syz-fillreports/fillreports.go
M tools/syz-fix-analyzer/fix-analyzer.go
M tools/syz-imagegen/combinations.go
M tools/syz-imagegen/imagegen.go
M tools/syz-kconf/kconf.go
M tools/syz-lore/query_lkml.go
M tools/syz-testbed/stats.go
M tools/syz-testbed/testbed.go
M vm/adb/adb.go
M vm/cuttlefish/cuttlefish.go
M vm/dispatcher/pool.go
M vm/dispatcher/pool_test.go
M vm/proxyapp/proxyappclient_tcp_test.go
M vm/proxyapp/proxyappclient_test.go
M vm/qemu/qemu.go
M vm/vm.go
M vm/vm_full_test.go
M vm/vm_test.go

Log Message:
-----------
all: trivial for-loop range refactorings

Fixes for "Use range over integer instead of traditional for loop" linter
warnings that boil down to mechanical replacement.

In certain cases untyped constants like 2e5 are converted to integer literals,
because they are considered as floats and can't be used in range expressions


Commit: 653436c786414755034f10dd85a76fc17bc0facd
https://github.com/google/syzkaller/commit/653436c786414755034f10dd85a76fc17bc0facd
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M vm/vmimpl/vmimpl.go

Log Message:
-----------
vm/vmimpl: suppress range-over-integer warning in EscapeDoubleQuotes

The loop in EscapeDoubleQuotes modifies the iterator variable pos inside the loop body. Ranging over an integer in
Go 1.22+ would overwrite these manual modifications and break the logic. Therefore, we keep the traditional for
loop and suppress the syz-linter warning.


Commit: f8480278d80ba4d3a334a30e45266f665a913b58
https://github.com/google/syzkaller/commit/f8480278d80ba4d3a334a30e45266f665a913b58
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M pkg/aflow/tool/codeeditor/codeeditor_test.go

Log Message:
-----------
pkg/aflow: add a unit test for replace()


Commit: 406a21dd6a14d10047bf717d8e63421a91f004d5
https://github.com/google/syzkaller/commit/406a21dd6a14d10047bf717d8e63421a91f004d5
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M pkg/aflow/tool/codeeditor/codeeditor.go

Log Message:
-----------
pkg/aflow/tool/codeeditor: refactor for-loop to while-style

Refactor the traditional for loop in replace function to a while-style
loop because the loop variable i is modified inside the body. This avoids
the linter warning about ranging over integers where it would be incorrect
due to manual index updates.


Commit: 3bb899a6e2fca9ff7bfd3bb354f01560e4172223
https://github.com/google/syzkaller/commit/3bb899a6e2fca9ff7bfd3bb354f01560e4172223
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M pkg/osutil/osutil_unix.go

Log Message:
-----------
pkg/osutil: refactor for-loop to while-style in ProcessTempDir

Refactor the traditional for loop in ProcessTempDir to a while-style
loop because the loop variable i is modified inside the body
(decremented to retry). Ranging over an integer in Go 1.22+ would
overwrite these manual modifications and break the logic.


Commit: 85894b88c3f4f988e4274d367366bf8c14a7dd58
https://github.com/google/syzkaller/commit/85894b88c3f4f988e4274d367366bf8c14a7dd58
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M pkg/report/fuchsia.go

Log Message:
-----------
pkg/report: suppress range-over-integer warning in fuchsia

The loop in symbolize modifies the iterator variable i inside the
loop body to skip lines when combining split assert lines. Ranging over
an integer in Go 1.22+ would overwrite these manual modifications and
break the logic. Therefore, we keep the traditional for loop and
suppress the syz-linter warning with a nolint comment.


Commit: a5447cba23efc7d4d57895bb10ab4ee5ecf75bab
https://github.com/google/syzkaller/commit/a5447cba23efc7d4d57895bb10ab4ee5ecf75bab
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M tools/syz-check/check.go

Log Message:
-----------
tools/syz-check: suppress range-over-integer warning in writeWarnings

The loop in writeWarnings modifies the iterator variable i inside the
loop body to skip consecutive warnings with identical messages. Ranging
over an integer in Go 1.22+ would overwrite these manual modifications
and break the logic. Therefore, we keep the traditional for loop and
suppress the syz-linter warning with a nolint comment.


Commit: d4f20b78764e36a54b89ed5d5252086e4b4d9a6b
https://github.com/google/syzkaller/commit/d4f20b78764e36a54b89ed5d5252086e4b4d9a6b
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M syz-cluster/pkg/emailclient/smtp_sender.go

Log Message:
-----------
syz-cluster/pkg/emailclient: modernizing loop and fixing error shadowing

Refactor the traditional for loop in querySecret to use range over
integer. Also change the assignment inside the loop from := to = to
avoid shadowing the err variable, ensuring the actual error is
returned on failure instead of nil.


Commit: fcdc28faaaeaa7aeb9f54fe27362e1950bd8403f
https://github.com/google/syzkaller/commit/fcdc28faaaeaa7aeb9f54fe27362e1950bd8403f
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M pkg/tool/flags_test.go

Log Message:
-----------
pkg/tool: add unit tests for flagEscape and flagUnescape

Add unit tests for flagEscape and flagUnescape in flags_test.go to
verify escaping and unescaping logic and prevent regressions.


Commit: dcdbfb4a65e211d9c8126184aa398a1766d07a59
https://github.com/google/syzkaller/commit/dcdbfb4a65e211d9c8126184aa398a1766d07a59
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M pkg/tool/flags.go

Log Message:
-----------
pkg/tool: modernizing loops in flags

Modernize loops in flagEscape and flagUnescape. The loop in flagEscape
is converted to use range over integer. The loop in flagUnescape is
converted to a while-style loop because it modifies the loop variable i
inside the body to jump over escape sequences.


Commit: 9cd2be316f5ff274cc13384095b68a9682f3709a
https://github.com/google/syzkaller/commit/9cd2be316f5ff274cc13384095b68a9682f3709a
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M sys/linux/init_alg_test.go

Log Message:
-----------
sys/linux: replace manual loops with copy in testAlg

Replace traditional for loops with copy() calls in testAlg to copy
address type and name. This is more idiomatic and concise.


Commit: ac66228323b15c75c56a0b7325d4d963a71cf1d4
https://github.com/google/syzkaller/commit/ac66228323b15c75c56a0b7325d4d963a71cf1d4
Author: Alexander Potapenko <gli...@google.com>
Date: 2026-04-21 (Tue, 21 Apr 2026)

Changed paths:
M tools/syz-linter/linter.go
M tools/syz-linter/testdata/src/lintertest/lintertest.go

Log Message:
-----------
tools/syz-linter: add rule for while-style loops with external counter

Add a custom linter rule to detect loops that look like i := 0; for i < N
and suggest refactoring them to for i := 0; i < N; { to improve variable
scoping. Also add test cases in lintertest.go to verify this rule.


Compare: https://github.com/google/syzkaller/compare/645284786b77%5E...ac66228323b1

To unsubscribe from these emails, change your notification settings at https://github.com/google/syzkaller/settings/notifications

Alexander Potapenko

unread,
Apr 21, 2026, 5:45:10 AM (3 days ago) Apr 21
to syzk...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages