|
5 | 5 | #include "../util.h"
|
6 | 6 |
|
7 | 7 | #if defined(__linux__)
|
| 8 | + #include <inttypes.h> |
8 | 9 | #include <limits.h>
|
9 | 10 | #include <unistd.h>
|
10 | 11 |
|
|
76 | 77 | const char *
|
77 | 78 | battery_remaining(const char *bat)
|
78 | 79 | {
|
79 |
| - int charge_now, current_now, m, h; |
| 80 | + uint64_t charge_now, current_now, m, h; |
80 | 81 | double timeleft;
|
81 | 82 | char path[PATH_MAX], state[12];
|
82 | 83 |
|
|
92 | 93 | if (!pick(bat, "/sys/class/power_supply/%s/charge_now",
|
93 | 94 | "/sys/class/power_supply/%s/energy_now",
|
94 | 95 | path, sizeof(path)) ||
|
95 |
| - pscanf(path, "%d", &charge_now) < 0) { |
| 96 | + pscanf(path, "%" PRIu64, &charge_now) < 0) { |
96 | 97 | return NULL;
|
97 | 98 | }
|
98 | 99 |
|
99 | 100 | if (!strcmp(state, "Discharging")) {
|
100 | 101 | if (!pick(bat, "/sys/class/power_supply/%s/current_now",
|
101 | 102 | "/sys/class/power_supply/%s/power_now", path,
|
102 | 103 | sizeof(path)) ||
|
103 |
| - pscanf(path, "%d", ¤t_now) < 0) { |
| 104 | + pscanf(path, "%" PRIu64, ¤t_now) < 0) { |
104 | 105 | return NULL;
|
105 | 106 | }
|
106 | 107 |
|
|
112 | 113 | h = timeleft;
|
113 | 114 | m = (timeleft - (double)h) * 60;
|
114 | 115 |
|
115 |
| - return bprintf("%dh %dm", h, m); |
| 116 | + return bprintf("%" PRIu64 "h %" PRIu64 "m", h, m); |
116 | 117 | }
|
117 | 118 |
|
118 | 119 | return "";
|
|
0 commit comments