[PATCH 1/2] Make new code pass gcc -Wall -Wextra.

Tomash Brechko tomash.brechko at gmail.com
Thu Nov 8 09:11:56 UTC 2007


---
 trunk/server/memcached.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/trunk/server/memcached.c b/trunk/server/memcached.c
index f4924cb..0693935 100644
--- a/trunk/server/memcached.c
+++ b/trunk/server/memcached.c
@@ -60,6 +60,12 @@ std *
 #endif
 #endif
 
+
+#define SUPPRESS_UNUSED_WARNING(var)            \
+  do                                            \
+    if (var) {}                                 \
+  while (0)
+
 /*
  * forward declarations
  */
@@ -906,6 +912,8 @@ void process_stat(enum command_code code,
     rel_time_t now = current_time;
     const struct param *param;
 
+    SUPPRESS_UNUSED_WARNING(code);
+
     assert(c != NULL);
 
     /* FIXME: why not "ERROR" as other commands do?  */
@@ -1352,6 +1360,9 @@ void process_update_command(enum command_code code,
     case CMD_APPEND:
         c->item_comm = NREAD_APPEND;
         break;
+    default:
+        assert(false);
+        break;
     }
     conn_set_state(c, conn_nread);
 }
@@ -1466,6 +1477,8 @@ void process_delete_command(enum command_code code,
     item *it;
     time_t exptime = 0;
 
+    SUPPRESS_UNUSED_WARNING(code);
+
     assert(c != NULL);
 
     if (ntokens < 3 || ntokens > 4) {
@@ -1556,6 +1569,8 @@ void process_verbosity_command(enum command_code code,
                                conn *c, token_t *tokens, size_t ntokens) {
     unsigned int level;
 
+    SUPPRESS_UNUSED_WARNING(code);
+
     assert(c != NULL);
 
     if (ntokens != 3) {
@@ -1591,6 +1606,10 @@ void process_manage_command(enum command_code code,
     case CMD_DISOWN:
         res = (sscanf(tokens[1].value, "%u", &bucket) == 1);
         break;
+    default:
+        assert(false);
+        res = false;  /* Suppress uninitialized warning.  */
+        break;
     }
 
     if (res) {
@@ -1616,6 +1635,9 @@ void process_manage_command(enum command_code code,
             }
             conn_set_state(c, conn_read);
             break;
+        default:
+            assert(false);
+            break;
         }
     } else {
         out_string(c, "CLIENT_ERROR bad format");
@@ -1624,6 +1646,8 @@ void process_manage_command(enum command_code code,
 
 void process_flush_all_command(enum command_code code,
                                conn *c, token_t *tokens, size_t ntokens) {
+    SUPPRESS_UNUSED_WARNING(code);
+
     if (ntokens < 2 || ntokens > 3) {
         out_string(c, "ERROR");
     }
@@ -1651,6 +1675,8 @@ void process_flush_all_command(enum command_code code,
 
 void process_slabs_command(enum command_code code,
                            conn *c, token_t *tokens, size_t ntokens) {
+    SUPPRESS_UNUSED_WARNING(code);
+
     if (ntokens != 5
         || strcmp(tokens[SUBCOMMAND_TOKEN].value, "reassign") != 0) {
         out_string(c, "ERROR");
@@ -1689,6 +1715,9 @@ void process_slabs_command(enum command_code code,
 
 void process_version_command(enum command_code code,
                              conn *c, token_t *tokens, size_t ntokens) {
+    SUPPRESS_UNUSED_WARNING(code);
+    SUPPRESS_UNUSED_WARNING(tokens);
+
     if (ntokens != 2) {
         out_string(c, "ERROR");
         return;
@@ -1699,6 +1728,9 @@ void process_version_command(enum command_code code,
 
 void process_quit_command(enum command_code code,
                           conn *c, token_t *tokens, size_t ntokens) {
+    SUPPRESS_UNUSED_WARNING(code);
+    SUPPRESS_UNUSED_WARNING(tokens);
+
     if (ntokens != 2) {
         out_string(c, "ERROR");
         return;
-- 
1.5.3.5.529.ge3d6d


More information about the memcached mailing list