Xinqi Bao's Git
projects
/
slstatus.git
/ diff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
b792b7a
)
battery: 64 bit ints on Linux
author
Aaron Marcher <
[email protected]
>
Sat, 7 Jul 2018 08:31:57 +0000
(10:31 +0200)
committer
Aaron Marcher <
[email protected]
>
Sat, 7 Jul 2018 08:31:57 +0000
(10:31 +0200)
components/battery.c
diff
|
blob
|
history
diff --git
a/components/battery.c
b/components/battery.c
index
82e0baf
..
31c7d48
100644
(file)
--- a/
components/battery.c
+++ b/
components/battery.c
@@
-5,6
+5,7
@@
#include "../util.h"
#if defined(__linux__)
#include "../util.h"
#if defined(__linux__)
+ #include <inttypes.h>
#include <limits.h>
#include <unistd.h>
#include <limits.h>
#include <unistd.h>
@@
-76,7
+77,7
@@
const char *
battery_remaining(const char *bat)
{
const char *
battery_remaining(const char *bat)
{
-
in
t charge_now, current_now, m, h;
+
uint64_
t charge_now, current_now, m, h;
double timeleft;
char path[PATH_MAX], state[12];
double timeleft;
char path[PATH_MAX], state[12];
@@
-92,7
+93,7
@@
if (!pick(bat, "/sys/class/power_supply/%s/charge_now",
"/sys/class/power_supply/%s/energy_now",
path, sizeof(path)) ||
if (!pick(bat, "/sys/class/power_supply/%s/charge_now",
"/sys/class/power_supply/%s/energy_now",
path, sizeof(path)) ||
- pscanf(path, "%
d"
, &charge_now) < 0) {
+ pscanf(path, "%
" PRIu64
, &charge_now) < 0) {
return NULL;
}
return NULL;
}
@@
-100,7
+101,7
@@
if (!pick(bat, "/sys/class/power_supply/%s/current_now",
"/sys/class/power_supply/%s/power_now", path,
sizeof(path)) ||
if (!pick(bat, "/sys/class/power_supply/%s/current_now",
"/sys/class/power_supply/%s/power_now", path,
sizeof(path)) ||
- pscanf(path, "%
d"
, ¤t_now) < 0) {
+ pscanf(path, "%
" PRIu64
, ¤t_now) < 0) {
return NULL;
}
return NULL;
}
@@
-112,7
+113,7
@@
h = timeleft;
m = (timeleft - (double)h) * 60;
h = timeleft;
m = (timeleft - (double)h) * 60;
- return bprintf("%
dh %d
m", h, m);
+ return bprintf("%
" PRIu64 "h %" PRIu64 "
m", h, m);
}
return "";
}
return "";