refactor(uffd): extract safeInvoke helper#2442
Conversation
Introduce a small safeInvoke(fn) helper in a dedicated invoke.go and
use it in faultPage's two failure paths, replacing duplicated
`if onFailure != nil { signalErr = onFailure() }` blocks.
Pure refactor, no behavior change.
PR SummaryLow Risk Overview Reviewed by Cursor Bugbot for commit cf2b55e. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
LGTM — straightforward deduplication with no behavior change.
Extended reasoning...
Overview
Adds a 3-line safeInvoke helper in a new invoke.go and replaces the two identical inline nil-check blocks in faultPage with calls to it. Only two files changed.
Security risks
None. The helper is internal to the package, touches only the error-path callback invocation, and introduces no new inputs or trust boundaries.
Level of scrutiny
Minimal scrutiny needed. This is a mechanical deduplication with provably identical semantics: safeInvoke(fn) returns nil when fn == nil and fn() otherwise, which is exactly what the replaced inline blocks did.
Other factors
No bugs reported, author verified go build, go vet, and golangci-lint all pass. The change is small, self-contained, and easy to audit by inspection.
Summary
Pure refactor, no behavior change.
Split out of #2419 alongside #2441 (Prefault extraction).
Test plan