diff options
author | Dustin Sallings <dustin@spy.net> | 2009-02-24 12:21:44 -0800 |
---|---|---|
committer | Dustin Sallings <dustin@spy.net> | 2009-02-24 13:42:30 -0800 |
commit | 09a40db54650cf7a3645cae47eb5b45febe7668c (patch) | |
tree | dc860e28af7c403c0c069439f89b998d85d6da4a | |
parent | e5d053c3f959c5b0ac4b9ffaf94538b443df3880 (diff) | |
download | memcached-09a40db54650cf7a3645cae47eb5b45febe7668c.tar.gz |
Convert an if/else chain to a switch. Add default state.
The default was the bigger issue. Defaulting to NOT_STORED is
probably OK, but if a new storage type comes up, I'd rather see failures.
-rw-r--r-- | memcached.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/memcached.c b/memcached.c index 8ec2c4a..8381cc8 100644 --- a/memcached.c +++ b/memcached.c @@ -860,14 +860,23 @@ static void complete_nread_ascii(conn *c) { } #endif - if (ret == STORED) + switch (ret) { + case STORED: out_string(c, "STORED"); - else if(ret == EXISTS) + break; + case EXISTS: out_string(c, "EXISTS"); - else if(ret == NOT_FOUND) + break; + case NOT_FOUND: out_string(c, "NOT_FOUND"); - else + break; + case NOT_STORED: out_string(c, "NOT_STORED"); + break; + default: + out_string(c, "SERVER_ERROR Unhandled storage type."); + } + } item_remove(c->item); /* release the c->item reference */ |