Xinqi Bao's Git

removed unnecessary typecast and added more comments
[slstatus.git] / slstatus.c
index 5246bc0..d360977 100644 (file)
@@ -1,12 +1,10 @@
 /* See LICENSE file for copyright and license details. */
 
 #include <alsa/asoundlib.h>
-#include <arpa/inet.h>
 #include <fcntl.h>
 #include <ifaddrs.h>
 #include <limits.h>
 #include <linux/wireless.h>
-#include <locale.h>
 #include <netdb.h>
 #include <pwd.h>
 #include <stdarg.h>
@@ -29,9 +27,8 @@
 #include "strlcat.h"
 #include "strlcpy.h"
 
-typedef char *(*op_fun)();
 struct arg {
-       op_fun func;
+       char *(*func)();
        const char *format;
        const char *args;
 };
@@ -252,7 +249,8 @@ entropy(void)
        FILE *fp = fopen("/proc/sys/kernel/random/entropy_avail", "r");
 
        if (fp == NULL) {
-               fprintf(stderr, "Could not open entropy file.\n");
+               fprintf(stderr, "Could not open entropy file: %s\n",
+                                               strerror(errno));
                return smprintf(UNKNOWN_STR);
        }
 
@@ -476,6 +474,7 @@ uptime(void)
 static char *
 username(void)
 {
+       /* FIXME: WHY USE REGISTER MODIFIER? */
        register struct passwd *pw;
        register uid_t uid;
 
@@ -515,6 +514,10 @@ uid(void)
 static char *
 vol_perc(const char *soundcard)
 {
+       /*
+        * TODO: FIXME: 
+        * https://github.com/drkh5h/slstatus/issues/12
+        */
        int mute = 0;
        long vol = 0, max = 0, min = 0;
        snd_mixer_t *handle;
@@ -563,12 +566,14 @@ wifi_perc(const char *wificard)
        char path[64];
        char status[5];
        char needle[strlen(wificard)+2];
-       FILE *fp = fopen(path, "r");
+       FILE *fp;
 
        strlcpy(path, "/sys/class/net/", sizeof(path));
        strlcat(path, wificard, sizeof(path));
        strlcat(path, "/operstate", sizeof(path));
 
+       fp = fopen(path, "r");
+
        if(fp == NULL) {
                fprintf(stderr, "Error opening wifi operstate file: %s\n",
                                                        strerror(errno));