Skip to content

Commit 221016e

Browse files
committed
squash: revert cast to unsigned long on windows
1 parent 23bb0f6 commit 221016e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/node_file-inl.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,18 @@ void FillStatsArray(AliasedBufferBase<NativeT, V8T>* fields,
9090
fields->SetValue(offset + static_cast<size_t>(FsStatsOffset::stat_offset), \
9191
static_cast<NativeT>(stat))
9292

93+
// On win32, time is stored in uint64_t and starts from 1601-01-01.
94+
// libuv calculates tv_sec and tv_nsec from it and converts to signed long,
95+
// which causes Y2038 overflow. The rest platforms should treat negative
96+
// values as pre-epoch time.
97+
#ifdef _WIN32
98+
#define SET_FIELD_WITH_TIME_STAT(stat_offset, stat) \
99+
/* NOLINTNEXTLINE(runtime/int) */ \
100+
SET_FIELD_WITH_STAT(stat_offset, static_cast<unsigned long>(stat))
101+
#else
93102
#define SET_FIELD_WITH_TIME_STAT(stat_offset, stat) \
94103
SET_FIELD_WITH_STAT(stat_offset, static_cast<double>(stat))
104+
#endif // _WIN32
95105

96106
SET_FIELD_WITH_STAT(kDev, s->st_dev);
97107
SET_FIELD_WITH_STAT(kMode, s->st_mode);

0 commit comments

Comments
 (0)