From 07d8c9c2988b0b99494c3a49399c196607ffc78f Mon Sep 17 00:00:00 2001 From: Steve Kay Date: Thu, 16 Jun 2022 14:52:07 +0100 Subject: [PATCH] code style, blank line after while --- cifsiostat.c | 1 + common.c | 1 + count.c | 2 ++ ioconf.c | 1 + iostat.c | 1 + mpstat.c | 3 +++ pcp_def_metrics.c | 2 ++ pidstat.c | 7 +++++++ rd_sensors.c | 11 +++++++++++ rd_stats.c | 3 +++ sa_common.c | 1 + tapestat.c | 1 + 12 files changed, 34 insertions(+) diff --git a/cifsiostat.c b/cifsiostat.c index 52e9cab..03be68a 100644 --- a/cifsiostat.c +++ b/cifsiostat.c @@ -141,6 +141,7 @@ struct io_cifs *add_list_cifs(struct io_cifs **clist, char *name) return NULL; while (*clist != NULL) { + c = *clist; if ((i = strcmp(c->name, name)) == 0) { /* cifs found in list */ diff --git a/common.c b/common.c index 5a915e6..94e94b5 100644 --- a/common.c +++ b/common.c @@ -948,6 +948,7 @@ char *get_persistent_name_from_pretty(char *pretty) return (NULL); while (persist_names[++i]) { + /* Get absolute path for current persistent name */ link = get_persistent_name_path(persist_names[i]); if (!link) diff --git a/count.c b/count.c index 855e212..a66764e 100644 --- a/count.c +++ b/count.c @@ -208,6 +208,7 @@ __nr_t get_irqcpu_nr(char *file, int max_nr_irqcpu, int cpu_nr) while ((fgets(line, INTERRUPTS_LINE + 11 * cpu_nr , fp) != NULL) && (irq < max_nr_irqcpu)) { + p = strcspn(line, ":"); if ((p > 0) && (p < 16)) { irq++; @@ -256,6 +257,7 @@ __nr_t get_diskstats_dev_nr(int count_part, int only_used_dev) * the number of lines... */ while (fgets(line, sizeof(line), fp) != NULL) { + if (!count_part) { i = sscanf(line, "%*d %*d %s %lu %*u %*u %*u %lu", dev_name, &rd_ios, &wr_ios); diff --git a/ioconf.c b/ioconf.c index ea2c578..cf03236 100644 --- a/ioconf.c +++ b/ioconf.c @@ -107,6 +107,7 @@ static char *ioc_conv(int radix, int nozero, const char *syms, } while (val > 0) { + *--p = syms[j = val % radix]; val /= radix; if (nozero && (j == 0)) { diff --git a/iostat.c b/iostat.c index 3739840..03f5623 100644 --- a/iostat.c +++ b/iostat.c @@ -300,6 +300,7 @@ struct io_device *add_list_device(struct io_device **dlist, char *name, int dtyp return NULL; while (*dlist != NULL) { + d = *dlist; if ((i = strcmp(d->name, name)) == 0) { /* Device found in list */ diff --git a/mpstat.c b/mpstat.c index 5ed9acc..d48f076 100644 --- a/mpstat.c +++ b/mpstat.c @@ -290,6 +290,7 @@ void fwd_irq_values(struct stats_irqcpu *st_ic[], unsigned int c, int j; while (c < last) { + st_irq_i = st_irq[curr] + c + 1; st_irq_j = st_irq[!curr] + c + 1; st_irq_i->irq_nr = st_irq_j->irq_nr; @@ -1856,8 +1857,10 @@ void read_interrupts_stat(char *file, struct stats_irqcpu *st_ic[], int ic_nr, i * Parse header line to see which CPUs are online */ while (fgets(line, INTERRUPTS_LINE + 11 * cpu_nr, fp) != NULL) { + next = line; while (((cp = strstr(next, "CPU")) != NULL) && (index < cpu_nr)) { + cpu = strtol(cp + 3, &next, 10); if (cpu >= cpu_nr) break; diff --git a/pcp_def_metrics.c b/pcp_def_metrics.c index 303ee0e..bf3e5a2 100644 --- a/pcp_def_metrics.c +++ b/pcp_def_metrics.c @@ -60,6 +60,7 @@ void pcp_def_percpu_int_metrics(struct activity *a, int cpu) /* Create instance for each interrupt for the current CPU */ while (list != NULL) { + snprintf(buf, sizeof(buf), "%s::cpu%d", list->item_name, cpu); buf[sizeof(buf) - 1] = '\0'; @@ -319,6 +320,7 @@ void pcp_def_irq_metrics(struct activity *a) /* Create instances and metrics for each interrupts for CPU "all" */ while (list != NULL) { + if (!strcmp(list->item_name, K_LOWERSUM)) { /* * Create metric for interrupt "sum" for CPU "all". diff --git a/pidstat.c b/pidstat.c index a9c197f..4026e27 100644 --- a/pidstat.c +++ b/pidstat.c @@ -138,6 +138,7 @@ void sfree_pid(struct st_pid **plist, int force) struct st_pid *p; while (*plist != NULL) { + p = *plist; if (!p->exist || force) { *plist = p->next; @@ -247,6 +248,7 @@ struct st_pid *add_list_pid(struct st_pid **plist, pid_t pid, pid_t tgid) * other TIDs. */ while (*plist != NULL) { + p = *plist; if (!p->tgid && (p->pid == pid)) /* PID found in list */ @@ -266,6 +268,7 @@ struct st_pid *add_list_pid(struct st_pid **plist, pid_t pid, pid_t tgid) * following its TGID. */ while (*plist != NULL) { + p = *plist; if (p->pid == tgid) { /* TGID found in list */ @@ -282,6 +285,7 @@ struct st_pid *add_list_pid(struct st_pid **plist, pid_t pid, pid_t tgid) plist = &(p->next); while (*plist != NULL) { + p = *plist; if ((p->tgid == tgid_p) && (p->pid == pid)) /* TID found in list */ @@ -605,6 +609,7 @@ int read_proc_pid_smap(pid_t pid, struct st_pid *plist, pid_t tgid, int curr) return 1; while ((state < 3) && (fgets(line, sizeof(line), fp) != NULL)) { + switch (state) { case 0: if (strstr(line, "[stack]")) { @@ -882,6 +887,7 @@ void read_task_stats(pid_t pid, struct st_pid *plist, int curr) return; while ((drp = __readdir(dir)) != NULL) { + if (!isdigit(drp->d_name[0])) { continue; } @@ -951,6 +957,7 @@ void read_stats(int curr) /* Get directory entries */ while ((drp = __readdir(dir)) != NULL) { + if (!isdigit(drp->d_name[0])) { continue; } diff --git a/rd_sensors.c b/rd_sensors.c index 94830d4..15d7ce5 100644 --- a/rd_sensors.c +++ b/rd_sensors.c @@ -68,8 +68,10 @@ __nr_t read_fan(struct stats_pwr_fan *st_pwr_fan, __nr_t nr_alloc) memset(st_pwr_fan, 0, STATS_PWR_FAN_SIZE); while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) { + i = 0; while ((feature = sensors_get_features(chip, &i))) { + if (feature->type == SENSORS_FEATURE_FAN) { j = 0; if (fan_read + 1 > nr_alloc) @@ -78,6 +80,7 @@ __nr_t read_fan(struct stats_pwr_fan *st_pwr_fan, __nr_t nr_alloc) sensors_snprintf_chip_name(st_pwr_fan_i->device, MAX_SENSORS_DEV_LEN, chip); while ((sub = sensors_get_all_subfeatures(chip, feature, &j))) { + if ((sub->type == SENSORS_SUBFEATURE_FAN_INPUT) && (sub->flags & SENSORS_MODE_R)) { if (sensors_get_value(chip, sub->number, &st_pwr_fan_i->rpm)) { @@ -130,8 +133,10 @@ __nr_t read_temp(struct stats_pwr_temp *st_pwr_temp, __nr_t nr_alloc) memset(st_pwr_temp, 0, STATS_PWR_TEMP_SIZE); while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) { + i = 0; while ((feature = sensors_get_features(chip, &i))) { + if (feature->type == SENSORS_FEATURE_TEMP) { j = 0; if (temp_read + 1 > nr_alloc) @@ -140,6 +145,7 @@ __nr_t read_temp(struct stats_pwr_temp *st_pwr_temp, __nr_t nr_alloc) sensors_snprintf_chip_name(st_pwr_temp_i->device, MAX_SENSORS_DEV_LEN, chip); while ((sub = sensors_get_all_subfeatures(chip, feature, &j))) { + if ((sub->type == SENSORS_SUBFEATURE_TEMP_INPUT) && (sub->flags & SENSORS_MODE_R)) { if (sensors_get_value(chip, sub->number, &st_pwr_temp_i->temp)) { @@ -197,8 +203,10 @@ __nr_t read_in(struct stats_pwr_in *st_pwr_in, __nr_t nr_alloc) memset(st_pwr_in, 0, STATS_PWR_IN_SIZE); while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) { + i = 0; while ((feature = sensors_get_features(chip, &i))) { + if (feature->type == SENSORS_FEATURE_IN) { j = 0; if (in_read + 1 > nr_alloc) @@ -207,6 +215,7 @@ __nr_t read_in(struct stats_pwr_in *st_pwr_in, __nr_t nr_alloc) sensors_snprintf_chip_name(st_pwr_in_i->device, MAX_SENSORS_DEV_LEN, chip); while ((sub = sensors_get_all_subfeatures(chip, feature, &j))) { + if ((sub->type == SENSORS_SUBFEATURE_IN_INPUT) && (sub->flags & SENSORS_MODE_R)) { if (sensors_get_value(chip, sub->number, &st_pwr_in_i->in)) { @@ -254,8 +263,10 @@ __nr_t get_sensors_nr(sensors_feature_type type) { int i; while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) { + i = 0; while ((feature = sensors_get_features(chip, &i))) { + if (feature->type == type) { count++; } diff --git a/rd_stats.c b/rd_stats.c index 06aceff..3b11598 100644 --- a/rd_stats.c +++ b/rd_stats.c @@ -210,9 +210,11 @@ __nr_t read_stat_irq(struct stats_irq *st_irq, __nr_t nr_alloc, __nr_t nr_int) * Parse header line to see which CPUs are online */ while (fgets(line, INTERRUPTS_LINE + 11 * cpu_nr, fp) != NULL) { + next = line; while (((cp = strstr(next, "CPU")) != NULL) && (index < cpu_nr)) { cpu = strtol(cp + 3, &next, 10); + if (cpu + 2 > nr_alloc) { rc = -1; goto out; @@ -570,6 +572,7 @@ void oct2chr(char *str) len = strlen(str); while (i < len - 3) { + if ((str[i] == '\\') && (str[i + 1] >= '0') && (str[i + 1] <= '3') && (str[i + 2] >= '0') && (str[i + 2] <= '7') && diff --git a/sa_common.c b/sa_common.c index c2c8ce1..da22ee0 100644 --- a/sa_common.c +++ b/sa_common.c @@ -427,6 +427,7 @@ int write_all(int fd, const void *buf, int nr_bytes) char *buffer = (char *) buf; while (nr_bytes > 0) { + block = write(fd, &buffer[offset], nr_bytes); if (block < 0) { diff --git a/tapestat.c b/tapestat.c index 3d5795e..e3d57ad 100644 --- a/tapestat.c +++ b/tapestat.c @@ -178,6 +178,7 @@ int get_max_tape_drives(void) return 0; while ((entry = readdir(dir)) != NULL) { + if (regexec(&tape_reg, &entry->d_name[0], 1, &match, 0) == 0) { /* d_name[2] to skip the st at the front */ tmp = atoi(&entry->d_name[2]) + 1; -- 2.50.1