windows: address Visual Studio warnings#169
windows: address Visual Studio warnings#169JKRhb wants to merge 1 commit intoeclipse-tinydtls:mainfrom
Conversation
| static inline size_t | ||
| print_timestamp(char *s, size_t len, time_t t) { | ||
| struct tm tmp; | ||
| errno_t err = localtime_s(&tmp, &t); |
There was a problem hiding this comment.
It's not a that good practice, to use the OS instead of a specific HAVE_, if there is no good reason.
So, what is the warning here, you like to fix?
(Just, if you prefer, split the _CRT_RAND_S stuff in a second PR, that may be faster to merge.)
There was a problem hiding this comment.
Thank you for your feedback on this, @boaks. I will shortly move the _CRT_RAND_S change to a separate PR.
Regarding the localtime change: IIRC, the warning it addresses is the following: C4996 'localtime': This function or variable may be unsafe. Consider using localtime_s instead
Do you have a suggestion how this could be solved in a better way?
There was a problem hiding this comment.
The _CRT_RAND_S change is now included separately in #178.
7892056 to
6e58060
Compare
This PR is a small follow-up to #126, addressing two warnings raised by Visual Studio when compiling for Windows.
In order to address the warnings, this PR introduces a platform-specific
print_timestampfunction, usinglocaltime_sinstead oflocaltime(which led to the emission of warnings for being insecure). Furthermore, the definition of_CRT_RAND_Sis moved totinydtls.has it initializes the global state of therand_sfunction and defining it indtls_prng_win.cwas apparently too late in the compilation process.