Xinqi Bao's Git

Add the percent sign to *_perc functions
authorAaron Marcher <[email protected]>
Sat, 19 May 2018 18:33:06 +0000 (20:33 +0200)
committerAaron Marcher <[email protected]>
Sat, 19 May 2018 18:33:06 +0000 (20:33 +0200)
Units should be added to the corresponding numbers

components/battery.c
components/cpu.c
components/disk.c
components/ram.c
components/swap.c
components/volume.c
components/wifi.c

index bcd42cd..5031608 100644 (file)
@@ -23,7 +23,7 @@
                        return NULL;
                }
 
                        return NULL;
                }
 
-               return bprintf("%d", perc);
+               return bprintf("%d%%", perc);
        }
 
        const char *
        }
 
        const char *
                struct apm_power_info apm_info;
 
                if (load_apm_power_info(&apm_info)) {
                struct apm_power_info apm_info;
 
                if (load_apm_power_info(&apm_info)) {
-                       return bprintf("%d", apm_info.battery_life);
+                       return bprintf("%d%%", apm_info.battery_life);
                }
 
                return NULL;
                }
 
                return NULL;
index 60a7991..e333f97 100644 (file)
@@ -34,7 +34,7 @@
                        return NULL;
                }
 
                        return NULL;
                }
 
-               return bprintf("%d", (int)(100 *
+               return bprintf("%d%%", (int)(100 *
                               ((b[0] + b[1] + b[2] + b[5] + b[6]) -
                                (a[0] + a[1] + a[2] + a[5] + a[6])) /
                               ((b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6]) -
                               ((b[0] + b[1] + b[2] + b[5] + b[6]) -
                                (a[0] + a[1] + a[2] + a[5] + a[6])) /
                               ((b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6]) -
@@ -88,7 +88,7 @@
                        return NULL;
                }
 
                        return NULL;
                }
 
-               return bprintf("%d", 100 *
+               return bprintf("%d%%", 100 *
                               ((a[CP_USER] + a[CP_NICE] + a[CP_SYS] + a[CP_INTR]) -
                                (b[CP_USER] + b[CP_NICE] + b[CP_SYS] + b[CP_INTR])) /
                               ((a[CP_USER] + a[CP_NICE] + a[CP_SYS] + a[CP_INTR] +
                               ((a[CP_USER] + a[CP_NICE] + a[CP_SYS] + a[CP_INTR]) -
                                (b[CP_USER] + b[CP_NICE] + b[CP_SYS] + b[CP_INTR])) /
                               ((a[CP_USER] + a[CP_NICE] + a[CP_SYS] + a[CP_INTR] +
index 00deea2..db18d12 100644 (file)
@@ -29,7 +29,7 @@ disk_perc(const char *mnt)
                return NULL;
        }
 
                return NULL;
        }
 
-       return bprintf("%d", (int)(100 *
+       return bprintf("%d%%", (int)(100 *
                       (1.0f - ((float)fs.f_bavail / (float)fs.f_blocks))));
 }
 
                       (1.0f - ((float)fs.f_bavail / (float)fs.f_blocks))));
 }
 
index 8f96b04..0eb2ea9 100644 (file)
@@ -28,7 +28,7 @@
                               "MemAvailable: %ld kB\nBuffers: %ld kB\n"
                               "Cached: %ld kB\n",
                               &total, &free, &buffers, &buffers, &cached) == 5) ?
                               "MemAvailable: %ld kB\nBuffers: %ld kB\n"
                               "Cached: %ld kB\n",
                               &total, &free, &buffers, &buffers, &cached) == 5) ?
-                      bprintf("%d", 100 * ((total - free) - (buffers + cached)) /
+                      bprintf("%d%%", 100 * ((total - free) - (buffers + cached)) /
                               total) :
                       NULL;
        }
                               total) :
                       NULL;
        }
@@ -97,7 +97,7 @@
 
                if (load_uvmexp(&uvmexp)) {
                        percent = uvmexp.active * 100 / uvmexp.npages;
 
                if (load_uvmexp(&uvmexp)) {
                        percent = uvmexp.active * 100 / uvmexp.npages;
-                       return bprintf("%d", percent);
+                       return bprintf("%d%%", percent);
                }
 
                return NULL;
                }
 
                return NULL;
index 73d24df..64feceb 100644 (file)
@@ -76,7 +76,7 @@
                }
                sscanf(match, "SwapFree: %ld kB\n", &free);
 
                }
                sscanf(match, "SwapFree: %ld kB\n", &free);
 
-               return bprintf("%d", 100 * (total - free - cached) / total);
+               return bprintf("%d%%", 100 * (total - free - cached) / total);
        }
 
        const char *
        }
 
        const char *
 
                getstats(&total, &used);
 
 
                getstats(&total, &used);
 
-               return bprintf("%d", 100 * used / total);
+               return bprintf("%d%%", 100 * used / total);
        }
 
        const char *
        }
 
        const char *
index 8674211..0bfbe08 100644 (file)
@@ -42,5 +42,5 @@ vol_perc(const char *card)
 
        close(afd);
 
 
        close(afd);
 
-       return bprintf("%d", v & 0xff);
+       return bprintf("%d%%", v & 0xff);
 }
 }
index b3e1723..389adab 100644 (file)
@@ -60,7 +60,7 @@
                sscanf(datastart + 1, " %*d   %d  %*d  %*d\t\t  %*d\t   "
                       "%*d\t\t%*d\t\t %*d\t  %*d\t\t %*d", &cur);
 
                sscanf(datastart + 1, " %*d   %d  %*d  %*d\t\t  %*d\t   "
                       "%*d\t\t%*d\t\t %*d\t  %*d\t\t %*d", &cur);
 
-               return bprintf("%d", (int)((float)cur / total * 100));
+               return bprintf("%d%%", (int)((float)cur / total * 100));
        }
 
        const char *
        }
 
        const char *
                                q = nr.nr_rssi >= -50 ? 100 : (nr.nr_rssi <= -100 ? 0 :
                                (2 * (nr.nr_rssi + 100)));
                        }
                                q = nr.nr_rssi >= -50 ? 100 : (nr.nr_rssi <= -100 ? 0 :
                                (2 * (nr.nr_rssi + 100)));
                        }
-                       return bprintf("%d", q);
+                       return bprintf("%d%%", q);
                }
 
                return NULL;
                }
 
                return NULL;