X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Femail.c;h=d94c542ffcff7fef4b8b12d06117acc42920100d;hp=c0f28d04379be54bc9c3e0fee08697d71ffc3cbb;hb=77ca1a45bab2f6adf9301723d0db68e5813a6d98;hpb=1804ab004b8c7e14eac8c3a662747fbae4cf4aad diff --git a/src/email.c b/src/email.c index c0f28d04..d94c542f 100644 --- a/src/email.c +++ b/src/email.c @@ -274,7 +274,7 @@ static void *collect(void *arg) { len = strlen(line); if ((line[len - 1] != '\n') && (line[len - 1] != '\r')) { - log_warn("collect: line too long (> %zu characters): " + log_warn("collect: line too long (> %" PRIsz " characters): " "'%s' (truncated)", sizeof(line) - 1, line); @@ -297,22 +297,21 @@ static void *collect(void *arg) { } if (line[0] == 'e') { /* e:: */ - char *ptr = NULL; - char *type = strtok_r(line + 2, ":", &ptr); - char *tmp = strtok_r(NULL, ":", &ptr); - int bytes = 0; - - if (tmp == NULL) { + char *type = line + 2; + char *bytes_str = strchr(type, ':'); + if (bytes_str == NULL) { log_err("collect: syntax error in line '%s'", line); continue; } - bytes = atoi(tmp); + *bytes_str = 0; + bytes_str++; pthread_mutex_lock(&count_mutex); type_list_incr(&list_count, type, /* increment = */ 1); pthread_mutex_unlock(&count_mutex); + int bytes = atoi(bytes_str); if (bytes > 0) { pthread_mutex_lock(&size_mutex); type_list_incr(&list_size, type, /* increment = */ bytes); @@ -370,7 +369,9 @@ static void *open_connection(void __attribute__((unused)) * arg) { pthread_exit((void *)1); } - struct sockaddr_un addr = {.sun_family = AF_UNIX}; + struct sockaddr_un addr = { + .sun_family = AF_UNIX, + }; sstrncpy(addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1)); errno = 0;