diff options
| author | Pali Rohár <pali.rohar@gmail.com> | 2019-04-25 19:26:23 +0200 |
|---|---|---|
| committer | Pali Rohár <pali.rohar@gmail.com> | 2019-04-25 19:26:23 +0200 |
| commit | d9d49f2dfc4eb4c22c8d9185348e67352e488f8b (patch) | |
| tree | 5583514f79bdc78bb47e0981e99213501ac2556f | |
| parent | 04bbf2486da795d02e27833bf98a1bbf0188c42e (diff) | |
| download | dlfcn-win32-d9d49f2dfc4eb4c22c8d9185348e67352e488f8b.tar.gz dlfcn-win32-d9d49f2dfc4eb4c22c8d9185348e67352e488f8b.tar.bz2 dlfcn-win32-d9d49f2dfc4eb4c22c8d9185348e67352e488f8b.zip | |
Remove ifdef hack for snprintf()
Old version of MSVC does not support snprintf() function and sprintf_s() is
not replacement for C99 snprintf(). As the only usage of snprintf() is to
format void* pointer we can use sprintf() with enough long buffer.
| -rw-r--r-- | dlfcn.c | 10 |
1 files changed, 5 insertions, 5 deletions
| @@ -46,10 +46,6 @@ | |||
| 46 | #endif | 46 | #endif |
| 47 | #include "dlfcn.h" | 47 | #include "dlfcn.h" |
| 48 | 48 | ||
| 49 | #if ((defined(_WIN32) || defined(WIN32)) && (defined(_MSC_VER)) ) | ||
| 50 | #define snprintf sprintf_s | ||
| 51 | #endif | ||
| 52 | |||
| 53 | /* Note: | 49 | /* Note: |
| 54 | * MSDN says these functions are not thread-safe. We make no efforts to have | 50 | * MSDN says these functions are not thread-safe. We make no efforts to have |
| 55 | * any kind of thread safety. | 51 | * any kind of thread safety. |
| @@ -191,7 +187,11 @@ static void save_err_ptr_str( const void *ptr ) | |||
| 191 | { | 187 | { |
| 192 | char ptr_buf[19]; /* 0x<pointer> up to 64 bits. */ | 188 | char ptr_buf[19]; /* 0x<pointer> up to 64 bits. */ |
| 193 | 189 | ||
| 194 | snprintf( ptr_buf, 19, "0x%p", ptr ); | 190 | #ifdef _MSC_VER |
| 191 | /* Supress warning C4996: 'sprintf': This function or variable may be unsafe */ | ||
| 192 | #pragma warning( suppress: 4996 ) | ||
| 193 | #endif | ||
| 194 | sprintf( ptr_buf, "0x%p", ptr ); | ||
| 195 | 195 | ||
| 196 | save_err_str( ptr_buf ); | 196 | save_err_str( ptr_buf ); |
| 197 | } | 197 | } |
