Fix some deprecation warnings on Windows

This fixes some snprintf and vsnprintf related deprecation
warnings we've been having on Windows with recent compilers.
This commit is contained in:
Russell Belfer 2013-02-28 14:41:26 -08:00
parent 97b7137459
commit f443a72d33
3 changed files with 10 additions and 4 deletions

View File

@ -33,11 +33,9 @@
# include "win32/pthread.h"
#endif
# define snprintf _snprintf
#else
# include <unistd.h>
# include <unistd.h>
# ifdef GIT_THREADS
# include <pthread.h>
# endif

View File

@ -37,6 +37,13 @@
/* MSVC doesn't define ssize_t at all */
typedef SSIZE_T ssize_t;
/* define snprintf using variadic macro support if available */
#if _MSC_VER >= 1400
# define snprintf(BUF, SZ, FMT, ...) _snprintf_s(BUF, SZ, _TRUNCATE, FMT, __VA_ARGS__)
#else
# define snprintf _snprintf
#endif
#endif
#define GIT_STDLIB_CALL __cdecl

View File

@ -375,7 +375,8 @@ int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
#ifdef _MSC_VER
int len;
if (count == 0 || (len = _vsnprintf(buffer, count, format, argptr)) < 0)
if (count == 0 ||
(len = _vsnprintf_s(buffer, count, _TRUNCATE, format, argptr)) < 0)
return _vscprintf(format, argptr);
return len;