]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
unittests: Fixed compilation warnings
authorSteve Holme <steve_holme@hotmail.com>
Sat, 2 Apr 2016 23:02:19 +0000 (00:02 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Sat, 2 Apr 2016 23:02:19 +0000 (00:02 +0100)
warning: implicit declaration of function 'sprintf_was_used'
         [-Wimplicit-function-declaration]

Follow up to the modications made to tests/libtest in commit 55452ebdff
as we prefer not to use sprintf() now.

tests/unit/unit1604.c

index c61f010dc62fa1d1119036065082ffa5e4cae93e..3fb9636eefc5f9931b91efdcb2aa275f86577774 100644 (file)
@@ -45,7 +45,7 @@ static void unit_stop(void)
 static char *getflagstr(int flags) {
   char *buf = malloc(256);
   fail_unless(buf, "out of memory");
-  sprintf(buf, "%s,%s,%s,%s",
+  snprintf(buf, sizeof(buf), "%s,%s,%s,%s",
     ((flags & SANITIZE_ALLOW_COLONS) ? "SANITIZE_ALLOW_COLONS" : ""),
     ((flags & SANITIZE_ALLOW_PATH) ? "SANITIZE_ALLOW_PATH" : ""),
     ((flags & SANITIZE_ALLOW_RESERVED) ? "SANITIZE_ALLOW_RESERVED" : ""),
@@ -56,7 +56,7 @@ static char *getflagstr(int flags) {
 static char *getcurlcodestr(int cc) {
   char *buf = malloc(256);
   fail_unless(buf, "out of memory");
-  sprintf(buf, "%s (%d)",
+  snprintf(buf, sizeof(buf), "%s (%d)",
     (cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" :
      cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" :
      cc == SANITIZE_ERR_INVALID_PATH ? "SANITIZE_ERR_INVALID_PATH" :