mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 01:48:35 +00:00
Tools: Stop counting plain loops as a hard blocker in the selftest audit
for/while lower since #106. The iterator loops (bpf_for, bpf_repeat) and the bpf_loop helper do not, so they keep a hard label of their own, and a do { } while (0) macro is no longer read as a loop. Against bpf-next 5714ca8 the programs with no hard blocker go from 29 to 39. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -15,7 +15,7 @@ negatives in both directions, and the envelope it encodes (the helper, map and
|
||||
construct lists below) must be kept in step with the compiler by hand. Re-run
|
||||
it after a feature lands to see what the feature unlocked. The lists were last
|
||||
reconciled against pythonbpf/helper and pythonbpf/maps when scalar @bpfglobal
|
||||
support and integer signedness merged.
|
||||
support, integer signedness and loops merged.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
@ -70,7 +70,10 @@ NOT_HELPERS = {
|
||||
# cost a careful rewrite can absorb). Order does not matter.
|
||||
PATTERNS = [
|
||||
# control flow
|
||||
("loop", "hard", r"\b(for|while)\s*\(|\bbpf_for\b|\bbpf_repeat\b|\bbpf_loop\s*\("),
|
||||
# plain for/while lower since loops landed (#106); `do { } while (0)` is a
|
||||
# macro idiom, not a loop. Iterator loops and the bpf_loop helper are not.
|
||||
("open_coded_loop", "hard", r"\bbpf_for(_each)?\b|\bbpf_repeat\b|\bbpf_loop\s*\("),
|
||||
("do_while", "soft", r"\}\s*while\s*\((?!\s*0\s*\))"),
|
||||
("goto", "hard", r"\bgoto\s+\w+"),
|
||||
("switch", "hard", r"\bswitch\s*\("),
|
||||
("ternary", "soft", r"\?[^?:]*:"),
|
||||
|
||||
Reference in New Issue
Block a user