projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Fix for test case failure.
[m6w6/libmemcached]
/
libmemcached
/
hosts.cc
diff --git
a/libmemcached/hosts.cc
b/libmemcached/hosts.cc
index ac6b03ad0e810115d16e673f795805ec5cb7bb96..337a999aa91c2f397fac641c7a69eaf3fcd22db5 100644
(file)
--- a/
libmemcached/hosts.cc
+++ b/
libmemcached/hosts.cc
@@
-217,7
+217,7
@@
static memcached_return_t update_continuum(memcached_st *ptr)
if (is_ketama_weighted)
{
float pct= (float)list[host_index].weight / (float)total_weight;
if (is_ketama_weighted)
{
float pct= (float)list[host_index].weight / (float)total_weight;
- pointer_per_server= (uint32_t) ((floor((float) (pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001))) * 4);
+ pointer_per_server= (uint32_t) ((
::
floor((float) (pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001))) * 4);
pointer_per_hash= 4;
if (DEBUG)
{
pointer_per_hash= 4;
if (DEBUG)
{
@@
-236,21
+236,21
@@
static memcached_return_t update_continuum(memcached_st *ptr)
pointer_index < pointer_per_server / pointer_per_hash;
pointer_index++)
{
pointer_index < pointer_per_server / pointer_per_hash;
pointer_index++)
{
- char sort_host[
MEMCACHED_MAX_HOST_SORT_LENGTH
]= "";
+ char sort_host[
1 +MEMCACHED_NI_MAXHOST +1 +MEMCACHED_NI_MAXSERV +1 + MEMCACHED_NI_MAXSERV
]= "";
int sort_host_length;
// Spymemcached ketema key format is: hostname/ip:port-index
// If hostname is not available then: /ip:port-index
int sort_host_length;
// Spymemcached ketema key format is: hostname/ip:port-index
// If hostname is not available then: /ip:port-index
- sort_host_length= snprintf(sort_host,
MEMCACHED_MAX_HOST_SORT_LENGTH
,
+ sort_host_length= snprintf(sort_host,
sizeof(sort_host)
,
"/%s:%u-%u",
list[host_index].hostname,
(uint32_t)list[host_index].port,
pointer_index);
"/%s:%u-%u",
list[host_index].hostname,
(uint32_t)list[host_index].port,
pointer_index);
- if (s
ort_host_length >= MEMCACHED_MAX_HOST_SORT_LENGTH ||
sort_host_length < 0)
+ if (s
ize_t(sort_host_length) >= sizeof(sort_host) or
sort_host_length < 0)
{
return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT,
{
return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT,
- memcached_literal_param("snprintf(
MEMCACHED_DEFAULT_COMMAND_SIZE
)"));
+ memcached_literal_param("snprintf(
sizeof(sort_host)
)"));
}
if (DEBUG)
}
if (DEBUG)
@@
-281,29
+281,29
@@
static memcached_return_t update_continuum(memcached_st *ptr)
pointer_index <= pointer_per_server / pointer_per_hash;
pointer_index++)
{
pointer_index <= pointer_per_server / pointer_per_hash;
pointer_index++)
{
- char sort_host[MEMCACHED_
MAX_HOST_SORT_LENGTH
]= "";
+ char sort_host[MEMCACHED_
NI_MAXHOST +1 +MEMCACHED_NI_MAXSERV +1 +MEMCACHED_NI_MAXSERV
]= "";
int sort_host_length;
if (list[host_index].port == MEMCACHED_DEFAULT_PORT)
{
int sort_host_length;
if (list[host_index].port == MEMCACHED_DEFAULT_PORT)
{
- sort_host_length= snprintf(sort_host,
MEMCACHED_MAX_HOST_SORT_LENGTH
,
+ sort_host_length= snprintf(sort_host,
sizeof(sort_host)
,
"%s-%u",
list[host_index].hostname,
pointer_index - 1);
}
else
{
"%s-%u",
list[host_index].hostname,
pointer_index - 1);
}
else
{
- sort_host_length= snprintf(sort_host,
MEMCACHED_MAX_HOST_SORT_LENGTH
,
+ sort_host_length= snprintf(sort_host,
sizeof(sort_host)
,
"%s:%u-%u",
list[host_index].hostname,
(uint32_t)list[host_index].port,
pointer_index - 1);
}
"%s:%u-%u",
list[host_index].hostname,
(uint32_t)list[host_index].port,
pointer_index - 1);
}
- if (s
ort_host_length >= MEMCACHED_MAX_HOST_SORT_LENGTH ||
sort_host_length < 0)
+ if (s
ize_t(sort_host_length) >= sizeof(sort_host) or
sort_host_length < 0)
{
return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT,
{
return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT,
- memcached_literal_param("snprintf(
MEMCACHED_DEFAULT_COMMAND_SIZE
)"));
+ memcached_literal_param("snprintf(
sizeof(sort_host))
)"));
}
if (is_ketama_weighted)
}
if (is_ketama_weighted)