]> granicus.if.org Git - sysstat/commitdiff
sa_common.c: Simplify a bit read_stat_bunch() function
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 16 Sep 2017 14:13:06 +0000 (16:13 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 16 Sep 2017 14:13:06 +0000 (16:13 +0200)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sa_common.c

index 07bff87c558cf3c76231b26934920d11bcf9e8b5..82c0f41821a103ec9f6a026cff415633bf8446ac 100644 (file)
@@ -1134,7 +1134,7 @@ void copy_structures(struct activity *act[], unsigned int id_seq[],
 void read_file_stat_bunch(struct activity *act[], int curr, int ifd, int act_nr,
                          struct file_activity *file_actlst)
 {
-       int i, j, k, p;
+       int i, j, p;
        struct file_activity *fal = file_actlst;
        off_t offset;
 
@@ -1152,16 +1152,16 @@ void read_file_stat_bunch(struct activity *act[], int curr, int ifd, int act_nr,
                                perror("lseek");
                                exit(2);
                        }
+                       continue;
                }
-               else if ((act[p]->nr > 0) &&
+
+               if ((act[p]->nr > 0) &&
                         ((act[p]->nr > 1) || (act[p]->nr2 > 1)) &&
                         (act[p]->msize > act[p]->fsize)) {
-                       for (j = 0; j < act[p]->nr; j++) {
-                               for (k = 0; k < act[p]->nr2; k++) {
-                                       sa_fread(ifd,
-                                                (char *) act[p]->buf[curr] + (j * act[p]->nr2 + k) * act[p]->msize,
-                                                act[p]->fsize, HARD_SIZE);
-                               }
+
+                       for (j = 0; j < (act[p]->nr * act[p]->nr2); j++) {
+                               sa_fread(ifd, (char *) act[p]->buf[curr] + j * act[p]->msize,
+                                        act[p]->fsize, HARD_SIZE);
                        }
                }
                else if (act[p]->nr > 0) {