Merge pull request #3329 from efuss/fix-3311
[collectd.git] / src / email.c
index 376dd6a..5360205 100644 (file)
@@ -40,8 +40,8 @@
 
 #include "collectd.h"
 
-#include "common.h"
 #include "plugin.h"
+#include "utils/common/common.h"
 
 #include <stddef.h>
 
@@ -174,16 +174,18 @@ static int email_config(const char *key, const char *value) {
     long int tmp = strtol(value, NULL, 0);
 
     if (tmp < 1) {
-      fprintf(stderr, "email plugin: `MaxConns' was set to invalid "
-                      "value %li, will use default %i.\n",
+      fprintf(stderr,
+              "email plugin: `MaxConns' was set to invalid "
+              "value %li, will use default %i.\n",
               tmp, MAX_CONNS);
       ERROR("email plugin: `MaxConns' was set to invalid "
             "value %li, will use default %i.\n",
             tmp, MAX_CONNS);
       max_conns = MAX_CONNS;
     } else if (tmp > MAX_CONNS_LIMIT) {
-      fprintf(stderr, "email plugin: `MaxConns' was set to invalid "
-                      "value %li, will use hardcoded limit %i.\n",
+      fprintf(stderr,
+              "email plugin: `MaxConns' was set to invalid "
+              "value %li, will use hardcoded limit %i.\n",
               tmp, MAX_CONNS_LIMIT);
       ERROR("email plugin: `MaxConns' was set to invalid "
             "value %li, will use hardcoded limit %i.\n",
@@ -260,7 +262,6 @@ static void *collect(void *arg) {
     while (42) {
       /* 256 bytes ought to be enough for anybody ;-) */
       char line[256 + 1]; /* line + '\0' */
-      int len = 0;
 
       errno = 0;
       if (fgets(line, sizeof(line), this->socket) == NULL) {
@@ -272,7 +273,7 @@ static void *collect(void *arg) {
         break;
       }
 
-      len = strlen(line);
+      size_t len = strlen(line);
       if ((line[len - 1] != '\n') && (line[len - 1] != '\r')) {
         log_warn("collect: line too long (> %" PRIsz " characters): "
                  "'%s' (truncated)",
@@ -287,7 +288,7 @@ static void *collect(void *arg) {
         continue;
       }
 
-      line[len - 1] = 0;
+      line[len - 1] = '\0';
 
       log_debug("collect: line = '%s'", line);