Set static bools to true instead of 1
[collectd.git] / src / libcollectdclient / network_buffer.c
index 662265d..2332e3e 100644 (file)
@@ -30,6 +30,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <math.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -122,10 +123,10 @@ struct lcc_network_buffer_s {
 /*
  * Private functions
  */
-static _Bool have_gcrypt(void) /* {{{ */
+static bool have_gcrypt(void) /* {{{ */
 {
-  static _Bool result = 0;
-  static _Bool need_init = 1;
+  static bool result;
+  static bool need_init = true;
 
   if (!need_init)
     return result;
@@ -150,7 +151,7 @@ static _Bool have_gcrypt(void) /* {{{ */
 #else
   return 0;
 #endif
-} /* }}} _Bool have_gcrypt */
+} /* }}} bool have_gcrypt */
 
 #ifndef HAVE_HTONLL
 static uint64_t htonll(uint64_t val) /* {{{ */
@@ -255,6 +256,10 @@ static double htond(double val) /* {{{ */
 
 static int nb_add_values(char **ret_buffer, /* {{{ */
                          size_t *ret_buffer_len, const lcc_value_list_t *vl) {
+  if ((vl == NULL) || (vl->values_len < 1)) {
+    return EINVAL;
+  }
+
   char *packet_ptr;
   size_t packet_len;