From 95871dcc45f6531b4c692ff892aad56bdd95e16f Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 10 Feb 2023 12:14:36 +0100 Subject: pkg/subsystem: restructure the package Remove the entity and match subpackages. Regenerate the linux.go file. --- pkg/subsystem/extractor.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'pkg/subsystem/extractor.go') diff --git a/pkg/subsystem/extractor.go b/pkg/subsystem/extractor.go index e54086b29..075c8079d 100644 --- a/pkg/subsystem/extractor.go +++ b/pkg/subsystem/extractor.go @@ -3,10 +3,6 @@ package subsystem -import ( - "github.com/google/syzkaller/pkg/subsystem/entity" -) - // Extractor deduces the subsystems from the list of crashes. type Extractor struct { raw rawExtractorInterface @@ -21,17 +17,17 @@ type Crash struct { // rawExtractorInterface simplifies testing. type rawExtractorInterface interface { - FromPath(path string) []*entity.Subsystem - FromProg(progBytes []byte) []*entity.Subsystem + FromPath(path string) []*Subsystem + FromProg(progBytes []byte) []*Subsystem } -func MakeExtractor(list []*entity.Subsystem) *Extractor { +func MakeExtractor(list []*Subsystem) *Extractor { return &Extractor{raw: makeRawExtractor(list)} } -func (e *Extractor) Extract(crashes []*Crash) []*entity.Subsystem { +func (e *Extractor) Extract(crashes []*Crash) []*Subsystem { // First put all subsystems to the same list. - subsystems := []*entity.Subsystem{} + subsystems := []*Subsystem{} for _, crash := range crashes { if crash.GuiltyPath != "" { subsystems = append(subsystems, e.raw.FromPath(crash.GuiltyPath)...) @@ -42,7 +38,7 @@ func (e *Extractor) Extract(crashes []*Crash) []*entity.Subsystem { } // If there are both parents and children, remove parents. - ignore := make(map[*entity.Subsystem]struct{}) + ignore := make(map[*Subsystem]struct{}) for _, entry := range subsystems { for p := range entry.ReachableParents() { ignore[p] = struct{}{} @@ -50,7 +46,7 @@ func (e *Extractor) Extract(crashes []*Crash) []*entity.Subsystem { } // And calculate counts. - counts := make(map[*entity.Subsystem]int) + counts := make(map[*Subsystem]int) maxCount := 0 for _, entry := range subsystems { if _, ok := ignore[entry]; ok { @@ -63,7 +59,7 @@ func (e *Extractor) Extract(crashes []*Crash) []*entity.Subsystem { } // Pick the most prevalent ones. - ret := []*entity.Subsystem{} + ret := []*Subsystem{} for entry, count := range counts { if count < maxCount { continue -- cgit mrf-deployment