diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2012-03-22 10:47:27 +1030 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-03-22 03:29:32 +0100 |
commit | 4816ffacb81d3234231730149c7b0629bb3646a4 (patch) | |
tree | f4c58312dfe25b31dd1a049a07a77b8c40503b64 /lib/tdb2/test | |
parent | 4ea9f8d4c0d08343910d85f44eebdd2d7bff6571 (diff) | |
download | samba-4816ffacb81d3234231730149c7b0629bb3646a4.tar.gz samba-4816ffacb81d3234231730149c7b0629bb3646a4.tar.bz2 samba-4816ffacb81d3234231730149c7b0629bb3646a4.zip |
lib/tdb2: fix -Wcast-qual warnings.
We use tdb_mkdata() to get rid of many of them from the tests, and
explicit cast_const() in a few places.
tlist_for_each() still causes a warning, but that needs to be fixed in
CCAN.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Thu Mar 22 03:29:32 CET 2012 on sn-devel-104
Diffstat (limited to 'lib/tdb2/test')
-rw-r--r-- | lib/tdb2/test/run-tdb1-3G-file.c | 6 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-check.c | 6 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-corrupt.c | 5 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-endian.c | 9 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-incompatible.c | 12 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-nested-transactions.c | 6 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-nested-traverse.c | 6 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-no-lock-during-traverse.c | 3 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-readonly-check.c | 6 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-traverse-in-transaction.c | 6 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-wronghash-fail.c | 3 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-zero-append.c | 6 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1.c | 6 | ||||
-rw-r--r-- | lib/tdb2/test/tdb1-external-agent.c | 3 |
14 files changed, 28 insertions, 55 deletions
diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c index 148611753f..c6e3042722 100644 --- a/lib/tdb2/test/run-tdb1-3G-file.c +++ b/lib/tdb2/test/run-tdb1-3G-file.c @@ -76,10 +76,8 @@ int main(int argc, char *argv[]) ok1(tdb); tdb->tdb1.io = &large_io_methods; - key.dsize = strlen("hi"); - key.dptr = (void *)"hi"; - orig_data.dsize = strlen("world"); - orig_data.dptr = (void *)"world"; + key = tdb_mkdata("hi", strlen("hi")); + orig_data = tdb_mkdata("world", strlen("world")); /* Enlarge the file (internally multiplies by 2). */ ret = tdb1_expand(tdb, 1500000000); diff --git a/lib/tdb2/test/run-tdb1-check.c b/lib/tdb2/test/run-tdb1-check.c index b8f0889b35..98295d73d3 100644 --- a/lib/tdb2/test/run-tdb1-check.c +++ b/lib/tdb2/test/run-tdb1-check.c @@ -21,10 +21,8 @@ int main(int argc, char *argv[]) ok1(tdb); ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - key.dsize = strlen("hi"); - key.dptr = (void *)"hi"; - data.dsize = strlen("world"); - data.dptr = (void *)"world"; + key = tdb_mkdata("hi", strlen("hi")); + data = tdb_mkdata("world", strlen("world")); ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); diff --git a/lib/tdb2/test/run-tdb1-corrupt.c b/lib/tdb2/test/run-tdb1-corrupt.c index 6403acb1ea..d46570f63b 100644 --- a/lib/tdb2/test/run-tdb1-corrupt.c +++ b/lib/tdb2/test/run-tdb1-corrupt.c @@ -47,9 +47,8 @@ static void check_test(struct tdb_context *tdb) ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); - key.dptr = (void *)"hello"; - data.dsize = strlen("world"); - data.dptr = (void *)"world"; + key = tdb_mkdata("hello", strlen("hello")); + data = tdb_mkdata("world", strlen("world")); /* Key and data size respectively. */ dsize = ksize = 0; diff --git a/lib/tdb2/test/run-tdb1-endian.c b/lib/tdb2/test/run-tdb1-endian.c index a31908009c..c72209fcbf 100644 --- a/lib/tdb2/test/run-tdb1-endian.c +++ b/lib/tdb2/test/run-tdb1-endian.c @@ -20,10 +20,8 @@ int main(int argc, char *argv[]) O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); ok1(tdb); - key.dsize = strlen("hi"); - key.dptr = (void *)"hi"; - data.dsize = strlen("world"); - data.dptr = (void *)"world"; + key = tdb_mkdata("hi", strlen("hi")); + data = tdb_mkdata("world", strlen("world")); ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_NOEXIST); ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); @@ -44,8 +42,7 @@ int main(int argc, char *argv[]) tdb = tdb_open("run-endian.tdb1", 0, O_RDWR, 0, NULL); ok1(tdb); - key.dsize = strlen("hi"); - key.dptr = (void *)"hi"; + key = tdb_mkdata("hi", strlen("hi")); ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); ok1(data.dsize == strlen("world")); ok1(memcmp(data.dptr, "world", strlen("world")) == 0); diff --git a/lib/tdb2/test/run-tdb1-incompatible.c b/lib/tdb2/test/run-tdb1-incompatible.c index 84acf1bccd..e478900533 100644 --- a/lib/tdb2/test/run-tdb1-incompatible.c +++ b/lib/tdb2/test/run-tdb1-incompatible.c @@ -87,8 +87,7 @@ int main(int argc, char *argv[]) O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr); ok1(tdb); ok1(log_count == 0); - d.dptr = (void *)"Hello"; - d.dsize = 5; + d = tdb_mkdata("Hello", strlen("Hello")); ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS); tdb_close(tdb); @@ -132,8 +131,7 @@ int main(int argc, char *argv[]) &incompat_hash_attr); ok1(tdb); ok1(log_count == 0); - d.dptr = (void *)"Hello"; - d.dsize = 5; + d = tdb_mkdata("Hello", strlen("Hello")); ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS); tdb_close(tdb); @@ -165,8 +163,7 @@ int main(int argc, char *argv[]) O_RDWR, 0600, &log_attr); ok1(tdb); ok1(log_count == 0); - d.dptr = (void *)"Hello"; - d.dsize = 5; + d = tdb_mkdata("Hello", strlen("Hello")); ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS); ok1(d.dsize == 5); free(d.dptr); @@ -181,8 +178,7 @@ int main(int argc, char *argv[]) O_CREAT|O_RDWR|O_TRUNC, 0600, &dumbhash_attr); ok1(tdb); ok1(log_count == 0); - d.dptr = (void *)"Hello"; - d.dsize = 5; + d = tdb_mkdata("Hello", strlen("Hello")); ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS); tdb_close(tdb); diff --git a/lib/tdb2/test/run-tdb1-nested-transactions.c b/lib/tdb2/test/run-tdb1-nested-transactions.c index 23ab740d9f..665f28bcef 100644 --- a/lib/tdb2/test/run-tdb1-nested-transactions.c +++ b/lib/tdb2/test/run-tdb1-nested-transactions.c @@ -16,8 +16,7 @@ int main(int argc, char *argv[]) hsize.tdb1_hashsize.hsize = 1024; plan_tests(30); - key.dsize = strlen("hi"); - key.dptr = (void *)"hi"; + key = tdb_mkdata("hi", strlen("hi")); tdb = tdb_open("run-nested-transactions.tdb1", TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); @@ -25,8 +24,7 @@ int main(int argc, char *argv[]) /* No nesting by default. */ ok1(tdb_transaction_start(tdb) == TDB_SUCCESS); - data.dptr = (void *)"world"; - data.dsize = strlen("world"); + data = tdb_mkdata("world", strlen("world")); ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS); ok1(data.dsize == strlen("world")); diff --git a/lib/tdb2/test/run-tdb1-nested-traverse.c b/lib/tdb2/test/run-tdb1-nested-traverse.c index 8fa36bd88a..76bec5a176 100644 --- a/lib/tdb2/test/run-tdb1-nested-traverse.c +++ b/lib/tdb2/test/run-tdb1-nested-traverse.c @@ -71,10 +71,8 @@ int main(int argc, char *argv[]) ok1(external_agent_operation1(agent, TRANSACTION_COMMIT, tdb->name) == SUCCESS); - key.dsize = strlen("hi"); - key.dptr = (void *)"hi"; - data.dptr = (void *)"world"; - data.dsize = strlen("world"); + key = tdb_mkdata("hi", strlen("hi")); + data = tdb_mkdata("world", strlen("world")); ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); tdb_traverse(tdb, traverse1, NULL); diff --git a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c index 7392d14875..127e69ad1c 100644 --- a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c +++ b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c @@ -22,8 +22,7 @@ static bool prepare_entries(struct tdb_context *tdb) for (i = 0; i < NUM_ENTRIES; i++) { key.dsize = sizeof(i); key.dptr = (void *)&i; - data.dsize = strlen("world"); - data.dptr = (void *)"world"; + data = tdb_mkdata("world", strlen("world")); if (tdb_store(tdb, key, data, 0) != TDB_SUCCESS) return false; diff --git a/lib/tdb2/test/run-tdb1-readonly-check.c b/lib/tdb2/test/run-tdb1-readonly-check.c index c15c06ab92..cd39647fc5 100644 --- a/lib/tdb2/test/run-tdb1-readonly-check.c +++ b/lib/tdb2/test/run-tdb1-readonly-check.c @@ -22,10 +22,8 @@ int main(int argc, char *argv[]) O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); ok1(tdb); - key.dsize = strlen("hi"); - key.dptr = (void *)"hi"; - data.dsize = strlen("world"); - data.dptr = (void *)"world"; + key = tdb_mkdata("hi", strlen("hi")); + data = tdb_mkdata("world", strlen("world")); ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); diff --git a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c index 7732d54cf7..318ec10288 100644 --- a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c +++ b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c @@ -52,10 +52,8 @@ int main(int argc, char *argv[]) 0600, &hsize); ok1(tdb); - key.dsize = strlen("hi"); - key.dptr = (void *)"hi"; - data.dptr = (void *)"world"; - data.dsize = strlen("world"); + key = tdb_mkdata("hi", strlen("hi")); + data = tdb_mkdata("world", strlen("world")); ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); diff --git a/lib/tdb2/test/run-tdb1-wronghash-fail.c b/lib/tdb2/test/run-tdb1-wronghash-fail.c index 19f926c787..6a9dae3a70 100644 --- a/lib/tdb2/test/run-tdb1-wronghash-fail.c +++ b/lib/tdb2/test/run-tdb1-wronghash-fail.c @@ -58,8 +58,7 @@ int main(int argc, char *argv[]) O_CREAT|O_RDWR|O_TRUNC, 0600, &log_attr); ok1(tdb); ok1(log_count == 0); - d.dptr = (void *)"Hello"; - d.dsize = 5; + d = tdb_mkdata("Hello", strlen("Hello")); ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS); tdb_close(tdb); diff --git a/lib/tdb2/test/run-tdb1-zero-append.c b/lib/tdb2/test/run-tdb1-zero-append.c index 16a097ce30..b5e55c0222 100644 --- a/lib/tdb2/test/run-tdb1-zero-append.c +++ b/lib/tdb2/test/run-tdb1-zero-append.c @@ -20,10 +20,8 @@ int main(int argc, char *argv[]) ok1(tdb); /* Tickle bug on appending zero length buffer to zero length buffer. */ - key.dsize = strlen("hi"); - key.dptr = (void *)"hi"; - data.dptr = (void *)"world"; - data.dsize = 0; + key = tdb_mkdata("hi", strlen("hi")); + data = tdb_mkdata("world", 0); ok1(tdb_append(tdb, key, data) == TDB_SUCCESS); ok1(tdb_append(tdb, key, data) == TDB_SUCCESS); diff --git a/lib/tdb2/test/run-tdb1.c b/lib/tdb2/test/run-tdb1.c index eebdcdb212..4769a5f6d8 100644 --- a/lib/tdb2/test/run-tdb1.c +++ b/lib/tdb2/test/run-tdb1.c @@ -19,10 +19,8 @@ int main(int argc, char *argv[]) O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); ok1(tdb); - key.dsize = strlen("hi"); - key.dptr = (void *)"hi"; - data.dsize = strlen("world"); - data.dptr = (void *)"world"; + key = tdb_mkdata("hi", strlen("hi")); + data = tdb_mkdata("world", strlen("world")); ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_NOEXIST); ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); diff --git a/lib/tdb2/test/tdb1-external-agent.c b/lib/tdb2/test/tdb1-external-agent.c index dff7012a40..2ba05741fc 100644 --- a/lib/tdb2/test/tdb1-external-agent.c +++ b/lib/tdb2/test/tdb1-external-agent.c @@ -28,8 +28,7 @@ static enum agent_return do_operation(enum operation op, const char *name) return OTHER_FAILURE; } - k.dptr = (void *)name; - k.dsize = strlen(name); + k = tdb_mkdata(name, strlen(name)); locking_would_block1 = 0; switch (op) { |