sadf: Don't use an array for tot_jiffies variable
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 16 Dec 2017 09:24:25 +0000 (10:24 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 16 Dec 2017 09:24:25 +0000 (10:24 +0100)
See commit 624374b.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
json_stats.c
rndr_stats.c
svg_stats.c
xml_stats.c

index 8027491c36833971cdb9b790c52369ad63cf7b63..685173db4fa7cd4aa49aecd78fa88ca168b18c75 100644 (file)
@@ -112,7 +112,7 @@ __print_funct_t json_print_cpu_stats(struct activity *a, int curr, int tab,
 {
        int i, cpu_offline;
        int sep = FALSE;
-       unsigned long long tot_jiffies[3];
+       unsigned long long tot_jiffies_c, tot_jiffies_p;
        unsigned long long deltot_jiffies;
        struct stats_cpu *scc, *scp;
        char cpuno[8];
@@ -134,17 +134,17 @@ __print_funct_t json_print_cpu_stats(struct activity *a, int curr, int tab,
                 * NB: Don't add cpu_guest/cpu_guest_nice because cpu_user/cpu_nice
                 * already include them.
                 */
-               tot_jiffies[curr] = scc->cpu_user + scc->cpu_nice +
-                                   scc->cpu_sys + scc->cpu_idle +
-                                   scc->cpu_iowait + scc->cpu_hardirq +
-                                   scc->cpu_steal + scc->cpu_softirq;
-               tot_jiffies[!curr] = scp->cpu_user + scp->cpu_nice +
-                                    scp->cpu_sys + scp->cpu_idle +
-                                    scp->cpu_iowait + scp->cpu_hardirq +
-                                    scp->cpu_steal + scp->cpu_softirq;
+               tot_jiffies_c = scc->cpu_user + scc->cpu_nice +
+                               scc->cpu_sys + scc->cpu_idle +
+                               scc->cpu_iowait + scc->cpu_hardirq +
+                               scc->cpu_steal + scc->cpu_softirq;
+               tot_jiffies_p = scp->cpu_user + scp->cpu_nice +
+                               scp->cpu_sys + scp->cpu_idle +
+                               scp->cpu_iowait + scp->cpu_hardirq +
+                               scp->cpu_steal + scp->cpu_softirq;
 
                /* Total number of jiffies spent on the interval */
-               deltot_jiffies = get_interval(tot_jiffies[!curr], tot_jiffies[curr]);
+               deltot_jiffies = get_interval(tot_jiffies_p, tot_jiffies_c);
 
                if (sep) {
                        printf(",\n");
@@ -164,7 +164,7 @@ __print_funct_t json_print_cpu_stats(struct activity *a, int curr, int tab,
                         * (Remember that guest/guest_nice times are already included in
                         * user/nice modes.)
                         */
-                       if (tot_jiffies[curr] == 0) {
+                       if (tot_jiffies_c == 0) {
                                /*
                                 * Set current struct fields (which have been set to zero)
                                 * to values from previous iteration. Hence their values won't
index 1cfe5ddce8efc8235d18a2aa438de5f3b205b816..33925d2b505e16b421004c1db4c1e691224c2f67 100644 (file)
@@ -171,7 +171,7 @@ __print_funct_t render_cpu_stats(struct activity *a, int isdb, char *pre,
                                 int curr, unsigned long long itv)
 {
        int i, cpu_offline;
-       unsigned long long tot_jiffies[3];
+       unsigned long long tot_jiffies_p, tot_jiffies_c;
        unsigned long long deltot_jiffies;
        struct stats_cpu *scc, *scp;
        int pt_newlin
@@ -192,17 +192,17 @@ __print_funct_t render_cpu_stats(struct activity *a, int isdb, char *pre,
                 * NB: Don't add cpu_guest/cpu_guest_nice because cpu_user/cpu_nice
                 * already include them.
                 */
-               tot_jiffies[curr] = scc->cpu_user + scc->cpu_nice +
-                                   scc->cpu_sys + scc->cpu_idle +
-                                   scc->cpu_iowait + scc->cpu_hardirq +
-                                   scc->cpu_steal + scc->cpu_softirq;
-               tot_jiffies[!curr] = scp->cpu_user + scp->cpu_nice +
-                                    scp->cpu_sys + scp->cpu_idle +
-                                    scp->cpu_iowait + scp->cpu_hardirq +
-                                    scp->cpu_steal + scp->cpu_softirq;
+               tot_jiffies_c = scc->cpu_user + scc->cpu_nice +
+                               scc->cpu_sys + scc->cpu_idle +
+                               scc->cpu_iowait + scc->cpu_hardirq +
+                               scc->cpu_steal + scc->cpu_softirq;
+               tot_jiffies_p = scp->cpu_user + scp->cpu_nice +
+                               scp->cpu_sys + scp->cpu_idle +
+                               scp->cpu_iowait + scp->cpu_hardirq +
+                               scp->cpu_steal + scp->cpu_softirq;
 
                /* Total number of jiffies spent on the interval */
-               deltot_jiffies = get_interval(tot_jiffies[!curr], tot_jiffies[curr]);
+               deltot_jiffies = get_interval(tot_jiffies_p, tot_jiffies_c);
 
                if (!i) {
                        /* This is CPU "all" */
@@ -317,7 +317,7 @@ __print_funct_t render_cpu_stats(struct activity *a, int isdb, char *pre,
                         * (Remember that guest/guest_nice times are already included in
                         * user/nice modes.)
                         */
-                       if (tot_jiffies[curr] == 0) {
+                       if (tot_jiffies_c == 0) {
                                /*
                                 * Set current struct fields (which have been set to zero)
                                 * to values from previous iteration. Hence their values won't
index b1d6a8832c0513fb4bb8bc11a9cc3760a5b8e324..af8beb216b787d4a521bdb6179c84ba900f50b31 100644 (file)
@@ -1010,7 +1010,7 @@ __print_funct_t svg_print_cpu_stats(struct activity *a, int curr, int action, st
                                    unsigned long long itv, struct record_header *record_hdr)
 {
        struct stats_cpu *scc, *scp;
-       unsigned long long tot_jiffies[3];
+       unsigned long long tot_jiffies_c, tot_jiffies_p;
        unsigned long long deltot_jiffies;
        int group1[] = {5};
        int group2[] = {9};
@@ -1050,17 +1050,17 @@ __print_funct_t svg_print_cpu_stats(struct activity *a, int curr, int action, st
                         * NB: Don't add cpu_guest/cpu_guest_nice because cpu_user/cpu_nice
                         * already include them.
                         */
-                       tot_jiffies[curr] = scc->cpu_user + scc->cpu_nice +
-                                           scc->cpu_sys + scc->cpu_idle +
-                                           scc->cpu_iowait + scc->cpu_hardirq +
-                                           scc->cpu_steal + scc->cpu_softirq;
-                       tot_jiffies[!curr] = scp->cpu_user + scp->cpu_nice +
-                                            scp->cpu_sys + scp->cpu_idle +
-                                            scp->cpu_iowait + scp->cpu_hardirq +
-                                            scp->cpu_steal + scp->cpu_softirq;
+                       tot_jiffies_c = scc->cpu_user + scc->cpu_nice +
+                                       scc->cpu_sys + scc->cpu_idle +
+                                       scc->cpu_iowait + scc->cpu_hardirq +
+                                       scc->cpu_steal + scc->cpu_softirq;
+                       tot_jiffies_p = scp->cpu_user + scp->cpu_nice +
+                                       scp->cpu_sys + scp->cpu_idle +
+                                       scp->cpu_iowait + scp->cpu_hardirq +
+                                       scp->cpu_steal + scp->cpu_softirq;
 
                        /* Total number of jiffies spent on the interval */
-                       deltot_jiffies = get_interval(tot_jiffies[!curr], tot_jiffies[curr]);
+                       deltot_jiffies = get_interval(tot_jiffies_p, tot_jiffies_c);
 
                        pos = i * 10;
                        offset = 0.0;
@@ -1072,7 +1072,7 @@ __print_funct_t svg_print_cpu_stats(struct activity *a, int curr, int action, st
                                 * (Remember that guest/guest_nice times are already included in
                                 * user/nice modes.)
                                 */
-                               if (tot_jiffies[curr] == 0) {
+                               if (tot_jiffies_c == 0) {
                                        /*
                                         * Set current struct fields (which have been set to zero)
                                         * to values from previous iteration. Hence their values won't
index 34be014821b4ed237ca9d90f9c6a40329ff478c8..20072f8b238d02dc342d76b0903d94cf525457b8 100644 (file)
@@ -109,7 +109,7 @@ __print_funct_t xml_print_cpu_stats(struct activity *a, int curr, int tab,
                                    unsigned long long itv)
 {
        int i, cpu_offline;
-       unsigned long long tot_jiffies[3];
+       unsigned long long tot_jiffies_p, tot_jiffies_c;
        unsigned long long deltot_jiffies;
        struct stats_cpu *scc, *scp;
        char cpuno[8];
@@ -131,17 +131,17 @@ __print_funct_t xml_print_cpu_stats(struct activity *a, int curr, int tab,
                 * NB: Don't add cpu_guest/cpu_guest_nice because cpu_user/cpu_nice
                 * already include them.
                 */
-               tot_jiffies[curr] = scc->cpu_user + scc->cpu_nice +
-                                   scc->cpu_sys + scc->cpu_idle +
-                                   scc->cpu_iowait + scc->cpu_hardirq +
-                                   scc->cpu_steal + scc->cpu_softirq;
-               tot_jiffies[!curr] = scp->cpu_user + scp->cpu_nice +
-                                    scp->cpu_sys + scp->cpu_idle +
-                                    scp->cpu_iowait + scp->cpu_hardirq +
-                                    scp->cpu_steal + scp->cpu_softirq;
+               tot_jiffies_c = scc->cpu_user + scc->cpu_nice +
+                               scc->cpu_sys + scc->cpu_idle +
+                               scc->cpu_iowait + scc->cpu_hardirq +
+                               scc->cpu_steal + scc->cpu_softirq;
+               tot_jiffies_p = scp->cpu_user + scp->cpu_nice +
+                               scp->cpu_sys + scp->cpu_idle +
+                               scp->cpu_iowait + scp->cpu_hardirq +
+                               scp->cpu_steal + scp->cpu_softirq;
 
                /* Total number of jiffies spent on the interval */
-               deltot_jiffies = get_interval(tot_jiffies[!curr], tot_jiffies[curr]);
+               deltot_jiffies = get_interval(tot_jiffies_p, tot_jiffies_c);
 
                if (!i) {
                        /* This is CPU "all" */
@@ -156,7 +156,7 @@ __print_funct_t xml_print_cpu_stats(struct activity *a, int curr, int tab,
                         * (Remember that guest/guest_nice times are already included in
                         * user/nice modes.)
                         */
-                       if (tot_jiffies[curr] == 0) {
+                       if (tot_jiffies_c == 0) {
                                /*
                                 * Set current struct fields (which have been set to zero)
                                 * to values from previous iteration. Hence their values won't