Skip to content

Commit

Permalink
return error if cpufreq's are empty
Browse files Browse the repository at this point in the history
Signed-off-by: Sergei Semenchuk <pdp.eleven11@gmail.com>
  • Loading branch information
binjip978 committed Dec 11, 2021
1 parent 0f8a320 commit 24c58f6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sysfs/system_cpu.go
Expand Up @@ -11,11 +11,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build linux
// +build linux

package sysfs

import (
"fmt"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -178,6 +180,10 @@ func (fs FS) SystemCpufreq() ([]SystemCPUCpufreqStats, error) {
return nil, err
}

if len(systemCpufreq) == 0 {
return nil, fmt.Errorf("could not find any cpufreq files")
}

return systemCpufreq, nil
}

Expand Down

0 comments on commit 24c58f6

Please sign in to comment.