[PATCH 2/2] Make old code pass gcc -Wall -Wextra.
Tomash Brechko
tomash.brechko at gmail.com
Thu Nov 8 09:12:10 UTC 2007
---
trunk/server/memcached.c | 26 ++++++++++++++++++--------
trunk/server/slabs.c | 2 +-
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/trunk/server/memcached.c b/trunk/server/memcached.c
index 0693935..c71cf07 100644
--- a/trunk/server/memcached.c
+++ b/trunk/server/memcached.c
@@ -662,7 +662,7 @@ static int build_udp_headers(conn *c) {
static void out_string(conn *c, const char *str) {
- size_t len;
+ int len;
assert(c != NULL);
@@ -1170,7 +1170,7 @@ void process_get_command(enum command_code code,
if (code == CMD_GETS)
{
in_memory_ptr = (uint32_t)item_get(key, nkey);
- sprintf(suffix," %d %d %lu\r\n", atoi(ITEM_suffix(it) + 1), it->nbytes - 2, in_memory_ptr);
+ sprintf(suffix," %d %d %u\r\n", atoi(ITEM_suffix(it) + 1), it->nbytes - 2, in_memory_ptr);
if (add_iov(c, "VALUE ", 6) != 0 ||
add_iov(c, ITEM_key(it), it->nkey) != 0 ||
add_iov(c, suffix, strlen(suffix)) != 0 ||
@@ -1244,9 +1244,9 @@ void process_update_command(enum command_code code,
size_t nkey;
int flags;
time_t exptime;
- int vlen, old_vlen;
- uint32_t req_memory_ptr, in_memory_ptr;
- item *it, *old_it;
+ int vlen;
+ uint32_t req_memory_ptr = 0, in_memory_ptr;
+ item *it;
assert(c != NULL);
@@ -1613,7 +1613,7 @@ void process_manage_command(enum command_code code,
}
if (res) {
- if ((bucket < 0) || (bucket >= MAX_BUCKETS)) {
+ if (bucket >= MAX_BUCKETS) {
if (code != CMD_BG) {
out_string(c, "CLIENT_ERROR bucket number out of range");
return;
@@ -1973,7 +1973,7 @@ static int transmit(conn *c) {
/* We've written some of the data. Remove the completed
iovec entries from the list of pending writes. */
- while (m->msg_iovlen > 0 && res >= m->msg_iov->iov_len) {
+ while (m->msg_iovlen > 0 && (size_t)res >= m->msg_iov->iov_len) {
res -= m->msg_iov->iov_len;
m->msg_iovlen--;
m->msg_iov++;
@@ -2444,6 +2444,10 @@ static void set_current_time(void) {
}
static void clock_handler(const int fd, const short which, void *arg) {
+ SUPPRESS_UNUSED_WARNING(fd);
+ SUPPRESS_UNUSED_WARNING(which);
+ SUPPRESS_UNUSED_WARNING(arg);
+
struct timeval t = {.tv_sec = 1, .tv_usec = 0};
static bool initialized = false;
@@ -2464,6 +2468,10 @@ static void clock_handler(const int fd, const short which, void *arg) {
static struct event deleteevent;
static void delete_handler(const int fd, const short which, void *arg) {
+ SUPPRESS_UNUSED_WARNING(fd);
+ SUPPRESS_UNUSED_WARNING(which);
+ SUPPRESS_UNUSED_WARNING(arg);
+
struct timeval t = {.tv_sec = 5, .tv_usec = 0};
static bool initialized = false;
@@ -2627,6 +2635,8 @@ static void remove_pidfile(const char *pid_file) {
static void sig_handler(const int sig) {
+ SUPPRESS_UNUSED_WARNING(sig);
+
printf("SIGINT handled.\n");
exit(EXIT_SUCCESS);
}
@@ -2783,7 +2793,7 @@ int main (int argc, char **argv) {
fprintf(stderr, "failed to getrlimit number of files\n");
exit(EXIT_FAILURE);
} else {
- int maxfiles = settings.maxconns;
+ size_t maxfiles = settings.maxconns;
if (rlim.rlim_cur < maxfiles)
rlim.rlim_cur = maxfiles + 3;
if (rlim.rlim_max < rlim.rlim_cur)
diff --git a/trunk/server/slabs.c b/trunk/server/slabs.c
index 1805129..14f0dca 100644
--- a/trunk/server/slabs.c
+++ b/trunk/server/slabs.c
@@ -204,7 +204,7 @@ void *do_slabs_alloc(const size_t size) {
slabclass_t *p;
unsigned int id = slabs_clsid(size);
- if (id < POWER_SMALLEST || id > power_largest)
+ if (id < POWER_SMALLEST || id > (unsigned int)power_largest)
return NULL;
p = &slabclass[id];
--
1.5.3.5.529.ge3d6d
More information about the memcached
mailing list