Skip to content

Commit

Permalink
fs: use syscall.Timespec.Unix
Browse files Browse the repository at this point in the history
Use the syscall method instead of repeating the type conversions for
the syscall.Stat_t Atim/Atimespec members. This also allows to drop the
//nolint: unconvert comments.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  • Loading branch information
tklauser committed Jan 3, 2022
1 parent 44b5ced commit 030679c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fs/stat_atim.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ func StatMtime(st *syscall.Stat_t) syscall.Timespec {

// StatATimeAsTime returns st.Atim as a time.Time
func StatATimeAsTime(st *syscall.Stat_t) time.Time {
return time.Unix(int64(st.Atim.Sec), int64(st.Atim.Nsec)) //nolint: unconvert // int64 conversions ensure the line compiles for 32-bit systems as well.
return time.Unix(st.Atim.Unix())
}
2 changes: 1 addition & 1 deletion fs/stat_darwinbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ func StatMtime(st *syscall.Stat_t) syscall.Timespec {

// StatATimeAsTime returns the access time as a time.Time
func StatATimeAsTime(st *syscall.Stat_t) time.Time {
return time.Unix(int64(st.Atimespec.Sec), int64(st.Atimespec.Nsec)) //nolint: unconvert // int64 conversions ensure the line compiles for 32-bit systems as well.
return time.Unix(st.Atimespec.Unix())
}

0 comments on commit 030679c

Please sign in to comment.