From a19ead105eeedcf7b01ec14a892d2e799e4dcba6 Mon Sep 17 00:00:00 2001 From: "Costa Tsaousis (ktsaou)" Date: Sun, 13 Nov 2016 12:20:27 +0200 Subject: [PATCH] improvements identified via static code analysis with cppcheck --- src/apps_plugin.c | 5 ++--- src/common.c | 15 ++++----------- src/daemon.c | 5 +---- src/eval.c | 7 ++----- src/health.c | 3 +-- src/ipc.c | 2 +- src/log.c | 4 ++-- src/plugin_idlejitter.c | 2 +- src/plugin_proc.c | 2 +- src/plugins_d.c | 3 +-- src/proc_diskstats.c | 3 +-- src/proc_interrupts.c | 3 ++- src/proc_meminfo.c | 3 +-- src/proc_net_dev.c | 3 +-- src/proc_net_rpc_nfs.c | 3 +-- src/proc_net_rpc_nfsd.c | 3 +-- src/proc_net_snmp6.c | 3 +-- src/proc_net_stat_conntrack.c | 3 +-- src/proc_self_mountinfo.c | 4 +--- src/proc_softirqs.c | 3 ++- src/proc_vmstat.c | 3 +-- src/procfile.c | 12 ++++++------ src/rrd.c | 3 +-- src/sys_fs_cgroup.c | 4 ++-- 24 files changed, 38 insertions(+), 63 deletions(-) diff --git a/src/apps_plugin.c b/src/apps_plugin.c index f22a575b..d367fc35 100644 --- a/src/apps_plugin.c +++ b/src/apps_plugin.c @@ -2787,7 +2787,6 @@ int main(int argc, char **argv) procfile_adaptive_initial_allocation = 1; time_t started_t = time(NULL); - time_t current_t; get_system_HZ(); get_system_pid_max(); get_system_cpus(); @@ -2831,12 +2830,12 @@ int main(int argc, char **argv) #ifndef PROFILING_MODE unsigned long long sunext = (time(NULL) - (time(NULL) % update_every) + update_every) * 1000000ULL; - unsigned long long sunow; #endif /* PROFILING_MODE */ global_iterations_counter = 1; for(;1; global_iterations_counter++) { #ifndef PROFILING_MODE + unsigned long long sunow; // delay until it is our time to run while((sunow = time_usec()) < sunext) sleep_usec(sunext - sunow); @@ -2878,7 +2877,7 @@ int main(int argc, char **argv) if(unlikely(debug)) fprintf(stderr, "apps.plugin: done Loop No %llu\n", global_iterations_counter); - current_t = time(NULL); + time_t current_t = time(NULL); #ifndef PROFILING_MODE // restart check (14400 seconds) diff --git a/src/common.c b/src/common.c index ce348d79..fa69bff8 100644 --- a/src/common.c +++ b/src/common.c @@ -864,11 +864,9 @@ uint32_t simple_hash(const char *name) { */ void strreverse(char *begin, char *end) { - char aux; - while (end > begin) { // clearer code. - aux = *end; + char aux = *end; *end-- = *begin; *begin++ = aux; } @@ -905,11 +903,10 @@ void *mymmap(const char *filename, size_t size, int flags, int ksm) { #ifdef MADV_MERGEABLE static int log_madvise_2 = 1, log_madvise_3 = 1; #endif - int fd; void *mem = NULL; errno = 0; - fd = open(filename, O_RDWR | O_CREAT | O_NOATIME, 0664); + int fd = open(filename, O_RDWR | O_CREAT | O_NOATIME, 0664); if (fd != -1) { if (lseek(fd, size, SEEK_SET) == (off_t) size) { if (write(fd, "", 1) == 1) { @@ -1090,14 +1087,12 @@ int snprintfz(char *dst, size_t n, const char *fmt, ...) { int processors = 1; long get_system_cpus(void) { - procfile *ff = NULL; - processors = 1; char filename[FILENAME_MAX + 1]; snprintfz(filename, FILENAME_MAX, "%s/proc/stat", global_host_prefix); - ff = procfile_open(filename, NULL, PROCFILE_FLAG_DEFAULT); + procfile *ff = procfile_open(filename, NULL, PROCFILE_FLAG_DEFAULT); if(!ff) { error("Cannot open file '%s'. Assuming system has %d processors.", filename, processors); return processors; @@ -1127,11 +1122,9 @@ long get_system_cpus(void) { pid_t pid_max = 32768; pid_t get_system_pid_max(void) { - procfile *ff = NULL; - char filename[FILENAME_MAX + 1]; snprintfz(filename, FILENAME_MAX, "%s/proc/sys/kernel/pid_max", global_host_prefix); - ff = procfile_open(filename, NULL, PROCFILE_FLAG_DEFAULT); + procfile *ff = procfile_open(filename, NULL, PROCFILE_FLAG_DEFAULT); if(!ff) { error("Cannot open file '%s'. Assuming system supports %d pids.", filename, pid_max); return pid_max; diff --git a/src/daemon.c b/src/daemon.c index fb57be14..2453012e 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -114,7 +114,6 @@ int become_user(const char *username, int pid_fd) error("Cannot set supplementary groups for user '%s'", username); freez(supplementary_groups); - supplementary_groups = NULL; ngroups = 0; } @@ -251,10 +250,8 @@ int become_daemon(int dont_fork, const char *user) create_needed_dir(VARLIB_DIR, getuid(), getgid()); } - if(pidfd != -1) { + if(pidfd != -1) close(pidfd); - pidfd = -1; - } return(0); } diff --git a/src/eval.c b/src/eval.c index 94c978e3..a4450f92 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1031,9 +1031,7 @@ static inline EVAL_NODE *parse_rest_of_expression(const char **string, int *erro // high level function to parse an expression or a sub-expression static inline EVAL_NODE *parse_full_expression(const char **string, int *error) { - EVAL_NODE *op1 = NULL; - - op1 = parse_one_full_operand(string, error); + EVAL_NODE *op1 = parse_one_full_operand(string, error); if(!op1) { *error = EVAL_ERROR_MISSING_OPERAND; return NULL; @@ -1081,7 +1079,6 @@ int expression_evaluate(EVAL_EXPRESSION *exp) { EVAL_EXPRESSION *expression_parse(const char *string, const char **failed_at, int *error) { const char *s = string; int err = EVAL_ERROR_OK; - unsigned long pos = 0; EVAL_NODE *op = parse_full_expression(&s, &err); @@ -1097,7 +1094,7 @@ EVAL_EXPRESSION *expression_parse(const char *string, const char **failed_at, in if (error) *error = err; if(!op) { - pos = s - string + 1; + unsigned long pos = s - string + 1; error("failed to parse expression '%s': %s at character %lu (i.e.: '%s').", string, expression_strerror(err), pos, s); return NULL; } diff --git a/src/health.c b/src/health.c index 876acac5..280c913f 100644 --- a/src/health.c +++ b/src/health.c @@ -141,13 +141,12 @@ static inline void health_alarm_log_save(RRDHOST *host, ALARM_ENTRY *ae) { static inline ssize_t health_alarm_log_read(RRDHOST *host, FILE *fp, const char *filename) { static uint32_t max_unique_id = 0, max_alarm_id = 0; - ssize_t loaded = -1, updated = -1, errored = -1, duplicate = -1; errno = 0; char *s, *buf = mallocz(65536 + 1); size_t line = 0, len = 0; - loaded = updated = errored = duplicate = 0; + ssize_t loaded = 0, updated = 0, errored = 0, duplicate = 0; pthread_rwlock_rdlock(&host->health_log.alarm_log_rwlock); diff --git a/src/ipc.c b/src/ipc.c index 61773625..3cf76513 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -138,7 +138,6 @@ printf ("allocated semaphores = %d\n", status.semaem); */ static inline int ipc_sem_get_status(struct ipc_status *st) { - static int error_shown = 0; struct seminfo seminfo; union semun arg; @@ -146,6 +145,7 @@ static inline int ipc_sem_get_status(struct ipc_status *st) { if(unlikely(semctl (0, 0, SEM_INFO, arg) < 0)) { /* kernel not configured for semaphores */ + static int error_shown = 0; if(unlikely(!error_shown)) { error("IPC: kernel is not configured for semaphores"); error_shown = 1; diff --git a/src/log.c b/src/log.c index 86716987..bf2ad6b3 100644 --- a/src/log.c +++ b/src/log.c @@ -24,7 +24,7 @@ void syslog_init(void) { } int open_log_file(int fd, FILE **fp, const char *filename, int *enabled_syslog) { - int f, t; + int f; if(!filename || !*filename || !strcmp(filename, "none")) filename = "/dev/null"; @@ -64,7 +64,7 @@ int open_log_file(int fd, FILE **fp, const char *filename, int *enabled_syslog) if(fd != f && fd != -1) { // it automatically closes - t = dup2(f, fd); + int t = dup2(f, fd); if (t == -1) { error("Cannot dup2() new fd %d to old fd %d for '%s'", f, fd, filename); close(f); diff --git a/src/plugin_idlejitter.c b/src/plugin_idlejitter.c index 30c6d870..a9b340ab 100644 --- a/src/plugin_idlejitter.c +++ b/src/plugin_idlejitter.c @@ -34,7 +34,7 @@ void *cpuidlejitter_main(void *ptr) while(susec < (rrd_update_every * 1000000ULL)) { gettimeofday(&before, NULL); - usleep(sleep_ms * 1000); + sleep_usec(sleep_ms * 1000); gettimeofday(&after, NULL); // calculate the time it took for a full loop diff --git a/src/plugin_proc.c b/src/plugin_proc.c index 1c461dab..3e19d85a 100644 --- a/src/plugin_proc.c +++ b/src/plugin_proc.c @@ -63,9 +63,9 @@ void *proc_main(void *ptr) // the next time we will run - aligned properly unsigned long long sunext = (time(NULL) - (time(NULL) % rrd_update_every) + rrd_update_every) * 1000000ULL; - unsigned long long sunow; for(;;) { + unsigned long long sunow; if(unlikely(netdata_exit)) break; // delay until it is our time to run diff --git a/src/plugins_d.c b/src/plugins_d.c index 6af9c21e..40536532 100644 --- a/src/plugins_d.c +++ b/src/plugins_d.c @@ -121,7 +121,6 @@ void *pluginsd_worker_thread(void *arg) info("PLUGINSD: '%s' running on pid %d", cd->fullfilename, cd->pid); RRDSET *st = NULL; - char *s; uint32_t hash; while(likely(fgets(line, PLUGINSD_LINE_MAX, fp) != NULL)) { @@ -132,7 +131,7 @@ void *pluginsd_worker_thread(void *arg) // debug(D_PLUGINSD, "PLUGINSD: %s: %s", cd->filename, line); int w = pluginsd_split_words(line, words, MAX_WORDS); - s = words[0]; + char *s = words[0]; if(unlikely(!s || !*s || !w)) { // debug(D_PLUGINSD, "PLUGINSD: empty line"); continue; diff --git a/src/proc_diskstats.c b/src/proc_diskstats.c index 7ff85778..52712c25 100644 --- a/src/proc_diskstats.c +++ b/src/proc_diskstats.c @@ -480,7 +480,6 @@ int do_proc_diskstats(int update_every, unsigned long long dt) { if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time uint32_t lines = procfile_lines(ff), l; - uint32_t words; // this is smart enough not to reload it every time mountinfo_reload(0); @@ -500,7 +499,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) { last_writes = 0, last_writesectors = 0, last_writems = 0, last_busy_ms = 0; - words = procfile_linewords(ff, l); + uint32_t words = procfile_linewords(ff, l); if(unlikely(words < 14)) continue; major = strtoul(procfile_lineword(ff, l, 0), NULL, 10); diff --git a/src/proc_interrupts.c b/src/proc_interrupts.c index c652693a..14215de6 100644 --- a/src/proc_interrupts.c +++ b/src/proc_interrupts.c @@ -52,7 +52,7 @@ int do_proc_interrupts(int update_every, unsigned long long dt) { return 0; // we return 0, so that we will retry to open it next time uint32_t lines = procfile_lines(ff), l; - uint32_t words = procfile_linewords(ff, 0), w; + uint32_t words = procfile_linewords(ff, 0); if(unlikely(!lines)) { error("Cannot read /proc/interrupts, zero lines reported."); @@ -61,6 +61,7 @@ int do_proc_interrupts(int update_every, unsigned long long dt) { // find how many CPUs are there if(unlikely(cpus == -1)) { + uint32_t w; cpus = 0; for(w = 0; w < words ; w++) { if(unlikely(strncmp(procfile_lineword(ff, 0, w), "CPU", 3) == 0)) diff --git a/src/proc_meminfo.c b/src/proc_meminfo.c index 0e5e14fd..11b41be7 100644 --- a/src/proc_meminfo.c +++ b/src/proc_meminfo.c @@ -114,7 +114,6 @@ int do_proc_meminfo(int update_every, unsigned long long dt) { return 0; // we return 0, so that we will retry to open it next time uint32_t lines = procfile_lines(ff), l; - uint32_t words; int hwcorrupted = 0; @@ -162,7 +161,7 @@ int do_proc_meminfo(int update_every, unsigned long long dt) { HardwareCorrupted = 0; for(l = 0; l < lines ;l++) { - words = procfile_linewords(ff, l); + uint32_t words = procfile_linewords(ff, l); if(unlikely(words < 2)) continue; char *name = procfile_lineword(ff, l, 0); diff --git a/src/proc_net_dev.c b/src/proc_net_dev.c index 53981182..33d140c4 100644 --- a/src/proc_net_dev.c +++ b/src/proc_net_dev.c @@ -29,14 +29,13 @@ int do_proc_net_dev(int update_every, unsigned long long dt) { if(do_events == -1) do_events = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "frames, collisions, carrier counters for all interfaces", CONFIG_ONDEMAND_ONDEMAND); uint32_t lines = procfile_lines(ff), l; - uint32_t words; char *iface; unsigned long long rbytes, rpackets, rerrors, rdrops, rfifo, rframe, rcompressed, rmulticast; unsigned long long tbytes, tpackets, terrors, tdrops, tfifo, tcollisions, tcarrier, tcompressed; for(l = 2; l < lines ;l++) { - words = procfile_linewords(ff, l); + uint32_t words = procfile_linewords(ff, l); if(words < 17) continue; iface = procfile_lineword(ff, l, 0); diff --git a/src/proc_net_rpc_nfs.c b/src/proc_net_rpc_nfs.c index 98acdd81..86e2f70c 100644 --- a/src/proc_net_rpc_nfs.c +++ b/src/proc_net_rpc_nfs.c @@ -159,14 +159,13 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) { if(do_proc4) do_proc4 = 1; uint32_t lines = procfile_lines(ff), l; - uint32_t words; char *type; unsigned long long net_count = 0, net_udp_count = 0, net_tcp_count = 0, net_tcp_connections = 0; unsigned long long rpc_calls = 0, rpc_retransmits = 0, rpc_auth_refresh = 0; for(l = 0; l < lines ;l++) { - words = procfile_linewords(ff, l); + uint32_t words = procfile_linewords(ff, l); if(!words) continue; type = procfile_lineword(ff, l, 0); diff --git a/src/proc_net_rpc_nfsd.c b/src/proc_net_rpc_nfsd.c index 817e6c86..e0092c72 100644 --- a/src/proc_net_rpc_nfsd.c +++ b/src/proc_net_rpc_nfsd.c @@ -253,7 +253,6 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) { if(do_proc4ops) do_proc4ops = 1; uint32_t lines = procfile_lines(ff), l; - uint32_t words; char *type; unsigned long long rc_hits = 0, rc_misses = 0, rc_nocache = 0; @@ -265,7 +264,7 @@ int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) { unsigned long long rpc_calls = 0, rpc_bad_format = 0, rpc_bad_auth = 0, rpc_bad_client = 0; for(l = 0; l < lines ;l++) { - words = procfile_linewords(ff, l); + uint32_t words = procfile_linewords(ff, l); if(!words) continue; type = procfile_lineword(ff, l, 0); diff --git a/src/proc_net_snmp6.c b/src/proc_net_snmp6.c index 34c01a2f..b7ec65c0 100644 --- a/src/proc_net_snmp6.c +++ b/src/proc_net_snmp6.c @@ -253,7 +253,6 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) { return 0; // we return 0, so that we will retry to open it next time uint32_t lines = procfile_lines(ff), l; - uint32_t words; unsigned long long Ip6InReceives = 0ULL; unsigned long long Ip6InHdrErrors = 0ULL; @@ -349,7 +348,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) { unsigned long long UdpLite6InCsumErrors = 0ULL; for(l = 0; l < lines ;l++) { - words = procfile_linewords(ff, l); + uint32_t words = procfile_linewords(ff, l); if(unlikely(words < 2)) { if(unlikely(words)) error("Cannot read /proc/net/snmp6 line %u. Expected 2 params, read %u.", l, words); continue; diff --git a/src/proc_net_stat_conntrack.c b/src/proc_net_stat_conntrack.c index b1fc1f33..807a9bae 100644 --- a/src/proc_net_stat_conntrack.c +++ b/src/proc_net_stat_conntrack.c @@ -31,13 +31,12 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) { return 0; // we return 0, so that we will retry to open it next time uint32_t lines = procfile_lines(ff), l; - uint32_t words; unsigned long long aentries = 0, asearched = 0, afound = 0, anew = 0, ainvalid = 0, aignore = 0, adelete = 0, adelete_list = 0, ainsert = 0, ainsert_failed = 0, adrop = 0, aearly_drop = 0, aicmp_error = 0, aexpect_new = 0, aexpect_create = 0, aexpect_delete = 0, asearch_restart = 0; for(l = 1; l < lines ;l++) { - words = procfile_linewords(ff, l); + uint32_t words = procfile_linewords(ff, l); if(unlikely(words < 17)) { if(unlikely(words)) error("Cannot read /proc/net/stat/nf_conntrack line. Expected 17 params, read %u.", words); continue; diff --git a/src/proc_self_mountinfo.c b/src/proc_self_mountinfo.c index 3b1ecded..d2708f2e 100644 --- a/src/proc_self_mountinfo.c +++ b/src/proc_self_mountinfo.c @@ -159,11 +159,9 @@ static char *strdupz_decoding_octal(const char *string) { // read the whole mountinfo into a linked list struct mountinfo *mountinfo_read() { - procfile *ff = NULL; - char filename[FILENAME_MAX + 1]; snprintfz(filename, FILENAME_MAX, "%s/proc/self/mountinfo", global_host_prefix); - ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT); + procfile *ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT); if(unlikely(!ff)) { snprintfz(filename, FILENAME_MAX, "%s/proc/1/mountinfo", global_host_prefix); ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT); diff --git a/src/proc_softirqs.c b/src/proc_softirqs.c index 5346026c..818a6a70 100644 --- a/src/proc_softirqs.c +++ b/src/proc_softirqs.c @@ -50,7 +50,7 @@ int do_proc_softirqs(int update_every, unsigned long long dt) { if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time uint32_t lines = procfile_lines(ff), l; - uint32_t words = procfile_linewords(ff, 0), w; + uint32_t words = procfile_linewords(ff, 0); if(unlikely(!lines)) { error("Cannot read /proc/softirqs, zero lines reported."); @@ -59,6 +59,7 @@ int do_proc_softirqs(int update_every, unsigned long long dt) { // find how many CPUs are there if(unlikely(cpus == -1)) { + uint32_t w; cpus = 0; for(w = 0; w < words ; w++) { if(unlikely(strncmp(procfile_lineword(ff, 0, w), "CPU", 3) == 0)) diff --git a/src/proc_vmstat.c b/src/proc_vmstat.c index 3615f56f..a8058398 100644 --- a/src/proc_vmstat.c +++ b/src/proc_vmstat.c @@ -209,7 +209,6 @@ int do_proc_vmstat(int update_every, unsigned long long dt) { if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time uint32_t lines = procfile_lines(ff), l; - uint32_t words; // unsigned long long allocstall = 0ULL; // unsigned long long compact_blocks_moved = 0ULL; @@ -305,7 +304,7 @@ int do_proc_vmstat(int update_every, unsigned long long dt) { // unsigned long long unevictable_pgs_stranded = 0ULL; for(l = 0; l < lines ;l++) { - words = procfile_linewords(ff, l); + uint32_t words = procfile_linewords(ff, l); if(unlikely(words < 2)) { if(unlikely(words)) error("Cannot read /proc/vmstat line %u. Expected 2 params, read %u.", l, words); continue; diff --git a/src/procfile.c b/src/procfile.c index ee737871..31bdb5e2 100644 --- a/src/procfile.c +++ b/src/procfile.c @@ -267,12 +267,12 @@ cleanup: procfile *procfile_readall(procfile *ff) { debug(D_PROCFILE, PF_PREFIX ": Reading file '%s'.", ff->filename); - ssize_t s, r = 1, x; + ssize_t r = 1; ff->len = 0; while(likely(r > 0)) { - s = ff->len; - x = ff->size - s; + ssize_t s = ff->len; + ssize_t x = ff->size - s; if(unlikely(!x)) { debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s'.", ff->filename); @@ -316,13 +316,13 @@ procfile *procfile_readall(procfile *ff) { static void procfile_set_separators(procfile *ff, const char *separators) { static char def[256] = { [0 ... 255] = 0 }; - int i; if(unlikely(!def[255])) { // this is thread safe // we check that the last byte is non-zero // if it is zero, multiple threads may be executing this at the same time // setting in def[] the exact same values + int i; for(i = 0; likely(i < 256) ;i++) { if(unlikely(i == '\n' || i == '\r')) def[i] = PF_CHAR_IS_NEWLINE; else if(unlikely(isspace(i) || !isprint(i))) def[i] = PF_CHAR_IS_SEPARATOR; @@ -443,16 +443,16 @@ procfile *procfile_reopen(procfile *ff, const char *filename, const char *separa void procfile_print(procfile *ff) { uint32_t lines = procfile_lines(ff), l; - uint32_t words, w; char *s; debug(D_PROCFILE, "File '%s' with %u lines and %u words", ff->filename, ff->lines->len, ff->words->len); for(l = 0; likely(l < lines) ;l++) { - words = procfile_linewords(ff, l); + uint32_t words = procfile_linewords(ff, l); debug(D_PROCFILE, " line %u starts at word %u and has %u words", l, ff->lines->lines[l].first, ff->lines->lines[l].words); + uint32_t w; for(w = 0; likely(w < words) ;w++) { s = procfile_lineword(ff, l, w); debug(D_PROCFILE, " [%u.%u] '%s'", l, w, s); diff --git a/src/rrd.c b/src/rrd.c index 5b218fa8..8e2d76af 100644 --- a/src/rrd.c +++ b/src/rrd.c @@ -474,11 +474,10 @@ RRDSET *rrdset_create(const char *type, const char *id, const char *name, const char fullid[RRD_ID_LENGTH_MAX + 1]; char fullfilename[FILENAME_MAX + 1]; - RRDSET *st = NULL; snprintfz(fullid, RRD_ID_LENGTH_MAX, "%s.%s", type, id); - st = rrdset_find(fullid); + RRDSET *st = rrdset_find(fullid); if(st) { error("Cannot create rrd stats for '%s', it already exists.", fullid); return st; diff --git a/src/sys_fs_cgroup.c b/src/sys_fs_cgroup.c index 5e49f33e..cef7cb44 100644 --- a/src/sys_fs_cgroup.c +++ b/src/sys_fs_cgroup.c @@ -269,7 +269,7 @@ void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) { } unsigned long i = procfile_linewords(ff, 0); - if(i <= 0) return; + if(i == 0) return; // we may have 1 more CPU reported while(i > 0) { @@ -1437,11 +1437,11 @@ void *cgroups_main(void *ptr) // the next time we will run - aligned properly unsigned long long sunext = (time(NULL) - (time(NULL) % rrd_update_every) + rrd_update_every) * 1000000ULL; - unsigned long long sunow; RRDSET *stcpu_thread = NULL; for(;;) { + unsigned long long sunow; if(unlikely(netdata_exit)) break; // delay until it is our time to run -- 2.39.2