Don't use __attribute__((unused))
[awesomized/libmemcached] / libmemcached / verbosity.c
index fba00144aa46a4004a1c6cfd2f1720c43b2bd4c5..d71fced7ab75baa31f0b057d0a24a35c58a6607d 100644 (file)
@@ -1,12 +1,12 @@
 #include "common.h"
 
-struct context_st 
+struct context_st
 {
   size_t length;
   const char *buffer;
 };
 
-static memcached_return_t _set_verbosity(const memcached_st *ptr __attribute__((unused)),
+static memcached_return_t _set_verbosity(const memcached_st *ptr,
                                          const memcached_server_st *server,
                                          void *context)
 {
@@ -16,6 +16,7 @@ static memcached_return_t _set_verbosity(const memcached_st *ptr __attribute__((
   char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
 
   struct context_st *execute= (struct context_st *)context;
+  (void)ptr;
 
   memc_ptr= memcached_create(&local_memc);
 
@@ -41,17 +42,17 @@ static memcached_return_t _set_verbosity(const memcached_st *ptr __attribute__((
 
 memcached_return_t memcached_verbosity(memcached_st *ptr, uint32_t verbosity)
 {
-  size_t send_length;
+  int send_length;
   memcached_server_fn callbacks[1];
 
   char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
 
-  send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, 
+  send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
                                  "verbosity %u\r\n", verbosity);
-  unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
+  if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || send_length < 0)
     return MEMCACHED_WRITE_FAILURE;
 
-  struct context_st context = { .length= send_length, .buffer= buffer };
+  struct context_st context = { .length= (size_t)send_length, .buffer= buffer };
 
   callbacks[0]= _set_verbosity;