static void calc_least_free_node(memcached_analysis_st *result,
const uint32_t server_num,
- const long max_allowed_bytes,
- const long used_bytes)
+ const uint64_t max_allowed_bytes,
+ const uint64_t used_bytes)
{
- uint64_t remaining_bytes= (uint64_t)max_allowed_bytes - used_bytes;
+ uint64_t remaining_bytes= max_allowed_bytes - used_bytes;
if (result->least_remaining_bytes == 0 ||
remaining_bytes < result->least_remaining_bytes)
const uint64_t total_bytes)
{
if (total_items > 0 && total_bytes > 0)
- result->average_item_size= total_bytes / total_items;
+ result->average_item_size= (uint32_t) (total_bytes / total_items);
}
static void calc_hit_ratio(memcached_analysis_st *result,
return;
}
- double temp= (double)total_get_hits/total_get_cmds;
+ double temp= (double) (total_get_hits/total_get_cmds);
result->pool_hit_ratio= temp * 100;
}
calc_largest_consumption(result, x, memc_stat[x].bytes);
calc_oldest_node(result, x, memc_stat[x].uptime);
calc_least_free_node(result, x,
- memc_stat[x].limit_maxbytes, memc_stat[x].bytes);
+ memc_stat[x].limit_maxbytes,
+ memc_stat[x].bytes);
total_get_hits+= memc_stat[x].get_hits;
total_get_cmds+= memc_stat[x].cmd_get;
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
request.message.header.request.opcode= cmd;
- request.message.header.request.keylen= htons(key_length);
+ request.message.header.request.keylen= htons((uint16_t) 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);
+ request.message.header.request.bodylen= htonl((uint32_t) (key_length + request.message.header.request.extlen));
request.message.body.delta= htonll(offset);
request.message.body.initial= htonll(initial);
- request.message.body.expiration= htonl(expiration);
+ request.message.body.expiration= htonl((uint32_t) expiration);
if ((memcached_do(&ptr->hosts[server_key], request.bytes,
sizeof(request.bytes), 0)!=MEMCACHED_SUCCESS) ||
ptr->number_of_replicas= (uint32_t)data;
break;
case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK:
- ptr->io_msg_watermark= (int32_t)data;
+ ptr->io_msg_watermark= (uint32_t) data;
break;
case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK:
- ptr->io_bytes_watermark= (int32_t)data;
+ ptr->io_bytes_watermark= (uint32_t)data;
break;
case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH:
- ptr->io_key_prefetch = (int32_t)data;
+ ptr->io_key_prefetch = (uint32_t)data;
break;
case MEMCACHED_BEHAVIOR_SND_TIMEOUT:
ptr->snd_timeout= (int32_t)data;
ptr->distribution= (memcached_server_distribution)(data);
if (ptr->distribution == MEMCACHED_DISTRIBUTION_RANDOM)
{
- srandom(time(NULL));
+ srandom((uint32_t) time(NULL));
}
run_distribution(ptr);
break;
case MEMCACHED_BEHAVIOR_DISTRIBUTION:
return ptr->distribution;
case MEMCACHED_BEHAVIOR_KETAMA:
- return (ptr->distribution == MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA) ? 1 : 0;
+ return (ptr->distribution == MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA) ? (uint64_t) 1 : 0;
case MEMCACHED_BEHAVIOR_HASH:
return ptr->hash;
case MEMCACHED_BEHAVIOR_KETAMA_HASH:
SO_SNDBUF, &sock_size, &sock_length))
return 0; /* Zero means error */
- return sock_size;
+ return (uint64_t) sock_size;
}
case MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE:
{
SO_RCVBUF, &sock_size, &sock_length))
return 0; /* Zero means error */
- return sock_size;
+ return (uint64_t) sock_size;
}
case MEMCACHED_BEHAVIOR_USER_DATA:
return MEMCACHED_FAILURE;
servAddr.sun_family= AF_UNIX;
strcpy(servAddr.sun_path, ptr->hostname); /* Copy filename */
- addrlen= strlen(servAddr.sun_path) + sizeof(servAddr.sun_family);
+ addrlen= (socklen_t) (strlen(servAddr.sun_path) + sizeof(servAddr.sun_family));
test_connect:
if (connect(ptr->fd,
unsigned int server_key,
const char *key,
size_t key_length,
- int flush);
+ uint8_t flush);
memcached_return memcached_delete_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
time_t expiration)
{
- char to_write;
+ uint8_t to_write;
size_t send_length;
memcached_return rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
return MEMCACHED_NO_SERVERS;
server_key= memcached_generate_hash(ptr, master_key, master_key_length);
- to_write= (ptr->flags & MEM_BUFFER_REQUESTS) ? 0 : 1;
+ to_write= (uint8_t) (ptr->flags & MEM_BUFFER_REQUESTS) ? 0 : 1;
bool no_reply= (ptr->flags & MEM_NOREPLY);
if (ptr->flags & MEM_BINARY_PROTOCOL)
else
{
if (expiration)
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "delete %s%.*s %u%s\r\n",
- ptr->prefix_key,
- (int)key_length, key,
- (uint32_t)expiration, no_reply ? " noreply" :"" );
+ send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
+ "delete %s%.*s %u%s\r\n",
+ ptr->prefix_key,
+ (int) key_length, key,
+ (uint32_t)expiration, no_reply ? " noreply" :"" );
else
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "delete %s%.*s%s\r\n",
- ptr->prefix_key,
- (int)key_length, key, no_reply ? " noreply" :"");
+ send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
+ "delete %s%.*s%s\r\n",
+ ptr->prefix_key,
+ (int)key_length, key, no_reply ? " noreply" :"");
if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
{
unsigned int server_key,
const char *key,
size_t key_length,
- int flush)
+ uint8_t flush)
{
protocol_binary_request_delete request= {.bytes= {0}};
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETE;
request.message.header.request.keylen= htons((uint16_t)key_length);
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
- request.message.header.request.bodylen= htonl(key_length);
+ request.message.header.request.bodylen= htonl((uint32_t) key_length);
if (ptr->flags & MEM_USE_UDP && !flush)
{
if ((memcached_do(&ptr->hosts[server_key], request.bytes,
sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) ||
(memcached_io_write(&ptr->hosts[server_key], key,
- key_length, flush) == -1))
+ key_length, (char) flush) == -1))
{
memcached_io_reset(&ptr->hosts[server_key]);
rc= MEMCACHED_WRITE_FAILURE;
memcached_server_st* server= &ptr->hosts[server_key];
if ((memcached_do(server, (const char*)request.bytes,
sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) ||
- (memcached_io_write(server, key, key_length, flush) == -1))
+ (memcached_io_write(server, key, key_length, (char) flush) == -1))
memcached_io_reset(server);
else
memcached_server_response_decrement(server);
if (ptr->type == MEMCACHED_CONNECTION_UDP && with_flush && ptr->write_buffer_offset > UDP_DATAGRAM_HEADER_LENGTH)
memcached_io_write(ptr, NULL, 0, 1);
- sent_length= memcached_io_write(ptr, command, command_length, with_flush);
+ sent_length= memcached_io_write(ptr, command, command_length, (char) with_flush);
if (sent_length == -1 || (size_t)sent_length != command_length)
rc= MEMCACHED_WRITE_FAILURE;
/* 256 I BELIEVE is the upper limit of slabs */
for (x= 0; x < 256; x++)
{
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "stats cachedump %u 0 0\r\n", x);
+ send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
+ "stats cachedump %u 0 0\r\n", x);
rc= memcached_do(&ptr->hosts[server_key], buffer, send_length, 1);
{
bool no_reply= (ptr->flags & MEM_NOREPLY);
if (expiration)
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "flush_all %llu%s\r\n",
- (unsigned long long)expiration, no_reply ? " noreply" : "");
+ send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
+ "flush_all %llu%s\r\n",
+ (unsigned long long)expiration, no_reply ? " noreply" : "");
else
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "flush_all%s\r\n", no_reply ? " noreply" : "");
+ send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
+ "flush_all%s\r\n", no_reply ? " noreply" : "");
rc= memcached_do(&ptr->hosts[x], buffer, send_length, 1);
request.message.header.request.extlen= 4;
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
request.message.header.request.bodylen= htonl(request.message.header.request.extlen);
- request.message.body.expiration= htonl(expiration);
+ request.message.body.expiration= htonl((uint32_t) expiration);
for (x= 0; x < ptr->number_of_hosts; x++)
{
{
if (rc == MEMCACHED_BUFFERED)
{
- uint8_t latch; /* We use latch to track the state of the original socket */
+ uint64_t latch; /* We use latch to track the state of the original socket */
latch= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS);
if (latch == 0)
memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
request.message.header.request.keylen= htons((uint16_t)key_length[x]);
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
- request.message.header.request.bodylen= htonl(key_length[x]);
+ request.message.header.request.bodylen= htonl((uint32_t) key_length[x]);
if ((memcached_io_write(&ptr->hosts[server_key], request.bytes,
sizeof(request.bytes), 0) == -1) ||
(memcached_io_write(&ptr->hosts[server_key], keys[x],
- key_length[x], flush) == -1))
+ key_length[x], (char) flush) == -1))
{
memcached_server_response_reset(&ptr->hosts[server_key]);
rc= MEMCACHED_SOME_ERRORS;
request.message.header.request.keylen= htons((uint16_t)key_length[x]);
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
- request.message.header.request.bodylen= htonl(key_length[x]);
+ request.message.header.request.bodylen= htonl((uint32_t) key_length[x]);
if ((memcached_io_write(&ptr->hosts[server], request.bytes,
sizeof(request.bytes), 0) == -1) ||
(memcached_io_write(&ptr->hosts[server], keys[x],
- key_length[x], flush) == -1))
+ key_length[x], (char) flush) == -1))
{
memcached_io_reset(&ptr->hosts[server]);
dead_servers[server]= true;
break;
case MEMCACHED_HASH_FNV1A_64:
{
- hash= FNV_64_INIT;
+ hash= (uint32_t) FNV_64_INIT;
for (x= 0; x < key_length; x++)
{
hash ^= key[x];
- hash *= FNV_64_PRIME;
+ hash *= (uint32_t) FNV_64_PRIME;
}
}
break;
case MEMCACHED_DISTRIBUTION_MODULA:
return hash % ptr->number_of_hosts;
case MEMCACHED_DISTRIBUTION_RANDOM:
- return random() % ptr->number_of_hosts;
+ return (uint32_t) random() % ptr->number_of_hosts;
default:
WATCHPOINT_ASSERT(0); /* We have added a distribution without extending the logic */
return hash % ptr->number_of_hosts;
static uint32_t internal_generate_hash(const char *key, size_t key_length)
{
const char *ptr= key;
- uint32_t value= 0;
+ int32_t value= 0;
while (key_length--)
{
- value += *ptr++;
+ value += (int32_t) *ptr++;
value += (value << 10);
value ^= (value >> 6);
}
value ^= (value >> 11);
value += (value << 15);
- return value == 0 ? 1 : value;
+ return value == 0 ? 1 : (uint32_t) value;
}
static uint32_t internal_generate_md5(const char *key, size_t key_length)
if (ptr->number_of_hosts)
{
qsort(ptr->hosts, ptr->number_of_hosts, sizeof(memcached_server_st), compare_servers);
- ptr->hosts[0].count= ptr->number_of_hosts;
+ ptr->hosts[0].count= (uint16_t) ptr->number_of_hosts;
}
}
uint32_t pointer_per_server= MEMCACHED_POINTS_PER_SERVER;
uint32_t pointer_per_hash= 1;
uint64_t total_weight= 0;
- uint32_t is_ketama_weighted= 0;
- uint32_t is_auto_ejecting= 0;
+ uint64_t is_ketama_weighted= 0;
+ uint64_t is_auto_ejecting= 0;
uint32_t points_per_server= 0;
uint32_t live_servers= 0;
struct timeval now;
live_servers= ptr->number_of_hosts;
is_ketama_weighted= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
- points_per_server= is_ketama_weighted ? MEMCACHED_POINTS_PER_SERVER_KETAMA : MEMCACHED_POINTS_PER_SERVER;
+ points_per_server= (uint32_t) (is_ketama_weighted ? MEMCACHED_POINTS_PER_SERVER_KETAMA : MEMCACHED_POINTS_PER_SERVER);
if (live_servers == 0)
return MEMCACHED_SUCCESS;
if (is_ketama_weighted)
{
float pct = (float)list[host_index].weight / (float)total_weight;
- pointer_per_server= floorf(pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001) * 4;
+ pointer_per_server= (uint32_t) ((floorf((float) (pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001))) * 4);
pointer_per_hash= 4;
#ifdef DEBUG
printf("ketama_weighted:%s|%d|%llu|%u\n",
if (list[host_index].port == MEMCACHED_DEFAULT_PORT)
{
- sort_host_length= snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
- "%s-%d",
- list[host_index].hostname,
- pointer_index - 1);
+ sort_host_length= (size_t) snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+ "%s-%d",
+ list[host_index].hostname,
+ pointer_index - 1);
}
else
{
- sort_host_length= snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
- "%s:%d-%d",
- list[host_index].hostname,
- list[host_index].port, pointer_index - 1);
+ sort_host_length= (size_t) snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+ "%s:%d-%d",
+ list[host_index].hostname,
+ list[host_index].port, pointer_index - 1);
}
WATCHPOINT_ASSERT(sort_host_length);
unsigned int i;
for (i = 0; i < pointer_per_hash; i++)
{
- value= ketama_server_hash(sort_host, sort_host_length, i);
+ value= ketama_server_hash(sort_host, (uint32_t) sort_host_length, (int) i);
ptr->continuum[continuum_index].index= host_index;
ptr->continuum[continuum_index++].value= value;
}
list[x].port, list[x].weight, list[x].type);
ptr->number_of_hosts++;
}
- ptr->hosts[0].count= ptr->number_of_hosts;
+ ptr->hosts[0].count= (uint16_t) ptr->number_of_hosts;
return run_distribution(ptr);
}
/* TODO: Check return type */
(void)memcached_server_create_with(ptr, &ptr->hosts[ptr->number_of_hosts], hostname, port, weight, type);
ptr->number_of_hosts++;
- ptr->hosts[0].count= ptr->number_of_hosts;
+ ptr->hosts[0].count= (uint16_t) ptr->number_of_hosts;
return run_distribution(ptr);
}
memcached_server_create_with(NULL, &new_host_list[count-1], hostname, port, weight, MEMCACHED_CONNECTION_TCP);
/* Backwards compatibility hack */
- new_host_list[0].count= count;
+ new_host_list[0].count= (uint16_t) count;
*error= MEMCACHED_SUCCESS;
return new_host_list;
}
ptr->io_bytes_sent = 0;
- ptr->read_data_length= data_read;
- ptr->read_buffer_length= data_read;
+ ptr->read_data_length= (size_t) data_read;
+ ptr->read_buffer_length= (size_t) data_read;
ptr->read_ptr= ptr->read_buffer;
}
}
ptr->server_failure_counter= 0;
- *nread = (size_t)(buffer_ptr - (char*)buffer);
+ *nread = (ssize_t)(buffer_ptr - (char*)buffer);
return MEMCACHED_SUCCESS;
}
return -1;
}
- return original_length;
+ return (ssize_t) original_length;
}
memcached_return memcached_io_close(memcached_server_st *ptr)
return -1;
}
- ptr->io_bytes_sent += sent_length;
+ ptr->io_bytes_sent += (uint32_t) sent_length;
local_write_ptr+= sent_length;
- write_length-= sent_length;
- return_length+= sent_length;
+ write_length-= (uint32_t) sent_length;
+ return_length+= (uint32_t) sent_length;
}
WATCHPOINT_ASSERT(write_length == 0);
else
ptr->write_buffer_offset= 0;
- return return_length;
+ return (ssize_t) return_length;
}
/*
if (rc != MEMCACHED_SUCCESS)
return rc;
- offset+= nread;
+ offset+= (size_t) nread;
}
return MEMCACHED_SUCCESS;
{
struct udp_datagram_header_st *header= (struct udp_datagram_header_st *)ptr->write_buffer;
uint16_t cur_req= get_udp_datagram_request_id(header);
- uint16_t msg_num= get_msg_num_from_request_id(cur_req);
- uint16_t thread_id= get_thread_id_from_request_id(cur_req);
+ int msg_num= get_msg_num_from_request_id(cur_req);
+ int thread_id= get_thread_id_from_request_id(cur_req);
if (((++msg_num) & UDP_REQUEST_ID_THREAD_MASK) != 0)
msg_num= 0;
- header->request_id= htons(thread_id | msg_num);
+ header->request_id= htons((uint16_t) (thread_id | msg_num));
}
memcached_return memcached_io_init_udp_header(memcached_server_st *ptr, uint16_t thread_id)
return MEMCACHED_FAILURE;
struct udp_datagram_header_st *header= (struct udp_datagram_header_st *)ptr->write_buffer;
- header->request_id= htons(generate_udp_request_thread_id(thread_id));
+ header->request_id= htons((uint16_t) (generate_udp_request_thread_id(thread_id)));
header->num_datagrams= htons(1);
header->sequence_number= htons(0);
memcached_server_st *memcached_servers_parse(const char *server_strings)
{
char *string;
- unsigned int port;
+ uint32_t port;
uint32_t weight;
const char *begin_ptr;
const char *end_ptr;
if (string)
{
- memcpy(buffer, begin_ptr, string - begin_ptr);
+ memcpy(buffer, begin_ptr, (size_t) (string - begin_ptr));
buffer[(unsigned int)(string - begin_ptr)]= 0;
begin_ptr= string+1;
}
ptr++;
- port= strtoul(ptr, (char **)NULL, 10);
+ port= (uint32_t) strtoul(ptr, (char **)NULL, 10);
ptr2= index(ptr, ' ');
if (! ptr2)
if (ptr2)
{
ptr2++;
- weight = strtoul(ptr2, (char **)NULL, 10);
+ weight = (uint32_t) strtoul(ptr2, (char **)NULL, 10);
}
}
* data to be sent from the server (the commands was in the output buffer
* and just flushed
*/
- long timeo= ptr->root->poll_timeout;
+ int32_t timeo= ptr->root->poll_timeout;
ptr->root->poll_timeout= 2000;
result_ptr= memcached_result_create(ptr->root, &result);
}
memcached_result_free(result_ptr);
- ptr->root->poll_timeout=timeo;
+ ptr->root->poll_timeout= timeo;
}
ptr->root->purging= 0;
memcached_io_close(ptr);
ptr->fd= -1;
- ptr->write_buffer_offset= (ptr->type == MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0 ;
+ ptr->write_buffer_offset= (size_t) ((ptr->type == MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0);
ptr->read_buffer_length= 0;
ptr->read_ptr= ptr->read_buffer;
memcached_server_response_reset(ptr);
if (end_ptr == string_ptr)
goto read_error;
for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++);
- result->flags= strtoul(next_ptr, &string_ptr, 10);
+ result->flags= (uint32_t) strtoul(next_ptr, &string_ptr, 10);
if (end_ptr == string_ptr)
goto read_error;
memory in the struct, which is important, for something that
rarely should happen?
*/
- rel_ptr= (char *)ptr->root->call_realloc(ptr->root, ptr->cached_server_error, endptr - startptr + 1);
+ rel_ptr= (char *)ptr->root->call_realloc(ptr->root,
+ ptr->cached_server_error,
+ (size_t) (endptr - startptr + 1));
if (rel_ptr == NULL)
{
}
ptr->cached_server_error= rel_ptr;
- memcpy(ptr->cached_server_error, startptr, endptr - startptr);
+ memcpy(ptr->cached_server_error, startptr, (size_t) (endptr - startptr));
ptr->cached_server_error[endptr - startptr]= 0;
return MEMCACHED_SERVER_ERROR;
}
size_t nr= (bodylen > SMALL_STRING_LEN) ? SMALL_STRING_LEN : bodylen;
if (memcached_safe_read(ptr, hole, nr) != MEMCACHED_SUCCESS)
return MEMCACHED_UNKNOWN_READ_FAILURE;
- bodylen -= nr;
+ bodylen-= (uint32_t) nr;
}
/* This might be an error from one of the quiet commands.. if
}
else if (!strcmp("pid", key))
{
- memc_stat->pid= strtol(value, (char **)NULL, 10);
+ memc_stat->pid= (uint32_t) strtol(value, (char **)NULL, 10);
}
else if (!strcmp("uptime", key))
{
- memc_stat->uptime= strtol(value, (char **)NULL, 10);
+ memc_stat->uptime= (uint32_t) strtol(value, (char **)NULL, 10);
}
else if (!strcmp("time", key))
{
- memc_stat->time= strtol(value, (char **)NULL, 10);
+ memc_stat->time= (uint32_t) strtol(value, (char **)NULL, 10);
}
else if (!strcmp("version", key))
{
}
else if (!strcmp("pointer_size", key))
{
- memc_stat->pointer_size= strtol(value, (char **)NULL, 10);
+ memc_stat->pointer_size= (uint32_t) strtol(value, (char **)NULL, 10);
}
else if (!strcmp("rusage_user", key))
{
for (walk_ptr= value; (!ispunct(*walk_ptr)); walk_ptr++);
*walk_ptr= 0;
walk_ptr++;
- memc_stat->rusage_user_seconds= strtol(value, (char **)NULL, 10);
- memc_stat->rusage_user_microseconds= strtol(walk_ptr, (char **)NULL, 10);
+ memc_stat->rusage_user_seconds= (uint32_t) strtol(value, (char **)NULL, 10);
+ memc_stat->rusage_user_microseconds= (uint32_t) strtol(walk_ptr, (char **)NULL, 10);
}
else if (!strcmp("rusage_system", key))
{
for (walk_ptr= value; (!ispunct(*walk_ptr)); walk_ptr++);
*walk_ptr= 0;
walk_ptr++;
- memc_stat->rusage_system_seconds= strtol(value, (char **)NULL, 10);
- memc_stat->rusage_system_microseconds= strtol(walk_ptr, (char **)NULL, 10);
+ memc_stat->rusage_system_seconds= (uint32_t) strtol(value, (char **)NULL, 10);
+ memc_stat->rusage_system_microseconds= (uint32_t) strtol(walk_ptr, (char **)NULL, 10);
}
else if (!strcmp("curr_items", key))
{
- memc_stat->curr_items= strtol(value, (char **)NULL, 10);
+ memc_stat->curr_items= (uint32_t) strtol(value, (char **)NULL, 10);
}
else if (!strcmp("total_items", key))
{
- memc_stat->total_items= strtol(value, (char **)NULL, 10);
+ memc_stat->total_items= (uint32_t) strtol(value, (char **)NULL, 10);
}
else if (!strcmp("bytes_read", key))
{
- memc_stat->bytes_read= strtoll(value, (char **)NULL, 10);
+ memc_stat->bytes_read= (uint32_t) strtoll(value, (char **)NULL, 10);
}
else if (!strcmp("bytes_written", key))
{
- memc_stat->bytes_written= strtoll(value, (char **)NULL, 10);
+ memc_stat->bytes_written= (uint32_t) strtoll(value, (char **)NULL, 10);
}
else if (!strcmp("bytes", key))
{
- memc_stat->bytes= strtoll(value, (char **)NULL, 10);
+ memc_stat->bytes= (uint32_t) strtoll(value, (char **)NULL, 10);
}
else if (!strcmp("curr_connections", key))
{
- memc_stat->curr_connections= strtoll(value, (char **)NULL, 10);
+ memc_stat->curr_connections= (uint32_t) strtoll(value, (char **)NULL, 10);
}
else if (!strcmp("total_connections", key))
{
- memc_stat->total_connections= strtoll(value, (char **)NULL, 10);
+ memc_stat->total_connections= (uint32_t) strtoll(value, (char **)NULL, 10);
}
else if (!strcmp("connection_structures", key))
{
- memc_stat->connection_structures= strtol(value, (char **)NULL, 10);
+ memc_stat->connection_structures= (uint32_t) strtol(value, (char **)NULL, 10);
}
else if (!strcmp("cmd_get", key))
{
- memc_stat->cmd_get= strtoll(value, (char **)NULL, 10);
+ memc_stat->cmd_get= (uint64_t) strtoll(value, (char **)NULL, 10);
}
else if (!strcmp("cmd_set", key))
{
- memc_stat->cmd_set= strtoll(value, (char **)NULL, 10);
+ memc_stat->cmd_set= (uint64_t) strtoll(value, (char **)NULL, 10);
}
else if (!strcmp("get_hits", key))
{
- memc_stat->get_hits= strtoll(value, (char **)NULL, 10);
+ memc_stat->get_hits= (uint64_t) strtoll(value, (char **)NULL, 10);
}
else if (!strcmp("get_misses", key))
{
}
else if (!strcmp("limit_maxbytes", key))
{
- memc_stat->limit_maxbytes= strtoll(value, (char **)NULL, 10);
+ memc_stat->limit_maxbytes= (uint64_t) strtoll(value, (char **)NULL, 10);
}
else if (!strcmp("threads", key))
{
- memc_stat->threads= strtol(value, (char **)NULL, 10);
+ memc_stat->threads= (uint32_t) strtol(value, (char **)NULL, 10);
}
else if (!(strcmp("delete_misses", key) == 0 ||/* New stats in the 1.3 beta */
strcmp("delete_hits", key) == 0 ||/* Just swallow them for now.. */
const char *key, memcached_return *error)
{
char buffer[SMALL_STRING_LEN];
- size_t length;
+ int length;
char *ret;
*error= MEMCACHED_SUCCESS;
return NULL;
}
- ret= ptr->call_malloc(ptr, length + 1);
- memcpy(ret, buffer, length);
+ ret= ptr->call_malloc(ptr, (size_t) (length + 1));
+ memcpy(ret, buffer, (size_t) length);
ret[length]= '\0';
return ret;
if (args != NULL)
{
- int len= strlen(args);
+ size_t len= strlen(args);
rc= memcached_validate_key_length(len, true);
unlikely (rc != MEMCACHED_SUCCESS)
return rc;
request.message.header.request.keylen= htons((uint16_t)len);
- request.message.header.request.bodylen= htonl(len);
+ request.message.header.request.bodylen= htonl((uint32_t) len);
if ((memcached_do(&ptr->hosts[server_key], request.bytes,
sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) ||
size_t send_length;
if (args)
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "stats %s\r\n", args);
+ send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
+ "stats %s\r\n", args);
else
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "stats\r\n");
+ send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
+ "stats\r\n");
if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
return MEMCACHED_WRITE_FAILURE;
server_key= memcached_generate_hash(ptr, master_key, master_key_length);
if (cas)
- write_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "%s %s%.*s %u %llu %zu %llu%s\r\n",
- storage_op_string(verb),
- ptr->prefix_key,
- (int)key_length, key, flags,
- (unsigned long long)expiration, value_length,
- (unsigned long long)cas,
- (ptr->flags & MEM_NOREPLY) ? " noreply" : "");
+ write_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
+ "%s %s%.*s %u %llu %zu %llu%s\r\n",
+ storage_op_string(verb),
+ ptr->prefix_key,
+ (int)key_length, key, flags,
+ (unsigned long long)expiration, value_length,
+ (unsigned long long)cas,
+ (ptr->flags & MEM_NOREPLY) ? " noreply" : "");
else
{
char *buffer_ptr= buffer;
buffer_ptr++;
write_length= (size_t)(buffer_ptr - buffer);
- write_length+= snprintf(buffer_ptr, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "%u %llu %zu%s\r\n",
- flags,
- (unsigned long long)expiration, value_length,
- (ptr->flags & MEM_NOREPLY) ? " noreply" : "");
+ write_length+= (size_t) snprintf(buffer_ptr, MEMCACHED_DEFAULT_COMMAND_SIZE,
+ "%u %llu %zu%s\r\n",
+ flags,
+ (unsigned long long)expiration, value_length,
+ (ptr->flags & MEM_NOREPLY) ? " noreply" : "");
}
if (ptr->flags & MEM_USE_UDP && ptr->flags & MEM_BUFFER_REQUESTS)
uint64_t cas,
memcached_storage_action verb)
{
- char flush;
+ uint8_t flush;
protocol_binary_request_set request= {.bytes= {0}};
size_t send_length= sizeof(request.bytes);
uint32_t server_key= memcached_generate_hash(ptr, master_key,
request.message.body.expiration= htonl((uint32_t)expiration);
}
- request.message.header.request.bodylen= htonl(key_length + value_length +
- request.message.header.request.extlen);
+ request.message.header.request.bodylen= htonl((uint32_t) (key_length + value_length +
+ request.message.header.request.extlen));
if (cas)
request.message.header.request.cas= htonll(cas);
- flush= ((server->root->flags & MEM_BUFFER_REQUESTS) && verb == SET_OP) ? 0 : 1;
+ flush= (uint8_t) (((server->root->flags & MEM_BUFFER_REQUESTS) && verb == SET_OP) ? 0 : 1);
if ((server->root->flags & MEM_USE_UDP) && !flush)
{
/* write the header */
if ((memcached_do(server, (const char*)request.bytes, send_length, 0) != MEMCACHED_SUCCESS) ||
(memcached_io_write(server, key, key_length, 0) == -1) ||
- (memcached_io_write(server, value, value_length, flush) == -1))
+ (memcached_io_write(server, value, value_length, (char) flush) == -1))
{
memcached_io_reset(server);
return MEMCACHED_WRITE_FAILURE;
if ((memcached_do(srv, (const char*)request.bytes,
send_length, 0) != MEMCACHED_SUCCESS) ||
(memcached_io_write(srv, key, key_length, 0) == -1) ||
- (memcached_io_write(srv, value, value_length, flush) == -1))
+ (memcached_io_write(srv, value, value_length, (char) flush) == -1))
memcached_io_reset(srv);
else
memcached_server_response_decrement(srv);
{
if (need && need > (size_t)(string->current_size - (size_t)(string->end - string->string)))
{
- size_t current_offset= string->end - string->string;
+ size_t current_offset= (size_t) (string->end - string->string);
char *new_value;
size_t adjust;
size_t new_size;
memcached_return rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "verbosity %u\r\n", verbosity);
+ send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
+ "verbosity %u\r\n", verbosity);
unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
return MEMCACHED_WRITE_FAILURE;
*/
const unsigned int m= 0x5bd1e995;
- const unsigned int seed= (0xdeadbeef * length);
+ const size_t seed= (0xdeadbeef * length);
const int r= 24;
// Initialize the hash to a 'random' value
- unsigned int h= seed ^ length;
+ size_t h= seed ^ length;
// Mix 4 bytes at a time into the hash
h *= m;
h ^= h >> 15;
- return h;
+ return (uint32_t) h;
}