Merge in additional documentation updates.
[awesomized/libmemcached] / libmemcached / util / version.c
index 7c936c715a6233f497843bf85106a6214ea8bcd5..a0b6925532ee8c69ec85f1d7819bb8ca100f7b8d 100644 (file)
@@ -22,14 +22,16 @@ struct local_context
   bool truth;
 };
 
-static memcached_return_t check_server_version(const memcached_st *ptr __attribute__((unused)),
+static memcached_return_t check_server_version(const memcached_st *ptr,
                                                const memcached_server_st *instance,
                                                void *context)
 {
   /* Do Nothing */
   struct local_context *check= (struct local_context *)context;
+  (void)ptr;
 
-  if (instance->major_version >= check->major_version &&
+  if (instance->major_version != UINT8_MAX &&
+      instance->major_version >= check->major_version &&
       instance->minor_version >= check->minor_version &&
       instance->micro_version >= check->micro_version )
   {
@@ -41,16 +43,18 @@ static memcached_return_t check_server_version(const memcached_st *ptr __attribu
   return MEMCACHED_FAILURE;
 }
 
-bool libmemcached_util_version_check(memcached_st *memc, 
+bool libmemcached_util_version_check(memcached_st *memc,
                                      uint8_t major_version,
                                      uint8_t minor_version,
                                      uint8_t micro_version)
 {
   memcached_server_fn callbacks[1];
-  memcached_version(memc);
+  memcached_return_t rc= memcached_version(memc);
+
+  if (rc != MEMCACHED_SUCCESS)
+    return false;
 
   struct local_context check= { .major_version= major_version, .minor_version= minor_version, .micro_version= micro_version, .truth= true };
-  memcached_version(memc);
 
   callbacks[0]= check_server_version;
   memcached_server_cursor(memc, callbacks, (void *)&check,  1);