From 67e329d0301d86470ed8cd61f690538506a7fd40 Mon Sep 17 00:00:00 2001 From: Daniel Hodges Date: Sun, 31 Oct 2021 18:55:53 -0400 Subject: [PATCH] Remove conditional error handling in profilers Signed-off-by: Daniel Hodges --- cache_profiler.go | 8 ++------ hardware_profiler.go | 8 ++------ software_profiler.go | 6 +----- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/cache_profiler.go b/cache_profiler.go index c7330f1..e3f79af 100644 --- a/cache_profiler.go +++ b/cache_profiler.go @@ -402,7 +402,7 @@ func (p *cacheProfiler) Profile(cacheProfile *CacheProfile) error { cacheProfile.Reset() p.profilersMu.RLock() for profilerType, profiler := range p.profilers { - profileVal := profileValuePool.Get().(*ProfileValue) + profileVal := ProfileValuePool.Get().(*ProfileValue) err2 := profiler.Profile(profileVal) err = multierr.Append(err, err2) if err2 == nil { @@ -470,9 +470,5 @@ func (p *cacheProfiler) Profile(cacheProfile *CacheProfile) error { } } p.profilersMu.RUnlock() - if len(multierr.Errors(err)) == len(p.profilers) { - return err - } - - return nil + return err } diff --git a/hardware_profiler.go b/hardware_profiler.go index 4a9123f..c862be3 100644 --- a/hardware_profiler.go +++ b/hardware_profiler.go @@ -204,7 +204,7 @@ func (p *hardwareProfiler) Profile(hwProfile *HardwareProfile) error { hwProfile.Reset() p.profilersMu.RLock() for profilerType, profiler := range p.profilers { - profileVal := profileValuePool.Get().(*ProfileValue) + profileVal := ProfileValuePool.Get().(*ProfileValue) err2 := profiler.Profile(profileVal) err = multierr.Append(err, err2) if err2 == nil { @@ -238,10 +238,6 @@ func (p *hardwareProfiler) Profile(hwProfile *HardwareProfile) error { } } } - if len(multierr.Errors(err)) == len(p.profilers) { - return err - } p.profilersMu.RUnlock() - - return nil + return err } diff --git a/software_profiler.go b/software_profiler.go index cf4f6aa..af88d03 100644 --- a/software_profiler.go +++ b/software_profiler.go @@ -183,7 +183,7 @@ func (p *softwareProfiler) Profile(swProfile *SoftwareProfile) error { swProfile.Reset() p.profilersMu.RLock() for profilerType, profiler := range p.profilers { - profileVal := profileValuePool.Get().(*ProfileValue) + profileVal := ProfileValuePool.Get().(*ProfileValue) err2 := profiler.Profile(profileVal) err = multierr.Append(err, err2) if err2 == nil { @@ -217,9 +217,5 @@ func (p *softwareProfiler) Profile(swProfile *SoftwareProfile) error { } } p.profilersMu.RUnlock() - if len(multierr.Errors(err)) == len(p.profilers) { - return err - } - return nil }