[Spice-devel] [vdagent-win V2 2/6] Fix building with Visual Studio (snprintf)

Uri Lublin uril at redhat.com
Mon Mar 24 10:02:39 PDT 2014


This commit partially reverts 4b9e9b1d28ea7eaec44ff73e2f91c4064986b12a

Building with Visual Studio breaks as snprintf is not implemented:
  vdagent\file_xfer.cpp(198) : error C3861: 'snprintf': identifier not found

Replace it with sprintf_s, which apparently is implemented in mingw too.
---
 vdagent/file_xfer.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index d1459c1..01072ba 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -195,10 +195,10 @@ bool FileXfer::g_key_get_string(char* data, const char* group, const char* key,
     char *group_pos, *key_pos, *next_group_pos, *start, *end;
     unsigned len;

-    snprintf(group_pfx, sizeof(group_pfx), "[%s]", group);
+    sprintf_s(group_pfx, sizeof(group_pfx), "[%s]", group);
     if (!(group_pos = strstr((char*)data, group_pfx))) return false;

-    snprintf(key_pfx, sizeof(key_pfx), "\n%s=", key);
+    sprintf_s(key_pfx, sizeof(key_pfx), "\n%s=", key);
     if (!(key_pos = strstr(group_pos, key_pfx))) return false;

     next_group_pos = strstr(group_pos + strlen(group_pfx), "[");
-- 
1.8.5.3



More information about the Spice-devel mailing list