Skip to content

Commit

Permalink
windows: address Visual Studio warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Sep 28, 2022
1 parent 9320251 commit 7892056
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
17 changes: 17 additions & 0 deletions dtls_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,30 @@ static const char *loglevels[] = {

#ifdef HAVE_TIME_H

#ifndef IS_WINDOWS

static inline size_t
print_timestamp(char *s, size_t len, time_t t) {
struct tm *tmp;
tmp = localtime(&t);
return strftime(s, len, "%b %d %H:%M:%S", tmp);
}

#else

static inline size_t
print_timestamp(char *s, size_t len, time_t t) {
struct tm tmp;
errno_t err = localtime_s(&tmp, &t);
if (err) {
printf("Invalid argument to localtime_s.");
exit(1);
}
return strftime(s, len, "%b %d %H:%M:%S", &tmp);
}

#endif

#else /* alternative implementation: just print the timestamp */

static inline size_t
Expand Down
2 changes: 0 additions & 2 deletions platform-specific/dtls_prng_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include "dtls_prng.h"
#include "dtls_debug.h"

#define _CRT_RAND_S

#include <stdlib.h>

#if defined(__MINGW32__)
Expand Down
1 change: 1 addition & 0 deletions tinydtls.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#if defined(_WIN32) || defined(_WIN64)
#define IS_WINDOWS 1
#define _CRT_RAND_S
#endif

#ifndef CONTIKI
Expand Down

0 comments on commit 7892056

Please sign in to comment.