diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2025-04-14 08:03:23 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2025-04-15 08:30:57 +0000 |
| commit | 23b969b777238d45d0e061f25dd93fbfaf5ee7bc (patch) | |
| tree | 8bc985eaf418e464e515ad034e560c1ab7ef4976 /pkg | |
| parent | 002170fbae88011602918a0d73675bfdb6fe4200 (diff) | |
pkg/declextract: add open fileops callback to interface list
Add open callback if there are no other unique callbacks.
This happens for e.g. seq files which only have unique open,
while read is a common seq_read callback.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/declextract/fileops.go | 6 | ||||
| -rw-r--r-- | pkg/declextract/typing.go | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/pkg/declextract/fileops.go b/pkg/declextract/fileops.go index 387db4f63..3a82d13c2 100644 --- a/pkg/declextract/fileops.go +++ b/pkg/declextract/fileops.go @@ -23,10 +23,14 @@ func (ctx *context) serializeFileOps() { for _, fops := range ctx.FileOps { files := fopsToFiles[fops] canGenerate := Tristate(len(files) != 0) - for _, op := range []*Function{fops.read, fops.write, fops.mmap} { + for _, op := range []*Function{fops.open, fops.read, fops.write, fops.mmap} { if op == nil { continue } + if op == fops.open && (uniqueFuncs[fops.read] == 1 || uniqueFuncs[fops.write] == 1 || + uniqueFuncs[fops.mmap] == 1 || uniqueFuncs[fops.ioctl] == 1) { + continue + } ctx.noteInterface(&Interface{ Type: IfaceFileop, Name: op.Name, diff --git a/pkg/declextract/typing.go b/pkg/declextract/typing.go index 04a11bbc7..31ee31d5d 100644 --- a/pkg/declextract/typing.go +++ b/pkg/declextract/typing.go @@ -49,6 +49,11 @@ import ( // we can consider it as unused. // - Detect common patterns for "must be 0" or "must be const" arguments, e.g.: // if (flags != 0) return -EINVAL; +// - Capture taking address of functions in functions. +// If code takes a function address, the target function most likely needs to be accounted +// in LOC/complexity/coverage analysis (effectively called). We won't see this function +// to be called via a function pointer later, or it may be passed to a very common function +// that we won't analyze (e.g. single_open(..., show_callback, ...)). var ( // Refines types based on data flows... |
