Xinqi Bao's Git
projects
/
slstatus.git
/ commitdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
d76b1a2
)
Change uint64_t to uintmax_t
author
Aaron Marcher <
[email protected]
>
Sat, 7 Jul 2018 08:50:25 +0000
(10:50 +0200)
committer
Aaron Marcher <
[email protected]
>
Sat, 7 Jul 2018 08:50:25 +0000
(10:50 +0200)
components/battery.c
patch
|
blob
|
history
components/cpu.c
patch
|
blob
|
history
components/entropy.c
patch
|
blob
|
history
components/netspeeds.c
patch
|
blob
|
history
components/ram.c
patch
|
blob
|
history
components/temperature.c
patch
|
blob
|
history
components/uptime.c
patch
|
blob
|
history
util.c
patch
|
blob
|
history
util.h
patch
|
blob
|
history
diff --git
a/components/battery.c
b/components/battery.c
index
31c7d48
..
ae31dd6
100644
(file)
--- a/
components/battery.c
+++ b/
components/battery.c
@@
-77,7
+77,7
@@
const char *
battery_remaining(const char *bat)
{
const char *
battery_remaining(const char *bat)
{
- uint
64
_t charge_now, current_now, m, h;
+ uint
max
_t charge_now, current_now, m, h;
double timeleft;
char path[PATH_MAX], state[12];
double timeleft;
char path[PATH_MAX], state[12];
@@
-93,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, "%" PRIu
64
, &charge_now) < 0) {
+ pscanf(path, "%" PRIu
MAX
, &charge_now) < 0) {
return NULL;
}
return NULL;
}
@@
-101,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, "%" PRIu
64
, ¤t_now) < 0) {
+ pscanf(path, "%" PRIu
MAX
, ¤t_now) < 0) {
return NULL;
}
return NULL;
}
@@
-113,7
+113,7
@@
h = timeleft;
m = (timeleft - (double)h) * 60;
h = timeleft;
m = (timeleft - (double)h) * 60;
- return bprintf("%" PRIu
64 "h %" PRIu64
"m", h, m);
+ return bprintf("%" PRIu
MAX "h %" PRIuMAX
"m", h, m);
}
return "";
}
return "";
diff --git
a/components/cpu.c
b/components/cpu.c
index
e320ff6
..
ceb95d8
100644
(file)
--- a/
components/cpu.c
+++ b/
components/cpu.c
@@
-11,11
+11,11
@@
const char *
cpu_freq(void)
{
const char *
cpu_freq(void)
{
- uint
64
_t freq;
+ uint
max
_t freq;
/* in kHz */
if (pscanf("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq",
/* in kHz */
if (pscanf("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq",
- "%"
SCNu64
, &freq) != 1) {
+ "%"
PRIuMAX
, &freq) != 1) {
return NULL;
}
return NULL;
}
@@
-74,8
+74,8
@@
cpu_perc(void)
{
int mib[2];
cpu_perc(void)
{
int mib[2];
- static uint
64
_t a[CPUSTATES];
- uint
64
_t b[CPUSTATES];
+ static uint
max
_t a[CPUSTATES];
+ uint
max
_t b[CPUSTATES];
size_t size;
mib[0] = CTL_KERN;
size_t size;
mib[0] = CTL_KERN;
diff --git
a/components/entropy.c
b/components/entropy.c
index
7f6112e
..
5173f15
100644
(file)
--- a/
components/entropy.c
+++ b/
components/entropy.c
@@
-8,14
+8,14
@@
const char *
entropy(void)
{
const char *
entropy(void)
{
- uint
64
_t num;
+ uint
max
_t num;
if (pscanf("/proc/sys/kernel/random/entropy_avail",
if (pscanf("/proc/sys/kernel/random/entropy_avail",
- "%" PRIu
64
, &num) != 1) {
+ "%" PRIu
MAX
, &num) != 1) {
return NULL;
}
return NULL;
}
- return bprintf("%" PRIu
64
, num);
+ return bprintf("%" PRIu
MAX
, num);
}
#elif defined(__OpenBSD__)
const char *
}
#elif defined(__OpenBSD__)
const char *
diff --git
a/components/netspeeds.c
b/components/netspeeds.c
index
7ab1590
..
ac9c4a6
100644
(file)
--- a/
components/netspeeds.c
+++ b/
components/netspeeds.c
@@
-5,13
+5,13
@@
#include "../util.h"
#if defined(__linux__)
#include "../util.h"
#if defined(__linux__)
- #include <
stdint
.h>
+ #include <
inttypes
.h>
const char *
netspeed_rx(const char *interface)
{
const char *
netspeed_rx(const char *interface)
{
- uint
64
_t oldrxbytes;
- static uint
64
_t rxbytes;
+ uint
max
_t oldrxbytes;
+ static uint
max
_t rxbytes;
extern const unsigned int interval;
char path[PATH_MAX];
extern const unsigned int interval;
char path[PATH_MAX];
@@
-22,7
+22,7
@@
interface) < 0) {
return NULL;
}
interface) < 0) {
return NULL;
}
- if (pscanf(path, "%
llu"
, &rxbytes) != 1) {
+ if (pscanf(path, "%
" PRIuMAX
, &rxbytes) != 1) {
return NULL;
}
if (oldrxbytes == 0) {
return NULL;
}
if (oldrxbytes == 0) {
@@
-36,8
+36,8
@@
const char *
netspeed_tx(const char *interface)
{
const char *
netspeed_tx(const char *interface)
{
- uint
64
_t oldtxbytes;
- static uint
64
_t txbytes;
+ uint
max
_t oldtxbytes;
+ static uint
max
_t txbytes;
extern const unsigned int interval;
char path[PATH_MAX];
extern const unsigned int interval;
char path[PATH_MAX];
@@
-48,7
+48,7
@@
interface) < 0) {
return NULL;
}
interface) < 0) {
return NULL;
}
- if (pscanf(path, "%
llu"
, &txbytes) != 1) {
+ if (pscanf(path, "%
" PRIuMAX
, &txbytes) != 1) {
return NULL;
}
if (oldtxbytes == 0) {
return NULL;
}
if (oldtxbytes == 0) {
@@
-70,8
+70,8
@@
{
struct ifaddrs *ifal, *ifa;
struct if_data *ifd;
{
struct ifaddrs *ifal, *ifa;
struct if_data *ifd;
- uint
64
_t oldrxbytes;
- static uint
64
_t rxbytes;
+ uint
max
_t oldrxbytes;
+ static uint
max
_t rxbytes;
extern const unsigned int interval;
int if_ok = 0;
extern const unsigned int interval;
int if_ok = 0;
@@
-106,8
+106,8
@@
{
struct ifaddrs *ifal, *ifa;
struct if_data *ifd;
{
struct ifaddrs *ifal, *ifa;
struct if_data *ifd;
- uint
64
_t oldtxbytes;
- static uint
64
_t txbytes;
+ uint
max
_t oldtxbytes;
+ static uint
max
_t txbytes;
extern const unsigned int interval;
int if_ok = 0;
extern const unsigned int interval;
int if_ok = 0;
diff --git
a/components/ram.c
b/components/ram.c
index
8688349
..
a2fff95
100644
(file)
--- a/
components/ram.c
+++ b/
components/ram.c
@@
-9,12
+9,12
@@
const char *
ram_free(void)
{
const char *
ram_free(void)
{
- uint
64
_t free;
+ uint
max
_t free;
if (pscanf("/proc/meminfo",
if (pscanf("/proc/meminfo",
- "MemTotal: %" PRIu
64
" kB\n"
- "MemFree: %" PRIu
64
" kB\n"
- "MemAvailable: %" PRIu
64
" kB\n",
+ "MemTotal: %" PRIu
MAX
" kB\n"
+ "MemFree: %" PRIu
MAX
" kB\n"
+ "MemAvailable: %" PRIu
MAX
" kB\n",
&free, &free, &free) != 3) {
return NULL;
}
&free, &free, &free) != 3) {
return NULL;
}
@@
-25,13
+25,13
@@
const char *
ram_perc(void)
{
const char *
ram_perc(void)
{
- uint
64
_t total, free, buffers, cached;
+ uint
max
_t total, free, buffers, cached;
if (pscanf("/proc/meminfo",
if (pscanf("/proc/meminfo",
- "MemTotal: %" PRIu
64
" kB\n"
- "MemFree: %" PRIu
64
" kB\n"
- "MemAvailable: %" PRIu
64
" kB\nBuffers: %ld kB\n"
- "Cached: %" PRIu
64
" kB\n",
+ "MemTotal: %" PRIu
MAX
" kB\n"
+ "MemFree: %" PRIu
MAX
" kB\n"
+ "MemAvailable: %" PRIu
MAX
" kB\nBuffers: %ld kB\n"
+ "Cached: %" PRIu
MAX
" kB\n",
&total, &free, &buffers, &buffers, &cached) != 5) {
return NULL;
}
&total, &free, &buffers, &buffers, &cached) != 5) {
return NULL;
}
@@
-47,9
+47,9
@@
const char *
ram_total(void)
{
const char *
ram_total(void)
{
- uint
64
_t total;
+ uint
max
_t total;
- if (pscanf("/proc/meminfo", "MemTotal: %" PRIu
64
" kB\n",
+ if (pscanf("/proc/meminfo", "MemTotal: %" PRIu
MAX
" kB\n",
&total) != 1) {
return NULL;
}
&total) != 1) {
return NULL;
}
@@
-60,13
+60,13
@@
const char *
ram_used(void)
{
const char *
ram_used(void)
{
- uint
64
_t total, free, buffers, cached;
+ uint
max
_t total, free, buffers, cached;
if (pscanf("/proc/meminfo",
if (pscanf("/proc/meminfo",
- "MemTotal: %" PRIu
64
" kB\n"
- "MemFree: %" PRIu
64
" kB\n"
- "MemAvailable: %" PRIu
64 " kB\nBuffers: %" PRIu64
" kB\n"
- "Cached: %" PRIu
64
" kB\n",
+ "MemTotal: %" PRIu
MAX
" kB\n"
+ "MemFree: %" PRIu
MAX
" kB\n"
+ "MemAvailable: %" PRIu
MAX " kB\nBuffers: %" PRIuMAX
" kB\n"
+ "Cached: %" PRIu
MAX
" kB\n",
&total, &free, &buffers, &buffers, &cached) != 5) {
return NULL;
}
&total, &free, &buffers, &buffers, &cached) != 5) {
return NULL;
}
diff --git
a/components/temperature.c
b/components/temperature.c
index
2c57853
..
71e1378
100644
(file)
--- a/
components/temperature.c
+++ b/
components/temperature.c
@@
-9,13
+9,13
@@
const char *
temp(const char *file)
{
const char *
temp(const char *file)
{
- uint
64
_t temp;
+ uint
max
_t temp;
- if(pscanf(file, "%" PRIu
64
, &temp) != 1) {
+ if(pscanf(file, "%" PRIu
MAX
, &temp) != 1) {
return NULL;
}
return NULL;
}
- return bprintf("%" PRIu
64
, temp / 1000);
+ return bprintf("%" PRIu
MAX
, temp / 1000);
}
#elif defined(__OpenBSD__)
#include <stdio.h>
}
#elif defined(__OpenBSD__)
#include <stdio.h>
diff --git
a/components/uptime.c
b/components/uptime.c
index
f957f17
..
67acbf7
100644
(file)
--- a/
components/uptime.c
+++ b/
components/uptime.c
@@
-8,7
+8,7
@@
const char *
uptime(void)
{
const char *
uptime(void)
{
- uint
64
_t h, m;
+ uint
max
_t h, m;
struct timespec uptime;
if (clock_gettime(CLOCK_BOOTTIME, &uptime) < 0) {
struct timespec uptime;
if (clock_gettime(CLOCK_BOOTTIME, &uptime) < 0) {
@@
-19,5
+19,5
@@
uptime(void)
h = uptime.tv_sec / 3600;
m = uptime.tv_sec % 3600 / 60;
h = uptime.tv_sec / 3600;
m = uptime.tv_sec % 3600 / 60;
- return bprintf("%" PRIu
64 "h %" PRIu64
"m", h, m);
+ return bprintf("%" PRIu
MAX "h %" PRIuMAX
"m", h, m);
}
}
diff --git
a/util.c
b/util.c
index
4c37ab0
..
eaa3001
100644
(file)
--- a/
util.c
+++ b/
util.c
@@
-94,7
+94,7
@@
bprintf(const char *fmt, ...)
}
const char *
}
const char *
-fmt_human(uint
64
_t num, int base)
+fmt_human(uint
max
_t num, int base)
{
double scaled;
size_t i, prefixlen;
{
double scaled;
size_t i, prefixlen;
diff --git
a/util.h
b/util.h
index
af12962
..
7f1f26c
100644
(file)
--- a/
util.h
+++ b/
util.h
@@
-12,5
+12,5
@@
void die(const char *, ...);
int esnprintf(char *str, size_t size, const char *fmt, ...);
const char *bprintf(const char *fmt, ...);
int esnprintf(char *str, size_t size, const char *fmt, ...);
const char *bprintf(const char *fmt, ...);
-const char *fmt_human(uint
64
_t num, int base);
+const char *fmt_human(uint
max
_t num, int base);
int pscanf(const char *path, const char *fmt, ...);
int pscanf(const char *path, const char *fmt, ...);