s3-lib: Remove unused function sprintf_append
authorAmitay Isaacs <amitay@gmail.com>
Tue, 23 Aug 2016 05:05:08 +0000 (15:05 +1000)
committerJeremy Allison <jra@samba.org>
Tue, 23 Aug 2016 23:33:50 +0000 (01:33 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/proto.h
source3/lib/util_str.c
source3/selftest/tests.py
source3/torture/t_strappend.c [deleted file]
source3/torture/torture.c
source3/wscript_build

index 36a54992561ae9130a9523c2274d9b9b93e95d7f..91484920726c0ae5e6f18a9caa5e96449bfcc816 100644 (file)
@@ -660,8 +660,6 @@ int ipstr_list_parse(const char *ipstr_list, struct ip_service **ip_list);
 void ipstr_list_free(char* ipstr_list);
 uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr);
 uint64_t conv_str_size(const char * str);
-void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len,
-                   size_t *bufsize, const char *fmt, ...);
 int asprintf_strupper_m(char **strp, const char *fmt, ...);
 char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...);
 char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...);
index fc878020b4ee72f166d17e0792c9b04a8a8a67bc..48e434f777ee548593759ea5c8917fa44de24b3a 100644 (file)
@@ -909,65 +909,6 @@ uint64_t conv_str_size(const char * str)
        return lval;
 }
 
-/* Append an sprintf'ed string. Double buffer size on demand. Usable without
- * error checking in between. The indication that something weird happened is
- * string==NULL */
-
-void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len,
-                   size_t *bufsize, const char *fmt, ...)
-{
-       va_list ap;
-       char *newstr;
-       int ret;
-       bool increased;
-
-       /* len<0 is an internal marker that something failed */
-       if (*len < 0)
-               goto error;
-
-       if (*string == NULL) {
-               if (*bufsize == 0)
-                       *bufsize = 128;
-
-               *string = talloc_array(mem_ctx, char, *bufsize);
-               if (*string == NULL)
-                       goto error;
-       }
-
-       va_start(ap, fmt);
-       ret = vasprintf(&newstr, fmt, ap);
-       va_end(ap);
-
-       if (ret < 0)
-               goto error;
-
-       increased = false;
-
-       while ((*len)+ret >= *bufsize) {
-               increased = true;
-               *bufsize *= 2;
-               if (*bufsize >= (1024*1024*256))
-                       goto error;
-       }
-
-       if (increased) {
-               *string = talloc_realloc(mem_ctx, *string, char,
-                                              *bufsize);
-               if (*string == NULL) {
-                       goto error;
-               }
-       }
-
-       StrnCpy((*string)+(*len), newstr, ret);
-       (*len) += ret;
-       free(newstr);
-       return;
-
- error:
-       *len = -1;
-       *string = NULL;
-}
-
 /*
  * asprintf into a string and strupper_m it after that.
  */
index dbd4c58a30818734a2129f847ea2a70c4083d213..afde94899e165a5b9b8313f2f99f209c9b687947 100755 (executable)
@@ -116,7 +116,6 @@ local_tests = [
     "LOCAL-MESSAGING-FDPASS2b",
     "LOCAL-PTHREADPOOL-TEVENT",
     "LOCAL-hex_encode_buf",
-    "LOCAL-sprintf_append",
     "LOCAL-remove_duplicate_addrs2"]
 
 for t in local_tests:
diff --git a/source3/torture/t_strappend.c b/source3/torture/t_strappend.c
deleted file mode 100644 (file)
index d52371e..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2005 by Volker Lendecke
- *
- * Test harness for sprintf_append
- */
-
-#include "includes.h"
-#include "torture/proto.h"
-
-bool run_local_sprintf_append(int dummy)
-{
-       TALLOC_CTX *mem_ctx;
-       char *string = NULL;
-       ssize_t len = 0;
-       size_t bufsize = 4;
-       int i;
-
-       mem_ctx = talloc_init("t_strappend");
-       if (mem_ctx == NULL) {
-               fprintf(stderr, "talloc_init failed\n");
-               return false;
-       }
-
-       sprintf_append(mem_ctx, &string, &len, &bufsize, "");
-       assert(strlen(string) == len);
-       sprintf_append(mem_ctx, &string, &len, &bufsize, "");
-       assert(strlen(string) == len);
-       sprintf_append(mem_ctx, &string, &len, &bufsize,
-                      "01234567890123456789012345678901234567890123456789\n");
-       assert(strlen(string) == len);
-
-
-       for (i=0; i<(10000); i++) {
-               if (i%1000 == 0) {
-                       printf("%d %lld\r", i, (long long int)bufsize);
-                       fflush(stdout);
-               }
-               sprintf_append(mem_ctx, &string, &len, &bufsize, "%d\n", i);
-               if (strlen(string) != len) {
-                       fprintf(stderr, "sprintf_append failed: strlen(string) %lld != len %lld\n",
-                               (long long int)strlen(string), (long long int)len);
-                       return false;
-               }
-       }
-
-       talloc_destroy(mem_ctx);
-
-       return true;
-}
index 06b919e1971fd96bdc9a3a9968f180f6816c7ea2..797f3bef5c609bd525cecf4e66b733ee6ca70039 100644 (file)
@@ -10526,7 +10526,6 @@ static struct {
        { "LOCAL-TEVENT-SELECT", run_local_tevent_select, 0},
        { "LOCAL-CONVERT-STRING", run_local_convert_string, 0},
        { "LOCAL-CONV-AUTH-INFO", run_local_conv_auth_info, 0},
-       { "LOCAL-sprintf_append", run_local_sprintf_append, 0},
        { "LOCAL-hex_encode_buf", run_local_hex_encode_buf, 0},
        { "LOCAL-IDMAP-TDB-COMMON", run_idmap_tdb_common_test, 0},
        { "LOCAL-remove_duplicate_addrs2", run_local_remove_duplicate_addrs2, 0},
index 69b73719fbd00e229f0add2ef39c82a79af28ce2..2d913e8df47498b7fa415a664662dadd7cd41195 100755 (executable)
@@ -1288,7 +1288,6 @@ bld.SAMBA3_BINARY('smbtorture' + bld.env.suffix3,
                  torture/test_messaging_fd_passing.c
                  torture/test_oplock_cancel.c
                  torture/test_pthreadpool_tevent.c
-                 torture/t_strappend.c
                  torture/bench_pthreadpool.c
                  torture/wbc_async.c''',
                  deps='''