Skip to content

Commit 43a1283

Browse files
committed
Change uint64_t to uintmax_t
1 parent d76b1a2 commit 43a1283

File tree

9 files changed

+45
-45
lines changed

9 files changed

+45
-45
lines changed

components/battery.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
const char *
7878
battery_remaining(const char *bat)
7979
{
80-
uint64_t charge_now, current_now, m, h;
80+
uintmax_t charge_now, current_now, m, h;
8181
double timeleft;
8282
char path[PATH_MAX], state[12];
8383

@@ -93,15 +93,15 @@
9393
if (!pick(bat, "/sys/class/power_supply/%s/charge_now",
9494
"/sys/class/power_supply/%s/energy_now",
9595
path, sizeof(path)) ||
96-
pscanf(path, "%" PRIu64, &charge_now) < 0) {
96+
pscanf(path, "%" PRIuMAX, &charge_now) < 0) {
9797
return NULL;
9898
}
9999

100100
if (!strcmp(state, "Discharging")) {
101101
if (!pick(bat, "/sys/class/power_supply/%s/current_now",
102102
"/sys/class/power_supply/%s/power_now", path,
103103
sizeof(path)) ||
104-
pscanf(path, "%" PRIu64, &current_now) < 0) {
104+
pscanf(path, "%" PRIuMAX, &current_now) < 0) {
105105
return NULL;
106106
}
107107

@@ -113,7 +113,7 @@
113113
h = timeleft;
114114
m = (timeleft - (double)h) * 60;
115115

116-
return bprintf("%" PRIu64 "h %" PRIu64 "m", h, m);
116+
return bprintf("%" PRIuMAX "h %" PRIuMAX "m", h, m);
117117
}
118118

119119
return "";

components/cpu.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
const char *
1212
cpu_freq(void)
1313
{
14-
uint64_t freq;
14+
uintmax_t freq;
1515

1616
/* in kHz */
1717
if (pscanf("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq",
18-
"%"SCNu64, &freq) != 1) {
18+
"%" PRIuMAX, &freq) != 1) {
1919
return NULL;
2020
}
2121

@@ -74,8 +74,8 @@
7474
cpu_perc(void)
7575
{
7676
int mib[2];
77-
static uint64_t a[CPUSTATES];
78-
uint64_t b[CPUSTATES];
77+
static uintmax_t a[CPUSTATES];
78+
uintmax_t b[CPUSTATES];
7979
size_t size;
8080

8181
mib[0] = CTL_KERN;

components/entropy.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
const char *
99
entropy(void)
1010
{
11-
uint64_t num;
11+
uintmax_t num;
1212

1313
if (pscanf("/proc/sys/kernel/random/entropy_avail",
14-
"%" PRIu64, &num) != 1) {
14+
"%" PRIuMAX, &num) != 1) {
1515
return NULL;
1616
}
1717

18-
return bprintf("%" PRIu64, num);
18+
return bprintf("%" PRIuMAX, num);
1919
}
2020
#elif defined(__OpenBSD__)
2121
const char *

components/netspeeds.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
#include "../util.h"
66

77
#if defined(__linux__)
8-
#include <stdint.h>
8+
#include <inttypes.h>
99

1010
const char *
1111
netspeed_rx(const char *interface)
1212
{
13-
uint64_t oldrxbytes;
14-
static uint64_t rxbytes;
13+
uintmax_t oldrxbytes;
14+
static uintmax_t rxbytes;
1515
extern const unsigned int interval;
1616
char path[PATH_MAX];
1717

@@ -22,7 +22,7 @@
2222
interface) < 0) {
2323
return NULL;
2424
}
25-
if (pscanf(path, "%llu", &rxbytes) != 1) {
25+
if (pscanf(path, "%" PRIuMAX, &rxbytes) != 1) {
2626
return NULL;
2727
}
2828
if (oldrxbytes == 0) {
@@ -36,8 +36,8 @@
3636
const char *
3737
netspeed_tx(const char *interface)
3838
{
39-
uint64_t oldtxbytes;
40-
static uint64_t txbytes;
39+
uintmax_t oldtxbytes;
40+
static uintmax_t txbytes;
4141
extern const unsigned int interval;
4242
char path[PATH_MAX];
4343

@@ -48,7 +48,7 @@
4848
interface) < 0) {
4949
return NULL;
5050
}
51-
if (pscanf(path, "%llu", &txbytes) != 1) {
51+
if (pscanf(path, "%" PRIuMAX, &txbytes) != 1) {
5252
return NULL;
5353
}
5454
if (oldtxbytes == 0) {
@@ -70,8 +70,8 @@
7070
{
7171
struct ifaddrs *ifal, *ifa;
7272
struct if_data *ifd;
73-
uint64_t oldrxbytes;
74-
static uint64_t rxbytes;
73+
uintmax_t oldrxbytes;
74+
static uintmax_t rxbytes;
7575
extern const unsigned int interval;
7676
int if_ok = 0;
7777

@@ -106,8 +106,8 @@
106106
{
107107
struct ifaddrs *ifal, *ifa;
108108
struct if_data *ifd;
109-
uint64_t oldtxbytes;
110-
static uint64_t txbytes;
109+
uintmax_t oldtxbytes;
110+
static uintmax_t txbytes;
111111
extern const unsigned int interval;
112112
int if_ok = 0;
113113

components/ram.c

+16-16
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
const char *
1010
ram_free(void)
1111
{
12-
uint64_t free;
12+
uintmax_t free;
1313

1414
if (pscanf("/proc/meminfo",
15-
"MemTotal: %" PRIu64 " kB\n"
16-
"MemFree: %" PRIu64 " kB\n"
17-
"MemAvailable: %" PRIu64 " kB\n",
15+
"MemTotal: %" PRIuMAX " kB\n"
16+
"MemFree: %" PRIuMAX " kB\n"
17+
"MemAvailable: %" PRIuMAX " kB\n",
1818
&free, &free, &free) != 3) {
1919
return NULL;
2020
}
@@ -25,13 +25,13 @@
2525
const char *
2626
ram_perc(void)
2727
{
28-
uint64_t total, free, buffers, cached;
28+
uintmax_t total, free, buffers, cached;
2929

3030
if (pscanf("/proc/meminfo",
31-
"MemTotal: %" PRIu64 " kB\n"
32-
"MemFree: %" PRIu64 " kB\n"
33-
"MemAvailable: %" PRIu64 " kB\nBuffers: %ld kB\n"
34-
"Cached: %" PRIu64 " kB\n",
31+
"MemTotal: %" PRIuMAX " kB\n"
32+
"MemFree: %" PRIuMAX " kB\n"
33+
"MemAvailable: %" PRIuMAX " kB\nBuffers: %ld kB\n"
34+
"Cached: %" PRIuMAX " kB\n",
3535
&total, &free, &buffers, &buffers, &cached) != 5) {
3636
return NULL;
3737
}
@@ -47,9 +47,9 @@
4747
const char *
4848
ram_total(void)
4949
{
50-
uint64_t total;
50+
uintmax_t total;
5151

52-
if (pscanf("/proc/meminfo", "MemTotal: %" PRIu64 " kB\n",
52+
if (pscanf("/proc/meminfo", "MemTotal: %" PRIuMAX " kB\n",
5353
&total) != 1) {
5454
return NULL;
5555
}
@@ -60,13 +60,13 @@
6060
const char *
6161
ram_used(void)
6262
{
63-
uint64_t total, free, buffers, cached;
63+
uintmax_t total, free, buffers, cached;
6464

6565
if (pscanf("/proc/meminfo",
66-
"MemTotal: %" PRIu64 " kB\n"
67-
"MemFree: %" PRIu64 " kB\n"
68-
"MemAvailable: %" PRIu64 " kB\nBuffers: %" PRIu64 " kB\n"
69-
"Cached: %" PRIu64 " kB\n",
66+
"MemTotal: %" PRIuMAX " kB\n"
67+
"MemFree: %" PRIuMAX " kB\n"
68+
"MemAvailable: %" PRIuMAX " kB\nBuffers: %" PRIuMAX " kB\n"
69+
"Cached: %" PRIuMAX " kB\n",
7070
&total, &free, &buffers, &buffers, &cached) != 5) {
7171
return NULL;
7272
}

components/temperature.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
const char *
1010
temp(const char *file)
1111
{
12-
uint64_t temp;
12+
uintmax_t temp;
1313

14-
if(pscanf(file, "%" PRIu64, &temp) != 1) {
14+
if(pscanf(file, "%" PRIuMAX, &temp) != 1) {
1515
return NULL;
1616
}
1717

18-
return bprintf("%" PRIu64, temp / 1000);
18+
return bprintf("%" PRIuMAX, temp / 1000);
1919
}
2020
#elif defined(__OpenBSD__)
2121
#include <stdio.h>

components/uptime.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
const char *
99
uptime(void)
1010
{
11-
uint64_t h, m;
11+
uintmax_t h, m;
1212
struct timespec uptime;
1313

1414
if (clock_gettime(CLOCK_BOOTTIME, &uptime) < 0) {
@@ -19,5 +19,5 @@ uptime(void)
1919
h = uptime.tv_sec / 3600;
2020
m = uptime.tv_sec % 3600 / 60;
2121

22-
return bprintf("%" PRIu64 "h %" PRIu64 "m", h, m);
22+
return bprintf("%" PRIuMAX "h %" PRIuMAX "m", h, m);
2323
}

util.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ bprintf(const char *fmt, ...)
9494
}
9595

9696
const char *
97-
fmt_human(uint64_t num, int base)
97+
fmt_human(uintmax_t num, int base)
9898
{
9999
double scaled;
100100
size_t i, prefixlen;

util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ void die(const char *, ...);
1212

1313
int esnprintf(char *str, size_t size, const char *fmt, ...);
1414
const char *bprintf(const char *fmt, ...);
15-
const char *fmt_human(uint64_t num, int base);
15+
const char *fmt_human(uintmax_t num, int base);
1616
int pscanf(const char *path, const char *fmt, ...);

0 commit comments

Comments
 (0)