summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Germishuys <jacquesg@striata.com>2014-07-12 14:44:21 +0200
committerJacques Germishuys <jacquesg@striata.com>2014-08-05 20:51:59 +0200
commitc983604eb1eb17dd42ea0fe47cf15f7c7c503a72 (patch)
tree1b205e6c76b1ff16a65e2893843b42ff7e91f98a
parent2f795d8fc50d81641d95723d9ddd92795886bed3 (diff)
downloadlibgit2-c983604eb1eb17dd42ea0fe47cf15f7c7c503a72.tar.gz
Consistently use p_snprintf
-rw-r--r--src/transports/winhttp.c4
-rw-r--r--src/win32/msvc-compat.h7
-rw-r--r--src/win32/posix_w32.c14
3 files changed, 13 insertions, 12 deletions
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index fd29579ef..32641cd64 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -749,9 +749,9 @@ replay:
/* Verify that we got the correct content-type back */
if (post_verb == s->verb)
- snprintf(expected_content_type_8, MAX_CONTENT_TYPE_LEN, "application/x-git-%s-result", s->service);
+ p_snprintf(expected_content_type_8, MAX_CONTENT_TYPE_LEN, "application/x-git-%s-result", s->service);
else
- snprintf(expected_content_type_8, MAX_CONTENT_TYPE_LEN, "application/x-git-%s-advertisement", s->service);
+ p_snprintf(expected_content_type_8, MAX_CONTENT_TYPE_LEN, "application/x-git-%s-advertisement", s->service);
if (git__utf8_to_16(expected_content_type, MAX_CONTENT_TYPE_LEN, expected_content_type_8) < 0) {
giterr_set(GITERR_OS, "Failed to convert expected content-type to wide characters");
diff --git a/src/win32/msvc-compat.h b/src/win32/msvc-compat.h
index efbc8ee37..4789d63df 100644
--- a/src/win32/msvc-compat.h
+++ b/src/win32/msvc-compat.h
@@ -15,13 +15,6 @@
typedef unsigned short mode_t;
typedef SSIZE_T ssize_t;
-/* define snprintf using variadic macro support if available */
-#if _MSC_VER >= 1500
-# define snprintf(BUF, SZ, FMT, ...) _snprintf_s(BUF, SZ, _TRUNCATE, FMT, __VA_ARGS__)
-#else
-# define snprintf _snprintf
-#endif
-
#endif
#define GIT_STDLIB_CALL __cdecl
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 7df8100ca..0023f95ff 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -564,11 +564,19 @@ char *p_realpath(const char *orig_path, char *buffer)
int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
{
-#if defined(_MSC_VER) && _MSC_VER >= 1500
+#if defined(_MSC_VER)
int len;
- if (count == 0 ||
- (len = _vsnprintf_s(buffer, count, _TRUNCATE, format, argptr)) < 0)
+ if (count == 0)
+ return _vscprintf(format, argptr);
+
+ #if _MSC_VER >= 1500
+ len = _vsnprintf_s(buffer, count, _TRUNCATE, format, argptr);
+ #else
+ len = _vsnprintf(buffer, count, format, argptr);
+ #endif
+
+ if (len < 0)
return _vscprintf(format, argptr);
return len;