[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Fri Nov 20 08:51:13 MST 2009
The branch, master has been updated
via c1cb1f7... charset/tests/iconv - Remove the "const" from "ptr_in" to prevent "discard_const_p" use
via 9776cb0... tdb tools: Mostly cosmetic adaptions
via 94c33bd... util/strlist: Fix up "const" warnings in the string list and test code
from eea5a16... s3-build: delete more object files for "make clean".
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit c1cb1f7724bd9c6e1862e59b71fc3f5375d6ff3e
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Oct 16 19:03:57 2009 +0200
charset/tests/iconv - Remove the "const" from "ptr_in" to prevent "discard_const_p" use
Signed-off-by: Stefan Metzmacher <metze at samba.org>
commit 9776cb03450d21da5d454e683bdba29793ba3f67
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Oct 16 19:02:02 2009 +0200
tdb tools: Mostly cosmetic adaptions
Signed-off-by: Stefan Metzmacher <metze at samba.org>
commit 94c33bdd72e22a9bb9e51b6acc15ae23087628e4
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Oct 16 19:06:29 2009 +0200
util/strlist: Fix up "const" warnings in the string list and test code
This work I did using suggestions by Jelmer.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/tdb/tools/tdbdump.c | 4 +-
lib/tdb/tools/tdbtool.c | 13 +++++----
lib/util/charset/tests/iconv.c | 14 +++++-----
lib/util/tests/strlist.c | 51 +++++++++++++++++++++------------------
lib/util/util.h | 2 +-
lib/util/util_strlist.c | 3 +-
6 files changed, 46 insertions(+), 41 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/tdb/tools/tdbdump.c b/lib/tdb/tools/tdbdump.c
index 8d93038..027fda3 100644
--- a/lib/tdb/tools/tdbdump.c
+++ b/lib/tdb/tools/tdbdump.c
@@ -65,8 +65,8 @@ static int dump_tdb(const char *fname, const char *keyname)
if (!keyname) {
tdb_traverse(tdb, traverse_fn, NULL);
} else {
- key.dptr = discard_const_p(uint8_t,keyname);
- key.dsize = strlen( keyname);
+ key.dptr = discard_const_p(uint8_t, keyname);
+ key.dsize = strlen(keyname);
value = tdb_fetch(tdb, key);
if (!value.dptr) {
return 1;
diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c
index d646515..b380883 100644
--- a/lib/tdb/tools/tdbtool.c
+++ b/lib/tdb/tools/tdbtool.c
@@ -419,6 +419,7 @@ static void info_tdb(void)
static void speed_tdb(const char *tlimit)
{
+ const char *str = "store test", *str2 = "transaction test";
unsigned timelimit = tlimit?atoi(tlimit):0;
double t;
int ops;
@@ -430,9 +431,9 @@ static void speed_tdb(const char *tlimit)
do {
long int r = random();
TDB_DATA key, dbuf;
- key.dptr = (unsigned char *)"store test";
+ key.dptr = discard_const_p(uint8_t, str);
key.dsize = strlen((char *)key.dptr);
- dbuf.dptr = (unsigned char *)&r;
+ dbuf.dptr = (uint8_t *) &r;
dbuf.dsize = sizeof(r);
tdb_store(tdb, key, dbuf, TDB_REPLACE);
t = _end_timer();
@@ -446,9 +447,9 @@ static void speed_tdb(const char *tlimit)
do {
long int r = random();
TDB_DATA key, dbuf;
- key.dptr = (unsigned char *)"store test";
+ key.dptr = discard_const_p(uint8_t, str);
key.dsize = strlen((char *)key.dptr);
- dbuf.dptr = (unsigned char *)&r;
+ dbuf.dptr = (uint8_t *) &r;
dbuf.dsize = sizeof(r);
tdb_fetch(tdb, key);
t = _end_timer();
@@ -462,9 +463,9 @@ static void speed_tdb(const char *tlimit)
do {
long int r = random();
TDB_DATA key, dbuf;
- key.dptr = (unsigned char *)"transaction test";
+ key.dptr = discard_const_p(uint8_t, str2);
key.dsize = strlen((char *)key.dptr);
- dbuf.dptr = (unsigned char *)&r;
+ dbuf.dptr = (uint8_t *) &r;
dbuf.dsize = sizeof(r);
tdb_transaction_start(tdb);
tdb_store(tdb, key, dbuf, TDB_REPLACE);
diff --git a/lib/util/charset/tests/iconv.c b/lib/util/charset/tests/iconv.c
index 3e2546d..178192e 100644
--- a/lib/util/charset/tests/iconv.c
+++ b/lib/util/charset/tests/iconv.c
@@ -134,7 +134,7 @@ static bool test_buffer(struct torture_context *test,
{
uint8_t buf1[1000], buf2[1000], buf3[1000];
size_t outsize1, outsize2, outsize3;
- const char *ptr_in;
+ char *ptr_in;
char *ptr_out;
size_t size_in1, size_in2, size_in3;
size_t ret1, ret2, ret3, len1, len2;
@@ -164,25 +164,25 @@ static bool test_buffer(struct torture_context *test,
}
/* internal convert to charset - placing result in buf1 */
- ptr_in = (const char *)inbuf;
+ ptr_in = (char *)inbuf;
ptr_out = (char *)buf1;
size_in1 = size;
outsize1 = sizeof(buf1);
memset(ptr_out, 0, outsize1);
errno = 0;
- ret1 = smb_iconv(cd2, &ptr_in, &size_in1, &ptr_out, &outsize1);
+ ret1 = smb_iconv(cd2, (const char **) &ptr_in, &size_in1, &ptr_out, &outsize1);
errno1 = errno;
/* system convert to charset - placing result in buf2 */
- ptr_in = (const char *)inbuf;
+ ptr_in = (char *)inbuf;
ptr_out = (char *)buf2;
size_in2 = size;
outsize2 = sizeof(buf2);
memset(ptr_out, 0, outsize2);
errno = 0;
- ret2 = iconv(cd, discard_const_p(char *, &ptr_in), &size_in2, &ptr_out, &outsize2);
+ ret2 = iconv(cd, &ptr_in, &size_in2, &ptr_out, &outsize2);
errno2 = errno;
len1 = sizeof(buf1) - outsize1;
@@ -236,13 +236,13 @@ static bool test_buffer(struct torture_context *test,
/* convert back to UTF-16, putting result in buf3 */
size = size - size_in1;
- ptr_in = (const char *)buf1;
+ ptr_in = (char *)buf1;
ptr_out = (char *)buf3;
size_in3 = len1;
outsize3 = sizeof(buf3);
memset(ptr_out, 0, outsize3);
- ret3 = smb_iconv(cd3, &ptr_in, &size_in3, &ptr_out, &outsize3);
+ ret3 = smb_iconv(cd3, (const char **) &ptr_in, &size_in3, &ptr_out, &outsize3);
/* we only internally support the first 1M codepoints */
if (outsize3 != sizeof(buf3) - size &&
diff --git a/lib/util/tests/strlist.c b/lib/util/tests/strlist.c
index a974f58..8940dab 100644
--- a/lib/util/tests/strlist.c
+++ b/lib/util/tests/strlist.c
@@ -30,7 +30,7 @@ struct test_list_element {
const char *list[5];
};
-struct test_list_element test_lists_strings[] = {
+const struct test_list_element test_lists_strings[] = {
{
.list_as_string = "",
.list = { NULL }
@@ -63,7 +63,7 @@ struct test_list_element test_lists_strings[] = {
}
};
-struct test_list_element test_lists_shell_strings[] = {
+const struct test_list_element test_lists_shell_strings[] = {
{
.list_as_string = "",
.list = { NULL }
@@ -99,18 +99,18 @@ struct test_list_element test_lists_shell_strings[] = {
}
};
-static bool test_lists_shell(struct torture_context *tctx,
- const void *data)
+static bool test_lists_shell(struct torture_context *tctx, const void *data)
{
const struct test_list_element *element = data;
- const char **ret1, **ret2, *tmp;
+
+ char **ret1, **ret2, *tmp;
bool match = true;
TALLOC_CTX *mem_ctx = tctx;
ret1 = str_list_make_shell(mem_ctx, element->list_as_string, element->seperators);
torture_assert(tctx, ret1, "str_list_make_shell() must not return NULL");
- tmp = str_list_join_shell(mem_ctx, ret1, element->seperators ? *element->seperators : ' ');
+ tmp = str_list_join_shell(mem_ctx, (const char **) ret1, element->seperators ? *element->seperators : ' ');
ret2 = str_list_make_shell(mem_ctx, tmp, element->seperators);
if ((ret1 == NULL || ret2 == NULL) && ret2 != ret1) {
@@ -130,7 +130,8 @@ static bool test_lists_shell(struct torture_context *tctx,
torture_assert(tctx, match, talloc_asprintf(tctx,
"str_list_{make,join}_shell: Error double parsing, first run:\n%s\nSecond run: \n%s", element->list_as_string, tmp));
- torture_assert(tctx, str_list_equal(ret1, element->list),
+ torture_assert(tctx, str_list_equal((const char * const *) ret1,
+ element->list),
talloc_asprintf(tctx,
"str_list_make_shell(%s) failed to create correct list",
element->list_as_string));
@@ -141,10 +142,12 @@ static bool test_lists_shell(struct torture_context *tctx,
static bool test_list_make(struct torture_context *tctx, const void *data)
{
const struct test_list_element *element = data;
+
char **result;
result = str_list_make(tctx, element->list_as_string, element->seperators);
torture_assert(tctx, result, "str_list_make() must not return NULL");
- torture_assert(tctx, str_list_equal((const char **)result, element->list),
+ torture_assert(tctx, str_list_equal((const char * const *) result,
+ element->list),
talloc_asprintf(tctx,
"str_list_make(%s) failed to create correct list",
element->list_as_string));
@@ -250,7 +253,7 @@ static bool test_list_length(struct torture_context *tctx)
static bool test_list_add(struct torture_context *tctx)
{
- char **result, **result2;
+ const char **result, **result2;
const char *list[] = {
"element_0",
"element_1",
@@ -258,9 +261,9 @@ static bool test_list_add(struct torture_context *tctx)
"element_3",
NULL
};
- result = str_list_make(tctx, "element_0, element_1, element_2", NULL);
+ result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL);
torture_assert(tctx, result, "str_list_make() must not return NULL");
- result2 = str_list_add(result, "element_3");
+ result2 = str_list_add((const char **) result, "element_3");
torture_assert(tctx, result2, "str_list_add() must not return NULL");
torture_assert(tctx, str_list_equal(result2, list),
"str_list_add() failed");
@@ -270,7 +273,7 @@ static bool test_list_add(struct torture_context *tctx)
static bool test_list_add_const(struct torture_context *tctx)
{
- char **result, **result2;
+ const char **result, **result2;
const char *list[] = {
"element_0",
"element_1",
@@ -278,7 +281,7 @@ static bool test_list_add_const(struct torture_context *tctx)
"element_3",
NULL
};
- result = str_list_make(tctx, "element_0, element_1, element_2", NULL);
+ result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL);
torture_assert(tctx, result, "str_list_make() must not return NULL");
result2 = str_list_add_const(result, "element_3");
torture_assert(tctx, result2, "str_list_add_const() must not return NULL");
@@ -290,14 +293,14 @@ static bool test_list_add_const(struct torture_context *tctx)
static bool test_list_remove(struct torture_context *tctx)
{
- char **result;
+ const char **result;
const char *list[] = {
"element_0",
"element_1",
"element_3",
NULL
};
- result = str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL);
+ result = (const char **) str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL);
torture_assert(tctx, result, "str_list_make() must not return NULL");
str_list_remove(result, "element_2");
torture_assert(tctx, str_list_equal(result, list),
@@ -336,7 +339,7 @@ static bool test_list_check_ci(struct torture_context *tctx)
static bool test_list_unique(struct torture_context *tctx)
{
- char **result;
+ const char **result;
const char *list[] = {
"element_0",
"element_1",
@@ -354,7 +357,7 @@ static bool test_list_unique(struct torture_context *tctx)
"element_2",
NULL
};
- result = str_list_copy(tctx, list_dup);
+ result = (const char **) str_list_copy(tctx, list_dup);
/* We must copy the list, as str_list_unique does a talloc_realloc() on it's parameter */
result = str_list_unique(result);
torture_assert(tctx, result, "str_list_unique() must not return NULL");
@@ -398,7 +401,7 @@ static bool test_list_unique_2(struct torture_context *tctx)
static bool test_list_append(struct torture_context *tctx)
{
- char **result;
+ const char **result;
const char *list[] = {
"element_0",
"element_1",
@@ -420,7 +423,7 @@ static bool test_list_append(struct torture_context *tctx)
"element_5",
NULL
};
- result = str_list_copy(tctx, list);
+ result = (const char **) str_list_copy(tctx, list);
torture_assert(tctx, result, "str_list_copy() must not return NULL");
result = str_list_append(result, list2);
torture_assert(tctx, result, "str_list_append() must not return NULL");
@@ -432,7 +435,7 @@ static bool test_list_append(struct torture_context *tctx)
static bool test_list_append_const(struct torture_context *tctx)
{
- char **result;
+ const char **result;
const char *list[] = {
"element_0",
"element_1",
@@ -454,7 +457,7 @@ static bool test_list_append_const(struct torture_context *tctx)
"element_5",
NULL
};
- result = str_list_copy(tctx, list);
+ result = (const char **) str_list_copy(tctx, list);
torture_assert(tctx, result, "str_list_copy() must not return NULL");
result = str_list_append_const(result, list2);
torture_assert(tctx, result, "str_list_append_const() must not return NULL");
@@ -471,12 +474,12 @@ struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx)
for (i = 0; i < ARRAY_SIZE(test_lists_shell_strings); i++) {
torture_suite_add_simple_tcase_const(suite, "lists_shell",
- test_lists_shell, &test_lists_shell_strings[i]);
+ test_lists_shell, &test_lists_shell_strings[i]);
}
for (i = 0; i < ARRAY_SIZE(test_lists_strings); i++) {
- torture_suite_add_simple_tcase_const(suite, "lists",
- test_list_make, &test_lists_strings[i]);
+ torture_suite_add_simple_tcase_const(suite, "list_make",
+ test_list_make, &test_lists_strings[i]);
}
torture_suite_add_simple_test(suite, "list_copy", test_list_copy);
diff --git a/lib/util/util.h b/lib/util/util.h
index 159f812..e7ea0ba 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -477,7 +477,7 @@ _PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list);
/**
Return true if all the elements of the list match exactly.
*/
-_PUBLIC_ bool str_list_equal(const char **list1, const char **list2);
+_PUBLIC_ bool str_list_equal(const char * const *list1, const char * const *list2);
/**
add an entry to a string list
diff --git a/lib/util/util_strlist.c b/lib/util/util_strlist.c
index 8d69eef..71998b9 100644
--- a/lib/util/util_strlist.c
+++ b/lib/util/util_strlist.c
@@ -264,7 +264,8 @@ _PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list)
/**
Return true if all the elements of the list match exactly.
*/
-_PUBLIC_ bool str_list_equal(const char **list1, const char **list2)
+_PUBLIC_ bool str_list_equal(const char * const *list1,
+ const char * const *list2)
{
int i;
--
Samba Shared Repository
More information about the samba-cvs
mailing list