Skip to content

convbin: workaround gmtime_t for windows WIN32#884

Open
ourairquality wants to merge 1 commit into
rtklibexplorer:mainfrom
ourairquality:win32-gmtime
Open

convbin: workaround gmtime_t for windows WIN32#884
ourairquality wants to merge 1 commit into
rtklibexplorer:mainfrom
ourairquality:win32-gmtime

Conversation

@ourairquality
Copy link
Copy Markdown

which has gmtime_s.

MSC has gmtime_s, but not BCC which has gmtime_r.
@rtklibexplorer
Copy link
Copy Markdown
Owner

From AI code review:

gmtime_r() returns non-null on success, so the existing if (...) is correct. But Microsoft gmtime_s() returns 0 on success and nonzero on failure, so this branch only enters the block on failure and then uses tm anyway. Microsoft documents gmtime_s as “Zero if successful” and error code on failure.

Suggested fix:

#ifdef _MSC_VER
if (!gmtime_s(&tm, &st.st_mtime)) {
#else
if (gmtime_r(&st.st_mtime, &tm)) {
#endif

Is this a valid concern?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants