Xinqi Bao's Git

(void)ed the prototypes
[slstatus.git] / slstatus.c
index 3ea29d1..40aaa19 100644 (file)
@@ -36,38 +36,38 @@ struct arg {
        const char *args;
 };
 
-void setstatus(const char *);
-char *smprintf(const char *, ...);
-char *battery_perc(const char *);
-char *cpu_perc(const char *);
-char *datetime(const char *);
-char *disk_free(const char *);
-char *disk_perc(const char *);
-char *disk_total(const char *);
-char *disk_used(const char *);
-char *entropy(const char *);
-char *gid(const char *);
-char *hostname(const char *);
-char *ip(const char *);
-char *load_avg(const char *);
-char *ram_free(const char *);
-char *ram_perc(const char *);
-char *ram_used(const char *);
-char *ram_total(const char *);
-char *run_command(const char *);
-char *temp(const char *);
-char *uid(const char *);
-char *uptime(const char *);
-char *username(const char *);
-char *vol_perc(const char *);
-char *wifi_perc(const char *);
-char *wifi_essid(const char *);
+static void setstatus(const char *);
+static char *smprintf(const char *, ...);
+static char *battery_perc(const char *);
+static char *cpu_perc(void);
+static char *datetime(const char *);
+static char *disk_free(const char *);
+static char *disk_perc(const char *);
+static char *disk_total(const char *);
+static char *disk_used(const char *);
+static char *entropy(void);
+static char *gid(void);
+static char *hostname(void);
+static char *ip(const char *);
+static char *load_avg(void);
+static char *ram_free(void);
+static char *ram_perc(void);
+static char *ram_used(void);
+static char *ram_total(void);
+static char *run_command(const char *);
+static char *temp(const char *);
+static char *uid(void);
+static char *uptime(void);
+static char *username(void);
+static char *vol_perc(const char *);
+static char *wifi_perc(const char *);
+static char *wifi_essid(const char *);
 
 static Display *dpy;
 
 #include "config.h"
 
-void
+static void
 setstatus(const char *str)
 {
        /* set WM_NAME via X11 */
@@ -75,7 +75,7 @@ setstatus(const char *str)
        XSync(dpy, False);
 }
 
-char *
+static char *
 smprintf(const char *fmt, ...)
 {
        va_list fmtargs;
@@ -89,7 +89,7 @@ smprintf(const char *fmt, ...)
        return ret;
 }
 
-char *
+static char *
 battery_perc(const char *battery)
 {
        int now, full, perc;
@@ -128,8 +128,8 @@ battery_perc(const char *battery)
        return smprintf("%d%%", perc);
 }
 
-char *
-cpu_perc(const char *null)
+static char *
+cpu_perc(void)
 {
        int perc;
        long double a[4], b[4];
@@ -157,7 +157,7 @@ cpu_perc(const char *null)
        return smprintf("%d%%", perc);
 }
 
-char *
+static char *
 datetime(const char *timeformat)
 {
        time_t tm;
@@ -183,7 +183,7 @@ datetime(const char *timeformat)
        return ret;
 }
 
-char *
+static char *
 disk_free(const char *mountpoint)
 {
        struct statvfs fs;
@@ -195,7 +195,7 @@ disk_free(const char *mountpoint)
        return smprintf("%f", (float)fs.f_bsize * (float)fs.f_bfree / 1024 / 1024 / 1024);
 }
 
-char *
+static char *
 disk_perc(const char *mountpoint)
 {
        int perc = 0;
@@ -210,7 +210,7 @@ disk_perc(const char *mountpoint)
        return smprintf("%d%%", perc);
 }
 
-char *
+static char *
 disk_total(const char *mountpoint)
 {
        struct statvfs fs;
@@ -223,7 +223,7 @@ disk_total(const char *mountpoint)
        return smprintf("%f", (float)fs.f_bsize * (float)fs.f_blocks / 1024 / 1024 / 1024);
 }
 
-char *
+static char *
 disk_used(const char *mountpoint)
 {
        struct statvfs fs;
@@ -236,8 +236,8 @@ disk_used(const char *mountpoint)
        return smprintf("%f", (float)fs.f_bsize * ((float)fs.f_blocks - (float)fs.f_bfree) / 1024 / 1024 / 1024);
 }
 
-char *
-entropy(const char *null)
+static char *
+entropy(void)
 {
        int entropy = 0;
        FILE *fp;
@@ -252,8 +252,8 @@ entropy(const char *null)
        return smprintf("%d", entropy);
 }
 
-char *
-gid(const char *null)
+static char *
+gid(void)
 {
        gid_t gid;
 
@@ -265,8 +265,8 @@ gid(const char *null)
        return smprintf(unknowntext);
 }
 
-char *
-hostname(const char *null)
+static char *
+hostname(void)
 {
        char hostname[HOST_NAME_MAX];
        FILE *fp;
@@ -281,7 +281,7 @@ hostname(const char *null)
        return smprintf("%s", hostname);
 }
 
-char *
+static char *
 ip(const char *interface)
 {
        struct ifaddrs *ifaddr, *ifa;
@@ -315,8 +315,8 @@ ip(const char *interface)
        return smprintf(unknowntext);
 }
 
-char *
-load_avg(const char *null)
+static char *
+load_avg(void)
 {
        double avgs[3];
 
@@ -328,8 +328,8 @@ load_avg(const char *null)
        return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
 }
 
-char *
-ram_free(const char *null)
+static char *
+ram_free(void)
 {
        long free;
        FILE *fp;
@@ -344,8 +344,8 @@ ram_free(const char *null)
        return smprintf("%f", (float)free / 1024 / 1024);
 }
 
-char *
-ram_perc(const char *null)
+static char *
+ram_perc(void)
 {
        int perc;
        long total, free, buffers, cached;
@@ -366,8 +366,8 @@ ram_perc(const char *null)
        return smprintf("%d%%", perc);
 }
 
-char *
-ram_total(const char *null)
+static char *
+ram_total(void)
 {
        long total;
        FILE *fp;
@@ -382,8 +382,8 @@ ram_total(const char *null)
        return smprintf("%f", (float)total / 1024 / 1024);
 }
 
-char *
-ram_used(const char *null)
+static char *
+ram_used(void)
 {
        long free, total, buffers, cached, used;
        FILE *fp;
@@ -403,7 +403,7 @@ ram_used(const char *null)
        return smprintf("%f", (float)used / 1024 / 1024);
 }
 
-char *
+static char *
 run_command(const char* command)
 {
        int good;
@@ -428,7 +428,7 @@ run_command(const char* command)
        return smprintf("%s", buffer);
 }
 
-char *
+static char *
 temp(const char *file)
 {
        int temperature;
@@ -444,8 +444,8 @@ temp(const char *file)
        return smprintf("%d°C", temperature / 1000);
 }
 
-char *
-uptime(const char *null)
+static char *
+uptime(void)
 {
        struct sysinfo info;
        int hours = 0;
@@ -458,8 +458,8 @@ uptime(const char *null)
        return smprintf("%dh %dm", hours, minutes);
 }
 
-char *
-username(const char *null)
+static char *
+username(void)
 {
        register struct passwd *pw;
        register uid_t uid;
@@ -477,8 +477,8 @@ username(const char *null)
        return smprintf(unknowntext);
 }
 
-char *
-uid(const char *null)
+static char *
+uid(void)
 {
        register uid_t uid;
 
@@ -495,7 +495,7 @@ uid(const char *null)
 }
 
 
-char *
+static char *
 vol_perc(const char *soundcard)
 {
        int mute = 0;
@@ -537,7 +537,7 @@ vol_perc(const char *soundcard)
                return smprintf("%d%%", (vol * 100) / max);
 }
 
-char *
+static char *
 wifi_perc(const char *wificard)
 {
        int bufsize = 255;
@@ -583,7 +583,7 @@ wifi_perc(const char *wificard)
        return smprintf("%d%%", strength);
 }
 
-char *
+static char *
 wifi_essid(const char *wificard)
 {
        char id[IW_ESSID_MAX_SIZE+1];
@@ -624,7 +624,10 @@ main(void)
                memset(status_string, 0, sizeof(status_string));
                for (size_t i = 0; i < sizeof(args) / sizeof(args[0]); ++i) {
                        argument = args[i];
-                       char *res = argument.func(argument.args);
+                       if (argument.args == NULL)
+                               char *res = argument.func();
+                       else
+                               char *res = argument.func(argument.args);
                        char *element = smprintf(argument.format, res);
                        if (element == NULL) {
                                element = smprintf(unknowntext);