Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
forgot to give entropy() some candy too
[slstatus.git]
/
slstatus.c
diff --git
a/slstatus.c
b/slstatus.c
index
163b44e
..
f070e1d
100644
(file)
--- a/
slstatus.c
+++ b/
slstatus.c
@@
-105,7
+105,7
@@
battery_perc(const char *battery)
int now, full, perc;
char batterynowfile[64];
char batteryfullfile[64];
int now, full, perc;
char batterynowfile[64];
char batteryfullfile[64];
- FILE *fp
= fopen(batterynowfile, "r")
;
+ FILE *fp;
strlcpy(batterynowfile, BATTERY_PATH, sizeof(batterynowfile));
strlcat(batterynowfile, battery, sizeof(batterynowfile));
strlcpy(batterynowfile, BATTERY_PATH, sizeof(batterynowfile));
strlcat(batterynowfile, battery, sizeof(batterynowfile));
@@
-117,6
+117,7
@@
battery_perc(const char *battery)
strlcat(batteryfullfile, "/", sizeof(batteryfullfile));
strlcat(batteryfullfile, BATTERY_FULL, sizeof(batteryfullfile));
strlcat(batteryfullfile, "/", sizeof(batteryfullfile));
strlcat(batteryfullfile, BATTERY_FULL, sizeof(batteryfullfile));
+ fp = fopen(batterynowfile, "r");
if (fp == NULL ) {
fprintf(stderr, "Error opening battery file: %s: %s\n",
batterynowfile,
if (fp == NULL ) {
fprintf(stderr, "Error opening battery file: %s: %s\n",
batterynowfile,
@@
-251,7
+252,8
@@
entropy(void)
FILE *fp = fopen("/proc/sys/kernel/random/entropy_avail", "r");
if (fp == NULL) {
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);
}
return smprintf(UNKNOWN_STR);
}