for (i = 0; i < a->nr[curr]; i++) {
- ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
+ found = FALSE;
- /* Look for corresponding serial line in previous iteration */
- j = i;
- if (j > a->nr[!curr]) {
- j = a->nr[!curr];
- }
+ if (a->nr[!curr] > 0) {
+ ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
- j0 = j;
- found = FALSE;
+ /* Look for corresponding serial line in previous iteration */
+ j = i;
- do {
- if (j > a->nr[!curr]) {
- j = 0;
+ if (j >= a->nr[!curr]) {
+ j = a->nr[!curr] - 1;
}
- ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
- if (ssc->line == ssp->line) {
- found = TRUE;
- break;
+
+ j0 = j;
+
+ do {
+ ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
+ if (ssc->line == ssp->line) {
+ found = TRUE;
+ break;
+ }
+ if (++j >= a->nr[!curr]) {
+ j = 0;
+ }
}
- j++;
+ while (j != j0);
}
- while (j != j0);
if (!found)
continue;
xprintf(tab++, "\"fchosts\": [");
for (i = 0; i < a->nr[curr]; i++) {
- sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
- /* Look for corresponding structure in previous iteration */
- j = i;
- if (j > a->nr[!curr]) {
- j = a->nr[!curr];
- }
-
- j0 = j;
found = FALSE;
- do {
- if (j > a->nr[!curr]) {
- j = 0;
+ if (a->nr[!curr] > 0) {
+ sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+
+ /* Look for corresponding structure in previous iteration */
+ j = i;
+
+ if (j >= a->nr[!curr]) {
+ j = a->nr[!curr] - 1;
}
- sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
- if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
- found = TRUE;
- break;
+
+ j0 = j;
+
+ do {
+ sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
+ if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+ found = TRUE;
+ break;
+ }
+ if (++j >= a->nr[!curr]) {
+ j = 0;
+ }
}
- j++;
+ while (j != j0);
}
- while (j != j0);
if (!found)
continue;
for (i = 0; i < a->nr[curr]; i++) {
- ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
+ found = FALSE;
- /* Look for corresponding serial line in previous iteration */
- j = i;
- if (j > a->nr[prev]) {
- j = a->nr[prev];
- }
+ if (a->nr[prev] > 0) {
+ ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
- j0 = j;
- found = FALSE;
+ /* Look for corresponding serial line in previous iteration */
+ j = i;
- do {
- if (j > a->nr[prev]) {
- j = 0;
+ if (j >= a->nr[prev]) {
+ j = a->nr[prev] - 1;
}
- ssp = (struct stats_serial *) ((char *) a->buf[prev] + j * a->msize);
- if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
- found = TRUE;
- break;
+
+ j0 = j;
+
+ do {
+ ssp = (struct stats_serial *) ((char *) a->buf[prev] + j * a->msize);
+ if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
+ found = TRUE;
+ break;
+ }
+ if (++j >= a->nr[prev]) {
+ j = 0;
+ }
}
- j++;
+ while (j != j0);
}
- while (j != j0);
if (!found)
continue;
for (i = 0; i < a->nr[curr]; i++) {
- sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+ found = FALSE;
- /* Look for corresponding structure in previous iteration */
- j = i;
- if (j > a->nr[prev]) {
- j = a->nr[prev];
- }
+ if (a->nr[prev] > 0) {
+ sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
- j0 = j;
- found = FALSE;
+ /* Look for corresponding structure in previous iteration */
+ j = i;
- do {
- if (j > a->nr[prev]) {
- j = 0;
+ if (j >= a->nr[prev]) {
+ j = a->nr[prev] - 1;
}
- sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + j * a->msize);
- if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
- found = TRUE;
- break;
+
+ j0 = j;
+
+ do {
+ sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + j * a->msize);
+ if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+ found = TRUE;
+ break;
+ }
+
+ if (++j >= a->nr[prev]) {
+ j = 0;
+ }
}
- j++;
+ while (j != j0);
}
- while (j != j0);
if (!found)
continue;
for (i = 0; i < a->nr[curr]; i++) {
+ found = FALSE;
ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
- /* Look for corresponding serial line in previous iteration */
- j = i;
- if (j > a->nr[!curr]) {
- j = a->nr[!curr];
- }
+ if (a->nr[!curr] > 0) {
- j0 = j;
- found = FALSE;
+ /* Look for corresponding serial line in previous iteration */
+ j = i;
- do {
- if (j > a->nr[!curr]) {
- j = 0;
+ if (j >= a->nr[!curr]) {
+ j = a->nr[!curr] - 1;
}
- ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
- if (ssc->line == ssp->line) {
- found = TRUE;
- break;
+
+ j0 = j;
+
+ do {
+ ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
+ if (ssc->line == ssp->line) {
+ found = TRUE;
+ break;
+ }
+ if (++j >= a->nr[!curr]) {
+ j = 0;
+ }
}
- j++;
+ while (j != j0);
}
- while (j != j0);
printf("%s %s: %u", timestr, pfield(a->hdr_line, FIRST), ssc->line);
}
for (i = 0; i < a->nr[curr]; i++) {
- sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
- /* Look for corresponding structure in previous iteration */
- j = i;
- if (j > a->nr[!curr]) {
- j = a->nr[!curr];
- }
-
- j0 = j;
found = FALSE;
- do {
- if (j > a->nr[!curr]) {
- j = 0;
+ if (a->nr[!curr] > 0) {
+ sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+
+ /* Look for corresponding structure in previous iteration */
+ j = i;
+
+ if (j >= a->nr[!curr]) {
+ j = a->nr[!curr] - 1;
}
- sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
- if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
- found = TRUE;
- break;
+
+ j0 = j;
+
+ do {
+ sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
+ if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+ found = TRUE;
+ break;
+ }
+ if (++j >= a->nr[!curr]) {
+ j = 0;
+ }
}
- j++;
+ while (j != j0);
}
- while (j != j0);
if (!found)
continue;
for (i = 0; i < a->nr[curr]; i++) {
- ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
+ found = FALSE;
- /* Look for corresponding serial line in previous iteration */
- j = i;
- if (j > a->nr[!curr]) {
- j = a->nr[!curr];
- }
+ if (a->nr[!curr] > 0) {
+ ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
- j0 = j;
- found = FALSE;
+ /* Look for corresponding serial line in previous iteration */
+ j = i;
- do {
- if (j > a->nr[!curr]) {
- j = 0;
+ if (j >= a->nr[!curr]) {
+ j = a->nr[!curr] - 1;
}
- ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
- if (ssc->line == ssp->line) {
- found = TRUE;
- break;
+
+ j0 = j;
+
+ do {
+ ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
+ if (ssc->line == ssp->line) {
+ found = TRUE;
+ break;
+ }
+ if (++j >= a->nr[!curr]) {
+ j = 0;
+ }
}
- j++;
+ while (j != j0);
}
- while (j != j0);
if (!found)
continue;
struct stats_fchost *sfcc, *sfcp;
for (i = 0; i < a->nr[curr]; i++) {
- sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
- /* Look for corresponding structure in previous iteration */
- j = i;
- if (j > a->nr[!curr]) {
- j = a->nr[!curr];
- }
-
- j0 = j;
found = FALSE;
- do {
- if (j > a->nr[!curr]) {
- j = 0;
+ if (a->nr[!curr] > 0) {
+ sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+
+ /* Look for corresponding structure in previous iteration */
+ j = i;
+
+ if (j >= a->nr[!curr]) {
+ j = a->nr[!curr] - 1;
}
- sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
- if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
- found = TRUE;
- break;
+
+ j0 = j;
+
+ do {
+ sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
+ if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+ found = TRUE;
+ break;
+ }
+ if (++j >= a->nr[!curr]) {
+ j = 0;
+ }
}
- j++;
+ while (j != j0);
}
- while (j != j0);
if (!found)
continue;
int check_net_dev_reg(struct activity *a, int curr, int ref, int pos)
{
struct stats_net_dev *sndc, *sndp;
- int j0, j= pos;
+ int j0, j = pos;
- if (j > a->nr[ref]) {
- j = a->nr[ref];
+ if (!a->nr[ref])
+ /*
+ * No items found in previous iteration:
+ * Current interface is necessarily new.
+ */
+ return -1;
+
+ if (j >= a->nr[ref]) {
+ j = a->nr[ref] - 1;
}
j0 = j;
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + pos * a->msize);
do {
- if (j > a->nr[ref]) {
- j = 0;
- }
sndp = (struct stats_net_dev *) ((char *) a->buf[ref] + j * a->msize);
if (!strcmp(sndc->interface, sndp->interface)) {
}
return j;
}
- j++;
+ if (++j >= a->nr[ref]) {
+ j = 0;
+ }
}
while (j != j0);
struct stats_net_edev *snedc, *snedp;
int j0, j = pos;
- if (j > a->nr[ref]) {
- j = a->nr[ref];
+ if (!a->nr[ref])
+ /*
+ * No items found in previous iteration:
+ * Current interface is necessarily new.
+ */
+ return -1;
+
+ if (j >= a->nr[ref]) {
+ j = a->nr[ref] - 1;
}
j0 = j;
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + pos * a->msize);
do {
- if (j > a->nr[ref]) {
- j = 0;
- }
snedp = (struct stats_net_edev *) ((char *) a->buf[ref] + j * a->msize);
if (!strcmp(snedc->interface, snedp->interface)) {
return j;
}
- j++;
+ if (++j >= a->nr[ref]) {
+ j = 0;
+ }
}
while (j != j0);
struct stats_disk *sdc, *sdp;
int j0, j = pos;
- if (j > a->nr[ref]) {
- j = a->nr[ref];
+ if (!a->nr[ref])
+ /*
+ * No items found in previous iteration:
+ * Current interface is necessarily new.
+ */
+ return -1;
+
+ if (j >= a->nr[ref]) {
+ j = a->nr[ref] - 1;
}
j0 = j;
sdc = (struct stats_disk *) ((char *) a->buf[curr] + pos * a->msize);
do {
- if (j > a->nr[ref]) {
- j = 0;
- }
sdp = (struct stats_disk *) ((char *) a->buf[ref] + j * a->msize);
if ((sdc->major == sdp->major) &&
return j;
}
- j++;
+ if (++j >= a->nr[ref]) {
+ j = 0;
+ }
}
while (j != j0);
/* For each FC HBA */
for (i = 0; i < a->nr[curr]; i++) {
- sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
- /* Look for corresponding graph */
- for (k = 0; k < svg_p->nr_max; k++) {
- item_name = *(out + k * 5 + 4);
- if (!strcmp(sfcc->fchost_name, item_name))
- /* Graph found! */
- break;
- }
- if (k == svg_p->nr_max) {
- /* Graph not found: Look for first free entry */
+ found = FALSE;
+
+ if (a->nr[!curr] > 0) {
+ sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+
+ /* Look for corresponding graph */
for (k = 0; k < svg_p->nr_max; k++) {
item_name = *(out + k * 5 + 4);
- if (!strcmp(item_name, ""))
+ if (!strcmp(sfcc->fchost_name, item_name))
+ /* Graph found! */
break;
}
if (k == svg_p->nr_max) {
- /* No free graph entry: Extend all buffers */
- reallocate_all_graph_lines(svg_p->nr_max,
- &out, &outsize, &spmin, &spmax);
- svg_p->nr_max *= 2;
+ /* Graph not found: Look for first free entry */
+ for (k = 0; k < svg_p->nr_max; k++) {
+ item_name = *(out + k * 5 + 4);
+ if (!strcmp(item_name, ""))
+ break;
+ }
+ if (k == svg_p->nr_max) {
+ /* No free graph entry: Extend all buffers */
+ reallocate_all_graph_lines(svg_p->nr_max,
+ &out, &outsize, &spmin, &spmax);
+ svg_p->nr_max *= 2;
+ }
}
- }
- pos = k * 5;
- unregistered = outsize + pos + 4;
+ pos = k * 5;
+ unregistered = outsize + pos + 4;
- /* Look for corresponding structure in previous iteration */
- j = i;
- if (j > a->nr[!curr]) {
- j = a->nr[!curr];
- }
-
- j0 = j;
- found = FALSE;
+ /* Look for corresponding structure in previous iteration */
+ j = i;
- do {
- if (j > a->nr[!curr]) {
- j = 0;
+ if (j >= a->nr[!curr]) {
+ j = a->nr[!curr] - 1;
}
- sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
- if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
- found = TRUE;
- break;
+
+ j0 = j;
+
+ do {
+ sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
+ if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+ found = TRUE;
+ break;
+ }
+ if (++j >= a->nr[!curr]) {
+ j = 0;
+ }
}
- j++;
+ while (j != j0);
}
- while (j != j0);
if (!found)
continue;
for (i = 0; i < a->nr[curr]; i++) {
- ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
+ found = FALSE;
- /* Look for corresponding serial line in previous iteration */
- j = i;
- if (j > a->nr[!curr]) {
- j = a->nr[!curr];
- }
+ if (a->nr[!curr] > 0) {
+ ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
- j0 = j;
- found = FALSE;
+ /* Look for corresponding serial line in previous iteration */
+ j = i;
- do {
- if (j > a->nr[!curr]) {
- j = 0;
+ if (j >= a->nr[!curr]) {
+ j = a->nr[!curr] - 1;
}
- ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
- if (ssc->line == ssp->line) {
- found = TRUE;
- break;
+
+ j0 = j;
+
+ do {
+ ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
+ if (ssc->line == ssp->line) {
+ found = TRUE;
+ break;
+ }
+ if (++j >= a->nr[!curr]) {
+ j = 0;
+ }
}
- j++;
+ while (j != j0);
}
- while (j != j0);
if (!found)
continue;
tab++;
for (i = 0; i < a->nr[curr]; i++) {
- sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
- /* Look for corresponding structure in previous iteration */
- j = i;
- if (j > a->nr[!curr]) {
- j = a->nr[!curr];
- }
-
- j0 = j;
found = FALSE;
- do {
- if (j > a->nr[!curr]) {
- j = 0;
+ if (a->nr[!curr] > 0) {
+ sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+
+ /* Look for corresponding structure in previous iteration */
+ j = i;
+
+ if (j >= a->nr[!curr]) {
+ j = a->nr[!curr] - 1;
}
- sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
- if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
- found = TRUE;
- break;
+
+ j0 = j;
+
+ do {
+ sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
+ if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+ found = TRUE;
+ break;
+ }
+ if (++j >= a->nr[!curr]) {
+ j = 0;
+ }
}
- j++;
+ while (j != j0);
}
- while (j != j0);
if (!found)
continue;