Permalink
Browse files

fixes tons of warnings produced on GNU/Linux

Change-Id: I4ffc7f259540ccc1e6c0c1410595f808c76c72b9
Reviewed-on: http://review.northscale.com/1566
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information...
1 parent 288e6ba commit e1ae2ef8a8569d47e56bb2359a56bc08915574c2 Aliaksey Kandratsenka committed with steveyen Aug 4, 2010
Showing with 458 additions and 358 deletions.
  1. +14 −12 agent_config.c
  2. +6 −2 agent_ping.c
  3. +87 −69 agent_stats.c
  4. +1 −0 assoc.c
  5. +1 −0 cache.c
  6. +29 −21 cproxy.c
  7. +5 −0 cproxy_config.c
  8. +6 −2 cproxy_front.c
  9. +2 −0 cproxy_multiget.c
  10. +4 −2 cproxy_protocol_a2a.c
  11. +9 −5 cproxy_protocol_a2b.c
  12. +1 −1 cproxy_protocol_b.c
  13. +1 −0 cproxy_protocol_b2b.c
  14. +6 −0 cproxy_stats.c
  15. +6 −4 genhash.c
  16. +2 −2 hash.c
  17. +5 −3 items.c
  18. +62 −62 log.c
  19. +8 −1 mcs.c
  20. +29 −23 memcached.c
  21. +1 −1 sizes.c
  22. +4 −3 slabs.c
  23. +1 −0 stdin_check.c
  24. +2 −0 t/moxi_all.pl
  25. +59 −47 testapp.c
  26. +100 −98 thread.c
  27. +5 −0 util.h
  28. +2 −0 work.c
View
@@ -43,17 +43,13 @@ static void cproxy_init_null_bucket(proxy_main *m);
static void cproxy_on_config(void *data0, void *data1);
-static bool cproxy_on_config_json_one(proxy_main *m, uint32_t new_config_ver,
- char *config, char *name);
-
-static
-bool cproxy_on_config_json_buckets(proxy_main *m, uint32_t new_config_ver,
- cJSON *jBuckets, bool want_default);
-
static void agent_logger(void *userdata,
enum conflate_log_level lvl,
const char *msg, ...)
{
+ (void)userdata;
+ (void)lvl;
+ (void)msg;
// Issues compiling vfprintf(), so turn off this unused code path for now.
#undef AGENT_LOGGER
#ifdef AGENT_LOGGER
@@ -372,6 +368,12 @@ void on_conflate_new_config(void *userdata, kvpair_t *config) {
#ifdef MOXI_USE_VBUCKET
+static bool cproxy_on_config_json_one(proxy_main *m, uint32_t new_config_ver,
+ char *config, char *name);
+
+static bool cproxy_on_config_json_buckets(proxy_main *m, uint32_t new_config_ver,
+ cJSON *jBuckets, bool want_default);
+
static
bool cproxy_on_config_json(proxy_main *m, uint32_t new_config_ver, char *config) {
bool rv = false;
@@ -971,7 +973,7 @@ void cproxy_on_config_pool(proxy_main *m,
}
bool changed = false;
- bool shutdown = false;
+ bool shutdown_flag = false;
pthread_mutex_lock(&m->proxy_main_lock);
@@ -1018,7 +1020,7 @@ void cproxy_on_config_pool(proxy_main *m,
m->stat_proxy_existings++;
} else {
m->stat_proxy_shutdowns++;
- shutdown = true;
+ shutdown_flag = true;
}
assert(config_ver != p->config_ver);
@@ -1030,12 +1032,12 @@ void cproxy_on_config_pool(proxy_main *m,
if (settings.verbose > 2) {
moxi_log_write("conp changed %s, shutdown %s\n",
changed ? "true" : "false",
- shutdown ? "true" : "false");
+ shutdown_flag ? "true" : "false");
}
// Restart the front_cache, if necessary.
//
- if (shutdown == false) {
+ if (shutdown_flag == false) {
if (behavior_pool->base.front_cache_max > 0 &&
behavior_pool->base.front_cache_lifespan > 0) {
mcache_start(&p->front_cache,
@@ -1060,7 +1062,7 @@ void cproxy_on_config_pool(proxy_main *m,
// Send update across worker threads, avoiding locks.
//
- work_collect wc = {0};
+ work_collect wc = {.count = 0};
work_collect_init(&wc, m->nthreads - 1, NULL);
for (int i = 1; i < m->nthreads; i++) {
View
@@ -77,7 +77,11 @@ enum conflate_mgmt_cb_result on_conflate_ping_test(void *userdata,
bool direct,
kvpair_t *form,
conflate_form_result *r)
- {
+{
+ (void)userdata;
+ (void)handle;
+ (void)cmd;
+ (void)direct;
assert(userdata);
// The form key-multivalues looks roughly like...
@@ -304,7 +308,7 @@ static void ping_server(char *server_name,
if (connected) {
for (int j = 0; recipes[j].name; j++) {
- struct moxi_stats recipe_stats = { 0.0 };
+ struct moxi_stats recipe_stats = { .min = 0.0 };
int failures = 0;
perform_ping_test(recipes[j], &mst,
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -183,6 +183,7 @@ static volatile int do_run_maintenance_thread = 1;
int hash_bulk_move = DEFAULT_HASH_BULK_MOVE;
static void *assoc_maintenance_thread(void *arg) {
+ (void)arg;
while (do_run_maintenance_thread) {
int ii = 0;
View
@@ -19,6 +19,7 @@ const int initial_pool_size = 64;
cache_t* cache_create(const char *name, size_t bufsize, size_t align,
cache_constructor_t* constructor,
cache_destructor_t* destructor) {
+ (void)align;
cache_t* ret = calloc(1, sizeof(cache_t));
char* nm = strdup(name);
void** ptr = calloc(initial_pool_size, bufsize);
View
@@ -265,10 +265,10 @@ int cproxy_listen_port(int port,
enum protocol protocol,
enum network_transport transport,
void *conn_extra,
- conn_funcs *conn_funcs) {
+ conn_funcs *funcs) {
assert(port > 0);
assert(conn_extra);
- assert(conn_funcs);
+ assert(funcs);
assert(is_listen_thread());
int listening = 0;
@@ -277,15 +277,15 @@ int cproxy_listen_port(int port,
conn *x = listen_conn_orig;
while (x != NULL) {
if (x->extra != NULL &&
- x->funcs == conn_funcs) {
+ x->funcs == funcs) {
struct in_addr in = {0};
- struct sockaddr_in sin = {0};
- socklen_t sin_len = sizeof(sin);
+ struct sockaddr_in s_in = {.sin_family = 0};
+ socklen_t sin_len = sizeof(s_in);
- if (getsockname(x->sfd, (struct sockaddr *) &sin, &sin_len) == 0) {
- in.s_addr = sin.sin_addr.s_addr;
+ if (getsockname(x->sfd, (struct sockaddr *) &s_in, &sin_len) == 0) {
+ in.s_addr = s_in.sin_addr.s_addr;
- int x_port = ntohs(sin.sin_port);
+ int x_port = ntohs(s_in.sin_port);
if (x_port == port) {
if (settings.verbose > 1) {
moxi_log_write(
@@ -341,7 +341,7 @@ int cproxy_listen_port(int port,
// such as if we handle graceful shutdown one day.
//
c->extra = conn_extra;
- c->funcs = conn_funcs;
+ c->funcs = funcs;
c->protocol = protocol;
c = c->next;
}
@@ -453,14 +453,14 @@ void cproxy_on_close_upstream_conn(conn *c) {
int n = mcs_server_count(&d->mst);
for (int i = 0; i < n; i++) {
- conn *c = d->downstream_conns[i];
- if (c != NULL &&
- c->state == conn_mwrite) {
- c->msgcurr = 0;
- c->msgused = 0;
- c->iovused = 0;
-
- cproxy_close_conn(c);
+ conn *downstream_conn = d->downstream_conns[i];
+ if (downstream_conn != NULL &&
+ downstream_conn->state == conn_mwrite) {
+ downstream_conn->msgcurr = 0;
+ downstream_conn->msgused = 0;
+ downstream_conn->iovused = 0;
+
+ cproxy_close_conn(downstream_conn);
}
}
}
@@ -1175,7 +1175,7 @@ conn *cproxy_find_downstream_conn_ex(downstream *d,
int v = -1;
int s = cproxy_server_index(d, key, key_length, &v);
if (s >= 0 &&
- s < mcs_server_count(&d->mst)) {
+ s < (int)mcs_server_count(&d->mst)) {
if (settings.verbose > 2) {
moxi_log_write("cproxy_find_downstream_conn_ex server_index %d, vbucket %d\n",
s, v);
@@ -1674,6 +1674,8 @@ bool cproxy_start_wait_queue_timeout(proxy_td *ptd, conn *uc) {
void wait_queue_timeout(const int fd,
const short which,
void *arg) {
+ (void)fd;
+ (void)which;
proxy_td *ptd = arg;
assert(ptd != NULL);
@@ -1984,6 +1986,9 @@ downstream *downstream_list_remove(downstream *head, downstream *d) {
* save on network hops.
*/
bool is_compatible_request(conn *existing, conn *candidate) {
+ (void)existing;
+ (void)candidate;
+
// The not-my-vbucket error handling requires us to not
// squash ascii multi-GET requests, due to reusing the
// multiget-deduplication machinery during retries and
@@ -2030,6 +2035,9 @@ bool is_compatible_request(conn *existing, conn *candidate) {
void downstream_timeout(const int fd,
const short which,
void *arg) {
+ (void)fd;
+ (void)which;
+
downstream *d = arg;
assert(d != NULL);
assert(d->ptd != NULL);
@@ -2128,7 +2136,7 @@ bool cproxy_auth_downstream(mcs_server_st *server,
if (usr_len <= 0 ||
pwd_len <= 0 ||
!IS_PROXY(behavior->downstream_protocol) ||
- (usr_len + pwd_len + 50 > sizeof(buf))) {
+ (usr_len + pwd_len + 50 > (int)sizeof(buf))) {
if (settings.verbose > 1) {
moxi_log_write("auth failure args\n");
}
@@ -2181,7 +2189,7 @@ bool cproxy_auth_downstream(mcs_server_st *server,
//
int len = res.response.bodylen;
while (len > 0) {
- int amt = (len > sizeof(buf) ? sizeof(buf) : len);
+ int amt = (len > (int)sizeof(buf) ? (int)sizeof(buf) : len);
if (mcs_server_st_read(server,
buf,
amt) != MEMCACHED_SUCCESS) {
@@ -2275,7 +2283,7 @@ bool cproxy_bucket_downstream(mcs_server_st *server,
int len = res.response.bodylen;
while (len > 0) {
- int amt = (len > sizeof(buf) ? sizeof(buf) : len);
+ int amt = (len > (int)sizeof(buf) ? (int)sizeof(buf) : len);
if (mcs_server_st_read(server,
buf,
amt) != MEMCACHED_SUCCESS) {
View
@@ -113,6 +113,7 @@ static void *noop_dup(const void *v)
}
void noop_free(void *v) {
+ (void)v;
/* Nothing */
}
@@ -756,6 +757,7 @@ void cproxy_dump_behavior_stderr(const void *dump_opaque,
const char *prefix,
const char *key,
const char *val) {
+ (void)dump_opaque;
assert(key);
assert(val);
@@ -780,6 +782,9 @@ void msec_set_current_time(void) {
}
void msec_clock_handler(const int fd, const short which, void *arg) {
+ (void)fd;
+ (void)which;
+ (void)arg;
// Subsecond resolution timer.
//
struct timeval t = { .tv_sec = 0,
View
@@ -163,6 +163,7 @@ void mcache_stop(mcache *m) {
void *mcache_get(mcache *m, char *key, int key_len,
uint32_t curr_time) {
+ (void)key_len;
assert(key);
if (m == NULL) {
@@ -246,7 +247,7 @@ void mcache_set(mcache *m, void *it,
// Evict some items if necessary.
//
for (int i = 0; m->lru_tail != NULL && i < 20; i++) {
- if (genhash_size(m->map) < m->max) {
+ if ((uint32_t)genhash_size(m->map) < m->max) {
break;
}
@@ -268,7 +269,7 @@ void mcache_set(mcache *m, void *it,
m->tot_evictions++;
}
- if (genhash_size(m->map) < m->max) {
+ if ((uint32_t)genhash_size(m->map) < m->max) {
char *key = m->funcs->item_key(it);
int key_len = m->funcs->item_key_len(it);
char *key_buf = NULL;
@@ -335,6 +336,8 @@ void mcache_set(mcache *m, void *it,
}
void mcache_delete(mcache *m, char *key, int key_len) {
+ (void)key_len;
+ (void)key;
assert(key);
assert(key_len > 0);
assert(key[key_len] == '\0' ||
@@ -441,6 +444,7 @@ struct mcache_foreach_data {
static
void mcache_foreach_trampoline(const void *key, const void *value, void *_data) {
+ (void)key;
struct mcache_foreach_data *data = _data;
data->f(value, data->userdata);
}
View
@@ -15,6 +15,7 @@
void multiget_foreach_free(const void *key,
const void *value,
void *user_data) {
+ (void)key;
downstream *d = user_data;
assert(d);
@@ -52,6 +53,7 @@ void multiget_foreach_free(const void *key,
void multiget_remove_upstream(const void *key,
const void *value,
void *user_data) {
+ (void)key;
multiget_entry *entry = (multiget_entry *) value;
assert(entry != NULL);
View
@@ -388,8 +388,10 @@ int a2a_multiget_start(conn *c, char *cmd, int cmd_len) {
/* An skey is a space prefixed key string.
*/
-int a2a_multiget_skey(conn *c, char *skey, int skey_len, int vbucket, int key_index) {
- return add_iov(c, skey, skey_len);
+int a2a_multiget_skey(conn *c, char *skey, int skey_length, int vbucket, int key_index) {
+ (void)vbucket;
+ (void)key_index;
+ return add_iov(c, skey, skey_length);
}
int a2a_multiget_end(conn *c) {
View
@@ -131,7 +131,7 @@ struct A2BSpec a2b_specs[] = {
.size = sizeof(protocol_binary_request_stats),
.broadcast = true
},
- { 0 } // NULL sentinel.
+ { .line = 0 } // NULL sentinel.
};
// These are immutable after init.
@@ -285,6 +285,7 @@ bool a2b_fill_request_token(struct A2BSpec *spec,
uint8_t **out_key,
uint16_t *out_keylen,
uint8_t *out_extlen) {
+ (void)cmd_ntokens;
assert(header);
assert(spec);
assert(spec->tokens);
@@ -635,8 +636,8 @@ void a2b_process_downstream_response(conn *c) {
protocol_binary_response_header *header =
(protocol_binary_response_header *) &c->binary_header;
- int extlen = header->response.extlen;
- int keylen = header->response.keylen;
+ uint32_t extlen = header->response.extlen;
+ uint32_t keylen = header->response.keylen;
uint32_t bodylen = header->response.bodylen;
uint16_t status = header->response.status;
@@ -1337,14 +1338,17 @@ bool cproxy_forward_a2b_simple_downstream(downstream *d,
}
int a2b_multiget_start(conn *c, char *cmd, int cmd_len) {
+ (void)c;
+ (void)cmd;
+ (void)cmd_len;
return 0; // No-op.
}
/* An skey is a space prefixed key string.
*/
-int a2b_multiget_skey(conn *c, char *skey, int skey_len, int vbucket, int key_index) {
+int a2b_multiget_skey(conn *c, char *skey, int skey_length, int vbucket, int key_index) {
char *key = skey + 1;
- int key_len = skey_len - 1;
+ int key_len = skey_length - 1;
item *it = item_alloc("b", 1, 0, 0, sizeof(protocol_binary_request_get));
if (it != NULL) {
Oops, something went wrong.

0 comments on commit e1ae2ef

Please sign in to comment.