From d123085f695745cc58f3d6882bfc7ce0893d8b84 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 23 Aug 2016 15:05:08 +1000 Subject: [PATCH] s3-lib: Remove unused function sprintf_append BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Jeremy Allison --- source3/include/proto.h | 2 -- source3/lib/util_str.c | 59 ----------------------------------- source3/selftest/tests.py | 1 - source3/torture/t_strappend.c | 49 ----------------------------- source3/torture/torture.c | 1 - source3/wscript_build | 1 - 6 files changed, 113 deletions(-) delete mode 100644 source3/torture/t_strappend.c diff --git a/source3/include/proto.h b/source3/include/proto.h index 36a54992561a..91484920726c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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, ...); diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index fc878020b4ee..48e434f777ee 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -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. */ diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index dbd4c58a3081..afde94899e16 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -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 index d52371e998f9..000000000000 --- a/source3/torture/t_strappend.c +++ /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; -} diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 06b919e1971f..797f3bef5c60 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -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}, diff --git a/source3/wscript_build b/source3/wscript_build index 69b73719fbd0..2d913e8df474 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -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=''' -- 2.34.1