From: Trond Norbye Date: Wed, 14 Oct 2009 11:40:42 +0000 (+0200) Subject: Fix compile warnings generated by gcc 4.4.1 X-Git-Tag: 0.35~11^2~3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=f563b56dafe5e44f63f4771d923ca1de6e41159b;p=m6w6%2Flibmemcached Fix compile warnings generated by gcc 4.4.1 --- diff --git a/libmemcached/memcached_get.c b/libmemcached/memcached_get.c index 90cf456f..0a47f63d 100644 --- a/libmemcached/memcached_get.c +++ b/libmemcached/memcached_get.c @@ -296,7 +296,7 @@ memcached_return memcached_mget_execute(memcached_st *ptr, memcached_callback_st cb= { .callback= callback, .context= context, - .number_of_callback= 1 + .number_of_callback= number_of_callbacks }; ptr->callbacks= &cb; diff --git a/libmemcached/memcached_io.c b/libmemcached/memcached_io.c index 6e517144..693ce95c 100644 --- a/libmemcached/memcached_io.c +++ b/libmemcached/memcached_io.c @@ -18,15 +18,14 @@ static void increment_udp_message_id(memcached_server_st *ptr); static memcached_return io_wait(memcached_server_st *ptr, memc_read_or_write read_or_write) { - struct pollfd fds[1]= { - [0].fd= ptr->fd, - [0].events = POLLIN + struct pollfd fds= { + .fd= ptr->fd, + .events = POLLIN }; - short flags= 0; int error; unlikely (read_or_write == MEM_WRITE) /* write */ - fds[0].events= POLLOUT; + fds.events= POLLOUT; /* ** We are going to block on write, but at least on Solaris we might block @@ -47,7 +46,7 @@ static memcached_return io_wait(memcached_server_st *ptr, if ((ptr->root->flags & MEM_NO_BLOCK) == 0) timeout= -1; - error= poll(fds, 1, timeout); + error= poll(&fds, 1, timeout); if (error == 1) return MEMCACHED_SUCCESS; @@ -127,7 +126,7 @@ static bool process_input_buffer(memcached_server_st *ptr) &ptr->root->result); if (error == MEMCACHED_SUCCESS) { - for (int x= 0; x < cb.number_of_callback; x++) + for (unsigned int x= 0; x < cb.number_of_callback; x++) { error= (*cb.callback[x])(ptr->root, &ptr->root->result, cb.context); if (error != MEMCACHED_SUCCESS) diff --git a/tests/function.c b/tests/function.c index 13daaa29..3ff84249 100644 --- a/tests/function.c +++ b/tests/function.c @@ -1465,8 +1465,8 @@ static test_return_t mget_execute(memcached_st *memc) int max_keys= binary ? 20480 : 1; - char **keys= calloc(max_keys, sizeof(char*)); - size_t *key_length=calloc(max_keys, sizeof(size_t)); + char **keys= calloc((size_t)max_keys, sizeof(char*)); + size_t *key_length=calloc((size_t)max_keys, sizeof(size_t)); /* First add all of the items.. */ char blob[1024] = {0}; @@ -1474,7 +1474,7 @@ static test_return_t mget_execute(memcached_st *memc) for (int x= 0; x < max_keys; ++x) { char k[251]; - key_length[x]= snprintf(k, sizeof(k), "0200%u", x); + key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%u", x); keys[x]= strdup(k); assert(keys[x] != NULL); rc= memcached_add(memc, keys[x], key_length[x], blob, sizeof(blob), 0, 0); @@ -1486,7 +1486,7 @@ static test_return_t mget_execute(memcached_st *memc) memcached_execute_function callbacks[1]= { [0]= &callback_counter }; rc= memcached_mget_execute(memc, NULL, 0, (const char**)keys, key_length, - max_keys, callbacks, &counter, 1); + (size_t)max_keys, callbacks, &counter, 1); if (binary) { @@ -1496,7 +1496,7 @@ static test_return_t mget_execute(memcached_st *memc) assert(rc == MEMCACHED_END); /* Verify that we got all of the items */ - assert(counter == max_keys); + assert(counter == (unsigned int)max_keys); } else {