Xinqi Bao's Git

Clean up header includes
[slstatus.git] / components / disk.c
index f4031ea..9d2284e 100644 (file)
@@ -1,7 +1,5 @@
 /* See LICENSE file for copyright and license details. */
-#include <errno.h>
 #include <stdio.h>
-#include <string.h>
 #include <sys/statvfs.h>
 
 #include "../util.h"
@@ -16,8 +14,7 @@ disk_free(const char *mnt)
                return NULL;
        }
 
-       return bprintf("%f",
-                      (float)fs.f_frsize * (float)fs.f_bavail / 1024 / 1024 / 1024);
+       return fmt_human(fs.f_frsize * fs.f_bavail, 1024);
 }
 
 const char *
@@ -44,8 +41,7 @@ disk_total(const char *mnt)
                return NULL;
        }
 
-       return bprintf("%f",
-                      (float)fs.f_frsize * (float)fs.f_blocks / 1024 / 1024 / 1024);
+       return fmt_human(fs.f_frsize * fs.f_blocks, 1024);
 }
 
 const char *
@@ -58,7 +54,5 @@ disk_used(const char *mnt)
                return NULL;
        }
 
-       return bprintf("%f",
-                      (float)fs.f_frsize * ((float)fs.f_blocks -
-                      (float)fs.f_bfree) / 1024 / 1024 / 1024);
+       return fmt_human(fs.f_frsize * (fs.f_blocks - fs.f_bfree), 1024);
 }