Skip to content

Commit

Permalink
fix(time): ticks is uint64
Browse files Browse the repository at this point in the history
The field started_time fetched from /proc stat file and passed as ticks
to ClockTicksToNsSinceBootTime() is an uint64.
  • Loading branch information
geyslan committed Oct 22, 2024
1 parent ee38ed6 commit bb573be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/time/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func getClockTimeNS(clockID int32) (int64, error) {
//

// ClockTicksToNsSinceBootTime converts kernel clock ticks to nanoseconds.
func ClockTicksToNsSinceBootTime(ticks int64) uint64 {
func ClockTicksToNsSinceBootTime(ticks uint64) uint64 {
// From the man page proc(5):
//
// starttime:
Expand All @@ -165,7 +165,7 @@ func ClockTicksToNsSinceBootTime(ticks int64) uint64 {
// in clock ticks (divide by sysconf(_SC_CLK_TCK)).
//
// The format for this field was %lu before Linux 2.6.
return uint64(ticks * 1000000000 / GetUserHZ())
return ticks * 1000000000 / uint64(GetUserHZ())
}

// BootToEpochNS converts time since boot to the epoch time
Expand Down

0 comments on commit bb573be

Please sign in to comment.