diff options
| author | Taras Madan <tarasmadan@google.com> | 2025-06-20 12:04:24 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-06-20 13:09:54 +0000 |
| commit | d6cdfb8a765c64793bc63cf630e68fbdd0ee0974 (patch) | |
| tree | 4ee8ffc152e02bf821671ce02cd28015aa4aa77c /pkg/report/report.go | |
| parent | e3003213f6deee7f817122847d77b769bc8b46ad (diff) | |
pkg/report: minor refactoring
setExecutorInfo is closer to Report.
Distinguish reportType and defaultReportType
Make setter a Report member function.
Diffstat (limited to 'pkg/report/report.go')
| -rw-r--r-- | pkg/report/report.go | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/pkg/report/report.go b/pkg/report/report.go index ea61f0a73..a069fe058 100644 --- a/pkg/report/report.go +++ b/pkg/report/report.go @@ -83,12 +83,22 @@ type ExecutorInfo struct { ExecID int // The program the syz-executor was executing. } -func (r Report) String() string { - return fmt.Sprintf("crash: %v\n%s", r.Title, r.Report) +// unspecifiedType can be used to cancel oops.defaultReportType from oopsFormat.reportType. +const unspecifiedType = crash.Type("UNSPECIFIED") + +func (rep *Report) setType(typ, defaultType crash.Type) { + if typ == unspecifiedType { + rep.Type = crash.UnknownType + } else if typ != crash.UnknownType { + rep.Type = typ + } else { + rep.Type = defaultType + } } -// unspecifiedType can be used to cancel oops.reportType from oopsFormat.reportType. -const unspecifiedType = crash.Type("UNSPECIFIED") +func (rep *Report) String() string { + return fmt.Sprintf("crash: %v\n%s", rep.Title, rep.Report) +} // NewReporter creates reporter for the specified OS/Type. func NewReporter(cfg *mgrconfig.Config) (*Reporter, error) { @@ -240,16 +250,6 @@ func (reporter *Reporter) Symbolize(rep *Report) error { return nil } -func setReportType(rep *Report, oops *oops, format oopsFormat) { - if format.reportType == unspecifiedType { - rep.Type = crash.UnknownType - } else if format.reportType != crash.UnknownType { - rep.Type = format.reportType - } else if oops.reportType != crash.UnknownType { - rep.Type = oops.reportType - } -} - func (reporter *Reporter) isInteresting(rep *Report) bool { if len(reporter.interests) == 0 { return true @@ -406,8 +406,8 @@ type oops struct { header []byte formats []oopsFormat suppressions []*regexp.Regexp - // This reportType will be used if oopsFormat's reportType is empty. - reportType crash.Type + // defaultReportType will be used if oopsFormat's reportType is empty. + defaultReportType crash.Type } type oopsFormat struct { @@ -817,7 +817,7 @@ func simpleLineParser(output []byte, oopses []*oops, params *stackParams, ignore rep.Report = output[rep.StartPos:] rep.Corrupted = corrupted != "" rep.CorruptedReason = corrupted - setReportType(rep, oops, format) + rep.setType(format.reportType, oops.defaultReportType) return rep } |
