diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-13 14:37:47 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-13 14:37:47 +0300 |
| commit | de6b9c4741dea87ce66e0309bac580030490dc30 (patch) | |
| tree | e535c606fb9ec90cacb3790544fe50038f7850e1 /internal/generate/codegen.go | |
| parent | 306b9eb1c1054992506dd36fc9f1b64e11276598 (diff) | |
refactor(generate): replace classifySyscall switches with kindRegistry (OCP)
Introduce kindregistry.go with a kindMeta struct (structName, enterAccepted)
and a kindRegistry map keyed by TracepointKind. Replace the switch in
isEnterRejected (codegen.go) and the switch in eventStructName (bpfhandler.go)
with lookupKind registry lookups. Adding a new TracepointKind now only
requires a single registry entry — no switch statements need to be touched.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/generate/codegen.go')
| -rw-r--r-- | internal/generate/codegen.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/internal/generate/codegen.go b/internal/generate/codegen.go index 1c7a9b3..e3ec0ef 100644 --- a/internal/generate/codegen.go +++ b/internal/generate/codegen.go @@ -131,13 +131,11 @@ func classifySyscall(sc Syscall) ([]GeneratedTracepoint, string) { return result, "" } +// isEnterRejected reports whether kind must not appear on a syscall-enter +// tracepoint. The answer comes from the kindRegistry so no switch statement +// needs updating when a new TracepointKind is added. func isEnterRejected(kind TracepointKind) bool { - switch kind { - case KindFd, KindName, KindOpen, KindPathname, KindFcntl, KindNull, KindDup3, KindOpenByHandleAt: - return false - default: - return true - } + return !lookupKind(kind).enterAccepted } func syscallFormatNames(sc Syscall) []string { |
