X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Femail.c;h=cb30a0eaf9ca42b73cccd2b19673d18ade2f15b4;hb=d3bd9c300b7b6c6b26c573a62fe59cece5d72739;hp=e11c6dee059842878cc98b85dde0b3040a53719e;hpb=0b7cd83a5e6bac068ea83a88a5ddcfb07c09fbec;p=collectd.git diff --git a/src/email.c b/src/email.c index e11c6dee..cb30a0ea 100644 --- a/src/email.c +++ b/src/email.c @@ -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; @@ -408,9 +409,7 @@ static void *open_connection(void __attribute__((unused)) * arg) { grp = NULL; status = getgrnam_r(group, &sg, grbuf, sizeof(grbuf), &grp); if (status != 0) { - char errbuf[1024]; - log_warn("getgrnam_r (%s) failed: %s", group, - sstrerror(status, errbuf, sizeof(errbuf))); + log_warn("getgrnam_r (%s) failed: %s", group, STRERROR(status)); } else if (grp == NULL) { log_warn("No such group: `%s'", group); } else {