uint32_t flags;
unsigned int fetch_key;
- fetch_key= random() % number_of;
+ fetch_key= (unsigned int)(random() % number_of);
value= memcached_get(memc, pairs[fetch_key].key, pairs[fetch_key].key_length,
&value_length, &flags, &rc);
memcached_server_push(memc, servers);
memcached_server_list_free(servers);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
+ (uint64_t)opt_binary);
while (optind < argc)
{
memcached_server_push(memc, servers);
memcached_server_list_free(servers);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
+ (uint64_t)opt_binary);
while (optind < argc)
{
ptr, opt_flags, (unsigned long long)opt_expires);
}
- if ((file_buffer_ptr= (char *)malloc(sizeof(char) * sbuf.st_size)) == NULL)
+ if ((file_buffer_ptr= (char *)malloc(sizeof(char) * (size_t)sbuf.st_size)) == NULL)
{
fprintf(stderr, "malloc: %s\n", strerror(errno));
exit(1);
}
- if ((read_length= read(fd, file_buffer_ptr, sbuf.st_size)) == -1)
+ if ((read_length= read(fd, file_buffer_ptr, (size_t)sbuf.st_size)) == -1)
{
fprintf(stderr, "read: %s\n", strerror(errno));
exit(1);
if (opt_method == OPT_ADD)
rc= memcached_add(memc, ptr, strlen(ptr),
- file_buffer_ptr, sbuf.st_size,
+ file_buffer_ptr, (size_t)sbuf.st_size,
opt_expires, opt_flags);
else if (opt_method == OPT_REPLACE)
rc= memcached_replace(memc, ptr, strlen(ptr),
- file_buffer_ptr, sbuf.st_size,
+ file_buffer_ptr, (size_t)sbuf.st_size,
opt_expires, opt_flags);
else
rc= memcached_set(memc, ptr, strlen(ptr),
- file_buffer_ptr, sbuf.st_size,
+ file_buffer_ptr, (size_t)sbuf.st_size,
opt_expires, opt_flags);
if (rc != MEMCACHED_SUCCESS)
memcached_server_push(memc, servers);
memcached_server_list_free(servers);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
+ (uint64_t)opt_binary);
rc= memcached_dump(memc, callbacks, NULL, 1);
servers= memcached_servers_parse(opt_servers);
memcached_server_push(memc, servers);
memcached_server_list_free(servers);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
+ (uint64_t) opt_binary);
rc = memcached_flush(memc, opt_expire);
if (rc != MEMCACHED_SUCCESS)
servers= memcached_servers_parse(opt_servers);
memcached_server_push(memc, servers);
memcached_server_list_free(servers);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
+ (uint64_t) opt_binary);
while (optind < argc)
{
memset(&conclusion, 0, sizeof(conclusions_st));
- srandom(time(NULL));
+ srandom((unsigned int)time(NULL));
options_parse(argc, argv);
if (!opt_servers)
/* We need to set udp behavior before adding servers to the client */
if (opt_udp_io)
{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, opt_udp_io);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP,
+ (uint64_t)opt_udp_io);
for(x= 0; x < servers[0].count; x++ )
servers[x].type= MEMCACHED_CONNECTION_UDP;
}
memcached_server_push(memc, servers);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
+ (uint64_t)opt_binary);
if (opt_flush)
flush_all(memc);
}
break;
case OPT_SLAP_CONCURRENCY:
- opt_concurrency= strtol(optarg, (char **)NULL, 10);
+ opt_concurrency= (unsigned int)strtoul(optarg, (char **)NULL, 10);
break;
case OPT_SLAP_EXECUTE_NUMBER:
- opt_execute_number= strtol(optarg, (char **)NULL, 10);
+ opt_execute_number= (unsigned int)strtoul(optarg, (char **)NULL, 10);
break;
case OPT_SLAP_INITIAL_LOAD:
- opt_createial_load= strtol(optarg, (char **)NULL, 10);
+ opt_createial_load= (unsigned int)strtoul(optarg, (char **)NULL, 10);
break;
case '?':
/* getopt_long already printed an error message. */
{
register int us, s;
- us = a.tv_usec - b.tv_usec;
+ us = (int)(a.tv_usec - b.tv_usec);
us /= 1000;
- s = a.tv_sec - b.tv_sec;
+ s = (int)(a.tv_sec - b.tv_sec);
s *= 1000;
return s + us;
}
AS_IF([test "$building_from_bzr" = "yes"],
[W_FAIL="-Werror"])
- BASE_WARNINGS="-pedantic -W -Wall -Wextra ${W_FAIL} -Wundef -Wshadow -Wmissing-declarations ${W_STRICT_ALIASING}"
- CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wswitch-default -Wswitch-enum -Wcast-align"
- CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wold-style-cast -Weffc++ -Wno-long-long"
+ BASE_WARNINGS="-pedantic -W -Wall -Wextra ${W_FAIL} -Wundef -Wshadow -Wmissing-declarations ${W_STRICT_ALIASING} -fdiagnostics-show-option"
+ CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wswitch-default -Wswitch-enum -Wcast-align -Wconversion"
+ CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wold-style-cast -Weffc++ -Wno-long-long -Wconversion"
+
+ AC_CACHE_CHECK([whether it is safe to use -Wconversion with htons],
+ [ac_cv_safe_to_use_Wconversion_],
+ [save_CFLAGS="$CFLAGS"
+ CFLAGS="${CC_WARNINGS} ${CFLAGS}"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
+#include <netinet/in.h>
+ ]],[[
+size_t source_port= 80;
+uint16_t x= htons((uint16_t)source_port);
+ ]])],
+ [ac_cv_safe_to_use_Wconversion_=yes],
+ [ac_cv_safe_to_use_Wconversion_=no])
+ CFLAGS="$save_CFLAGS"])
+
+ AS_IF([test "$ac_cv_safe_to_use_Wconversion_" = "no"],
+ [
+ NO_CONVERSION="-Wno-conversion"
+ ])
AC_CACHE_CHECK([whether it is safe to use -Wlogical-op],
CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${W_FAIL}"
fi
+AC_SUBST(NO_CONVERSION)
AC_SUBST(NO_REDUNDANT_DECLS)
AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${CPPFLAGS}"
lib_LTLIBRARIES = libmemcached.la
+libmemcached_la_CFLAGS= ${AM_CFLAGS} ${NO_CONVERSION}
libmemcached_la_SOURCES = crc.c \
memcached.c \
memcached_auto.c \
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
request.message.header.request.opcode= cmd;
- request.message.header.request.keylen= htons((uint16_t)key_length);
+ request.message.header.request.keylen= htons(key_length);
request.message.header.request.extlen= 20;
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
request.message.header.request.bodylen= htonl(key_length + request.message.header.request.extlen);
memcached_st *master;
memcached_st **mmc;
int firstfree;
- int size;
- int current_size;
+ uint32_t size;
+ uint32_t current_size;
};
static memcached_return mutex_enter(pthread_mutex_t *mutex)
noinst_HEADERS = test.h server.h ketama_test_cases.h
noinst_PROGRAMS = testapp testplus udptest atomsmasher startservers
+testapp_CFLAGS= ${AM_CFLAGS} ${NO_CONVERSION}
testapp_SOURCES = test.c function.c server.c ../clients/generator.c ../clients/execute.c
testapp_LDADD = $(LDADDS)
uint32_t test_bit;
uint8_t which;
- test_bit= random() % GLOBAL_COUNT;
- which= random() % 2;
+ test_bit= (uint32_t)(random() % GLOBAL_COUNT);
+ which= (uint8_t)(random() % 2);
if (which == 0)
{
for (x= 0; x < TEST_PORT_COUNT; x++)
{
- test_ports[x]= random() % 64000;
+ test_ports[x]= (uint32_t)random() % 64000;
rc= memcached_server_add_with_weight(local_memc, "localhost", test_ports[x], 0);
assert(local_memc->number_of_hosts == x + 1);
assert(local_memc->hosts[0].count == x+1);
for (x= 0; x < TEST_PORT_COUNT; x++)
{
- test_ports[x]= random() % 64000;
+ test_ports[x]= (uint32_t)(random() % 64000);
rc= memcached_server_add_with_weight(local_memc, "localhost", test_ports[x], 0);
assert(local_memc->number_of_hosts == x+1);
assert(local_memc->hosts[0].count == x+1);
{
unsigned int j= 0;
- size= (rand() % ( 5 * 1024 ) ) + 400;
+ size= (uint32_t)(rand() % ( 5 * 1024 ) ) + 400;
memset(randomstuff, 0, 6 * 1024);
assert(size < 6 * 1024); /* Being safe here */
for (j= 0 ; j < size ;j++)
- randomstuff[j] = (char) (rand() % 26) + 97;
+ randomstuff[j] = (signed char) ((rand() % 26) + 97);
total += size;
sprintf(key, "%d", x);
char insert_data[VALUE_SIZE_BUG5];
for (x= 0; x < VALUE_SIZE_BUG5; x++)
- insert_data[x]= rand();
+ insert_data[x]= (signed char)rand();
memcached_flush(memc, 0);
value= memcached_get(memc, keys[0], key_length[0],
char insert_data[VALUE_SIZE_BUG5];
for (x= 0; x < VALUE_SIZE_BUG5; x++)
- insert_data[x]= rand();
+ insert_data[x]= (signed char)rand();
memcached_flush(memc, 0);
value= memcached_get(memc, keys[0], key_length[0],
char insert_data[VALUE_SIZE_BUG5];
for (x= 0; x < VALUE_SIZE_BUG5; x++)
- insert_data[x]= rand();
+ insert_data[x]= (signed char)rand();
memcached_flush(memc, 0);
char *value;
size_t value_length= 512;
unsigned int x;
- int key_len= 3;
+ size_t key_len= 3;
memcached_return rc;
unsigned int set= 1;
memcached_st *mclone= memcached_clone(NULL, memc);
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_NO_BLOCK, set);
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_TCP_NODELAY, set);
timeout= 2;
- memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, timeout);
+ memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT,
+ (uint64_t)timeout);
value = (char*)malloc(value_length * sizeof(char));
char *value;
size_t value_length= 512;
unsigned int x;
- int key_len= 3;
+ size_t key_len= 3;
memcached_return rc;
unsigned int set= 1;
int32_t timeout;
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_NO_BLOCK, set);
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_TCP_NODELAY, set);
timeout= -1;
- memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, timeout);
+ memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT,
+ (size_t)timeout);
timeout= (int32_t)memcached_behavior_get(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT);
*/
static test_return user_supplied_bug14(memcached_st *memc)
{
- int setter= 1;
+ size_t setter= 1;
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, setter);
memcached_return rc;
char *key= "foo";
static test_return user_supplied_bug18(memcached_st *trash)
{
memcached_return rc;
- int value;
+ uint64_t value;
int x;
memcached_server_st *server_pool;
memcached_st *memc;
}
static test_return generate_buffer_data(memcached_st *memc)
{
- int latch= 0;
+ size_t latch= 0;
latch= 1;
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, latch);
static test_return delete_buffer_generate(memcached_st *memc)
{
- int latch= 0;
+ size_t latch= 0;
unsigned int x;
latch= 1;
static memcached_return poll_timeout(memcached_st *memc)
{
- int32_t timeout;
+ size_t timeout;
timeout= 100;
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, timeout);
- timeout= (int32_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT);
+ timeout= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT);
assert(timeout == 100);
for (int x=0; x < 100; ++x)
{
char key[10];
- size_t len= sprintf(key, "%d", x);
+ size_t len= (size_t)sprintf(key, "%d", x);
switch (count)
{
case 0:
*/
int no_msg=0;
for (uint32_t x=0; x < memc->number_of_hosts; ++x)
- no_msg+=memc->hosts[x].cursor_active;
+ no_msg+=(int)(memc->hosts[x].cursor_active);
assert(no_msg == 0);
assert(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS);
for (int x=0; x < 100; ++x)
{
char key[10];
- size_t len= sprintf(key, "%d", x);
+ size_t len= (size_t)sprintf(key, "%d", x);
size_t length;
uint32_t flags;
char* value=memcached_get(memc, key, strlen(key),
{
if (fgets(buffer, sizeof(buffer), fp) != NULL)
{
- pid_t pid = atol(buffer);
+ pid_t pid = (pid_t)atol(buffer);
if (pid != 0)
kill(pid, SIGTERM);
}
assert(construct->servers);
- srandom(time(NULL));
+ srandom((unsigned int)time(NULL));
for (x= 0; x < memcached_server_list_count(construct->servers); x++)
{
{
register int us, s;
- us = a.tv_usec - b.tv_usec;
+ us = (int)(a.tv_usec - b.tv_usec);
us /= 1000;
- s = a.tv_sec - b.tv_sec;
+ s = (int)(a.tv_sec - b.tv_sec);
s *= 1000;
return s + us;
}