Fix all warnings found via clang.
[awesomized/libmemcached] / example / memcached_light.cc
index 61c5314da950ce4d5fe42882355bede0185fd0ae..3f14c8ee17d2b1d6d5d7b2ca18e2701459d3bc66 100644 (file)
@@ -9,11 +9,11 @@
  * With that in mind, let me give you some pointers into the source:
  *   storage.c/h       - Implements the item store for this server and not really
  *                       interesting for this example.
- *   interface_v0.c    - Shows an implementation of the memcached server by using
+ *   interface_v0.cc   - Shows an implementation of the memcached server by using
  *                       the "raw" access to the packets as they arrive
- *   interface_v1.c    - Shows an implementation of the memcached server by using
+ *   interface_v1.cc   - Shows an implementation of the memcached server by using
  *                       the more "logical" interface.
- *   memcached_light.c - This file sets up all of the sockets and run the main
+ *   memcached_light.cc- This file sets up all of the sockets and run the main
  *                       message loop.
  *
  *
@@ -23,7 +23,7 @@
  * the library)
  */
 
-#include "config.h"
+#include <config.h>
 
 #include <libmemcachedprotocol-0.0/handler.h>
 #include <libmemcached/socket.hpp>
@@ -77,7 +77,8 @@ struct options_st {
 
   options_st() :
     service("9999"),
-    is_verbose(false)
+    is_verbose(false),
+    opt_daemon(false)
   {
   }
 };
@@ -134,7 +135,7 @@ static void drive_client(memcached_socket_t fd, short, void *arg)
       flags|= EV_READ;
     }
 
-    event_set(&client->event, (intptr_t)fd, flags, drive_client, client);
+    event_set(&client->event, int(fd), flags, drive_client, client);
     event_base_set(event_base, &client->event);
 
     if (event_add(&client->event, 0) == -1)
@@ -183,7 +184,7 @@ static void accept_handler(memcached_socket_t fd, short, void *arg)
     struct connection *client = &socket_userdata_map[sock];
     client->userdata= c;
 
-    event_set(&client->event, (intptr_t)sock, EV_READ, drive_client, client);
+    event_set(&client->event, int(sock), EV_READ, drive_client, client);
     event_base_set(event_base, &client->event);
     if (event_add(&client->event, 0) == -1)
     {
@@ -433,13 +434,6 @@ int main(int argc, char **argv)
 {
   memcached_binary_protocol_callback_st *interface= &interface_v0_impl;
 
-  /*
-   * We need to initialize the handlers manually due to a bug in the
-   * warnings generated by struct initialization in gcc (all the way up to 4.4)
-   */
-  initialize_interface_v0_handler();
-  initialize_interface_v1_handler();
-
   {
     enum long_option_t {
       OPT_HELP,
@@ -554,6 +548,14 @@ int main(int argc, char **argv)
   util::log_info_st log_file(argv[0], global_options.log_file, false);
   log_file.write(util::VERBOSE_NOTICE, "starting log");
 
+  /*
+   * We need to initialize the handlers manually due to a bug in the
+   * warnings generated by struct initialization in gcc (all the way up to 4.4)
+   */
+  initialize_interface_v0_handler(log_file);
+  initialize_interface_v1_handler(log_file);
+
+
   if (server_socket(log_file, global_options.service) == false)
   {
     return EXIT_FAILURE;
@@ -603,7 +605,7 @@ int main(int argc, char **argv)
     struct connection *conn= &socket_userdata_map[server_sockets[xx]];
     conn->userdata= protocol_handle;
 
-    event_set(&conn->event, (intptr_t)server_sockets[xx], EV_READ | EV_PERSIST, accept_handler, conn);
+    event_set(&conn->event, int(server_sockets[xx]), EV_READ | EV_PERSIST, accept_handler, conn);
 
     event_base_set(event_base, &conn->event);
     if (event_add(&conn->event, 0) == -1)