From bf86f5aaada407ff2fed28fe03bc0b892caf4e41 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 9 Apr 2024 08:56:35 +0200 Subject: pkg/cover: move functions to after they are used This makes code easier to read top-down in the natural order and Go does not require the inverted declaration order like C/C++. --- pkg/cover/report.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'pkg/cover/report.go') diff --git a/pkg/cover/report.go b/pkg/cover/report.go index f52a2bcaa..4e7ec3001 100644 --- a/pkg/cover/report.go +++ b/pkg/cover/report.go @@ -76,19 +76,6 @@ type line struct { pcProgCount map[uint64]int // some lines have multiple BBs } -func coverageCallbackMismatch(debug bool, numPCs int, unmatchedProgPCs map[uint64]bool) error { - debugStr := "" - if debug { - debugStr += "\n\nUnmatched PCs:\n" - for pc := range unmatchedProgPCs { - debugStr += fmt.Sprintf("%x\n", pc) - } - } - // nolint: lll - return fmt.Errorf("%d out of %d PCs returned by kcov do not have matching coverage callbacks. Check the discoverModules() code.%s", - len(unmatchedProgPCs), numPCs, debugStr) -} - type fileMap map[string]*file func (rg *ReportGenerator) prepareFileMap(progs []Prog, debug bool) (fileMap, error) { @@ -181,6 +168,18 @@ func (rg *ReportGenerator) prepareFileMap(progs []Prog, debug bool) (fileMap, er return files, nil } +func coverageCallbackMismatch(debug bool, numPCs int, unmatchedProgPCs map[uint64]bool) error { + debugStr := "" + if debug { + debugStr += "\n\nUnmatched PCs:\n" + for pc := range unmatchedProgPCs { + debugStr += fmt.Sprintf("%x\n", pc) + } + } + return fmt.Errorf("%d out of %d PCs returned by kcov do not have matching coverage callbacks."+ + " Check the discoverModules() code.%s", len(unmatchedProgPCs), numPCs, debugStr) +} + func uniquePCs(progs []Prog) []uint64 { PCs := make(map[uint64]bool) for _, p := range progs { -- cgit mrf-deployment