network plugin, libcollectdclient: Check return value of gcry_control().
[collectd.git] / src / libcollectdclient / network_buffer.c
index acbe93f..ee6857a 100644 (file)
@@ -54,7 +54,9 @@
 /* Re enable deprecation warnings */
 #  pragma GCC diagnostic warning "-Wdeprecated-declarations"
 # endif
+# if GCRYPT_VERSION_NUMBER < 0x010600
 GCRY_THREAD_OPTION_PTHREAD_IMPL;
+# endif
 #endif
 
 #include "collectd/network_buffer.h"
@@ -131,12 +133,17 @@ static _Bool have_gcrypt (void) /* {{{ */
   need_init = 0;
 
 #if HAVE_LIBGCRYPT
-  gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+# if GCRYPT_VERSION_NUMBER < 0x010600
+  if (gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))
+    return (0);
+# endif
 
   if (!gcry_check_version (GCRYPT_VERSION))
     return (0);
 
-  gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0);
+  if (!gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0))
+    return (0);
+
   gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
 
   result = 1;
@@ -146,6 +153,7 @@ static _Bool have_gcrypt (void) /* {{{ */
 #endif
 } /* }}} _Bool have_gcrypt */
 
+#ifndef HAVE_HTONLL
 static uint64_t htonll (uint64_t val) /* {{{ */
 {
   static int config = 0;
@@ -175,6 +183,7 @@ static uint64_t htonll (uint64_t val) /* {{{ */
 
   return ((((uint64_t) lo) << 32) | ((uint64_t) hi));
 } /* }}} uint64_t htonll */
+#endif
 
 static double htond (double val) /* {{{ */
 {