From dcc4f9ceee29ec101b2dcc4c662d7d768eda190a Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Mon, 13 Feb 2012 12:14:15 -0800 Subject: [PATCH] Just update to ptr for some loops. --- libmemcached/io.cc | 2 +- libmemcached/key.cc | 4 ++-- libmemcached/response.cc | 2 +- libmemcached/sasl.cc | 8 ++++---- tests/libmemcached-1.0/atomsmasher.cc | 15 +++++++-------- tests/libmemcached-1.0/ketama.cc | 4 ++-- tests/libmemcached-1.0/mem_functions.cc | 6 +++--- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/libmemcached/io.cc b/libmemcached/io.cc index 50fa77ae..48c0de6c 100644 --- a/libmemcached/io.cc +++ b/libmemcached/io.cc @@ -722,7 +722,7 @@ memcached_server_write_instance_st memcached_io_get_readable_server(memcached_st break; default: - for (size_t x= 0; x < host_index; ++x) + for (ptrdiff_t x= 0; x < host_index; ++x) { if (fds[x].revents & POLLIN) { diff --git a/libmemcached/key.cc b/libmemcached/key.cc index 39c1455b..19d1f957 100644 --- a/libmemcached/key.cc +++ b/libmemcached/key.cc @@ -51,7 +51,7 @@ memcached_return_t memcached_key_test(memcached_st &memc, // we just check the size of the key if (memc.flags.verify_key == false or memc.flags.binary_protocol == true) { - for (uint32_t x= 0; x < number_of_keys; x++) + for (size_t x= 0; x < number_of_keys; x++) { // We should set binary key, but the memcached server is broken for // longer keys at the moment. @@ -65,7 +65,7 @@ memcached_return_t memcached_key_test(memcached_st &memc, return MEMCACHED_SUCCESS; } - for (uint32_t x= 0; x < number_of_keys; x++) + for (size_t x= 0; x < number_of_keys; x++) { memcached_return_t rc= memcached_validate_key_length(*(key_length + x), false); if (memcached_failed(rc)) diff --git a/libmemcached/response.cc b/libmemcached/response.cc index 69ac26a4..511cf786 100644 --- a/libmemcached/response.cc +++ b/libmemcached/response.cc @@ -60,7 +60,7 @@ static memcached_return_t textual_value_fetch(memcached_server_write_instance_st char *key= result->item_key; result->key_length= 0; - for (size_t prefix_length= memcached_array_size(instance->root->_namespace); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++) + for (ptrdiff_t prefix_length= memcached_array_size(instance->root->_namespace); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++) { if (prefix_length == 0) { diff --git a/libmemcached/sasl.cc b/libmemcached/sasl.cc index ce61e318..40d37e3a 100644 --- a/libmemcached/sasl.cc +++ b/libmemcached/sasl.cc @@ -427,7 +427,7 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st * into the list, but if we don't know the ID we don't know how to handle * the context... */ - size_t total= 0; + ptrdiff_t total= 0; while (source->sasl.callbacks[total].id != SASL_CB_LIST_END) { @@ -453,7 +453,7 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st memcpy(callbacks, source->sasl.callbacks, (total + 1) * sizeof(sasl_callback_t)); /* Now update the context... */ - for (size_t x= 0; x < total; ++x) + for (ptrdiff_t x= 0; x < total; ++x) { if (callbacks[x].id == SASL_CB_USER || callbacks[x].id == SASL_CB_AUTHNAME) { @@ -462,7 +462,7 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st if (callbacks[x].context == NULL) { /* Failed to allocate memory, clean up previously allocated memory */ - for (size_t y= 0; y < x; ++y) + for (ptrdiff_t y= 0; y < x; ++y) { libmemcached_free(clone, clone->sasl.callbacks[y].context); } @@ -479,7 +479,7 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st if (n == NULL) { /* Failed to allocate memory, clean up previously allocated memory */ - for (size_t y= 0; y < x; ++y) + for (ptrdiff_t y= 0; y < x; ++y) { libmemcached_free(clone, clone->sasl.callbacks[y].context); } diff --git a/tests/libmemcached-1.0/atomsmasher.cc b/tests/libmemcached-1.0/atomsmasher.cc index bab25d03..fd3dc46e 100644 --- a/tests/libmemcached-1.0/atomsmasher.cc +++ b/tests/libmemcached-1.0/atomsmasher.cc @@ -59,7 +59,7 @@ static test_return_t generate_pairs(memcached_st *) global_pairs= pairs_generate(GLOBAL_COUNT, 400); global_count= GLOBAL_COUNT; - for (size_t x= 0; x < global_count; x++) + for (ptrdiff_t x= 0; x < global_count; x++) { global_keys[x]= global_pairs[x].key; global_keys_length[x]= global_pairs[x].key_length; @@ -71,7 +71,7 @@ static test_return_t generate_pairs(memcached_st *) static test_return_t drizzle(memcached_st *memc) { infinite: - for (size_t x= 0; x < TEST_COUNTER; x++) + for (ptrdiff_t x= 0; x < TEST_COUNTER; x++) { memcached_return_t rc; char *return_value; @@ -174,7 +174,7 @@ static test_return_t add_test(memcached_st *memc) static test_return_t many_adds(memcached_st *memc) { test_true(memc); - for (size_t x= 0; x < TEST_COUNTER; x++) + for (ptrdiff_t x= 0; x < TEST_COUNTER; x++) { test_compare_got(TEST_SUCCESS, add_test(memc), x); } @@ -203,7 +203,7 @@ static test_return_t memcached_create_benchmark(memcached_st *) { benchmark_state.create_init= true; - for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++) + for (ptrdiff_t x= 0; x < BENCHMARK_TEST_LOOP; x++) { memcached_st *ptr; ptr= memcached_create(&benchmark_state.create[x]); @@ -218,10 +218,9 @@ static test_return_t memcached_clone_benchmark(memcached_st *memc) { benchmark_state.clone_init= true; - for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++) + for (ptrdiff_t x= 0; x < BENCHMARK_TEST_LOOP; x++) { - memcached_st *ptr; - ptr= memcached_clone(&benchmark_state.clone[x], memc); + memcached_st *ptr= memcached_clone(&benchmark_state.clone[x], memc); test_true(ptr); } @@ -243,7 +242,7 @@ static test_return_t pre_allocate(memcached_st *) static test_return_t post_allocate(memcached_st *) { - for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++) + for (ptrdiff_t x= 0; x < BENCHMARK_TEST_LOOP; x++) { if (benchmark_state.create_init) { diff --git a/tests/libmemcached-1.0/ketama.cc b/tests/libmemcached-1.0/ketama.cc index 82237343..939236aa 100644 --- a/tests/libmemcached-1.0/ketama.cc +++ b/tests/libmemcached-1.0/ketama.cc @@ -207,7 +207,7 @@ test_return_t auto_eject_hosts(memcached_st *trash) /* This would not work if there were only two hosts. */ - for (size_t x= 0; x < 99; x++) + for (ptrdiff_t x= 0; x < 99; x++) { memcached_autoeject(memc); uint32_t server_idx= memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key)); @@ -219,7 +219,7 @@ test_return_t auto_eject_hosts(memcached_st *trash) memc->ketama.next_distribution_rebuild= time(NULL) - 1; memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, memc->distribution); - for (size_t x= 0; x < 99; x++) + for (ptrdiff_t x= 0; x < 99; x++) { uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key)); // We re-use instance from above. diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index 3707c6b3..7f8342da 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -721,7 +721,7 @@ test_return_t memcached_mget_mixed_memcached_get_TEST(memcached_st *memc) time_t(0), uint32_t(0))); } - for (size_t loop= 0; loop < 20; loop++) + for (ptrdiff_t loop= 0; loop < 20; loop++) { if (random() %2) { @@ -1989,7 +1989,7 @@ test_return_t key_teardown(memcached_st *) test_return_t block_add_regression(memcached_st *memc) { /* First add all of the items.. */ - for (size_t x= 0; x < REGRESSION_BINARY_VS_BLOCK_COUNT; ++x) + for (ptrdiff_t x= 0; x < REGRESSION_BINARY_VS_BLOCK_COUNT; ++x) { char blob[1024] = {0}; @@ -2701,7 +2701,7 @@ test_return_t user_supplied_bug14(memcached_st *memc) libtest::vchar_t value; value.reserve(18000); - for (size_t x= 0; x < 18000; x++) + for (ptrdiff_t x= 0; x < 18000; x++) { value.push_back((char) (x % 127)); } -- 2.30.2