Change uint64_t to uintmax_t
This commit is contained in:
		@@ -77,7 +77,7 @@
 | 
				
			|||||||
	const char *
 | 
						const char *
 | 
				
			||||||
	battery_remaining(const char *bat)
 | 
						battery_remaining(const char *bat)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uint64_t charge_now, current_now, m, h;
 | 
							uintmax_t charge_now, current_now, m, h;
 | 
				
			||||||
		double timeleft;
 | 
							double timeleft;
 | 
				
			||||||
		char path[PATH_MAX], state[12];
 | 
							char path[PATH_MAX], state[12];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -93,7 +93,7 @@
 | 
				
			|||||||
		if (!pick(bat, "/sys/class/power_supply/%s/charge_now",
 | 
							if (!pick(bat, "/sys/class/power_supply/%s/charge_now",
 | 
				
			||||||
		          "/sys/class/power_supply/%s/energy_now",
 | 
							          "/sys/class/power_supply/%s/energy_now",
 | 
				
			||||||
		          path, sizeof(path)) ||
 | 
							          path, sizeof(path)) ||
 | 
				
			||||||
		    pscanf(path, "%" PRIu64, &charge_now) < 0) {
 | 
							    pscanf(path, "%" PRIuMAX, &charge_now) < 0) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -101,7 +101,7 @@
 | 
				
			|||||||
			if (!pick(bat, "/sys/class/power_supply/%s/current_now",
 | 
								if (!pick(bat, "/sys/class/power_supply/%s/current_now",
 | 
				
			||||||
			          "/sys/class/power_supply/%s/power_now", path,
 | 
								          "/sys/class/power_supply/%s/power_now", path,
 | 
				
			||||||
			          sizeof(path)) ||
 | 
								          sizeof(path)) ||
 | 
				
			||||||
			    pscanf(path, "%" PRIu64, ¤t_now) < 0) {
 | 
								    pscanf(path, "%" PRIuMAX, ¤t_now) < 0) {
 | 
				
			||||||
				return NULL;
 | 
									return NULL;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -113,7 +113,7 @@
 | 
				
			|||||||
			h = timeleft;
 | 
								h = timeleft;
 | 
				
			||||||
			m = (timeleft - (double)h) * 60;
 | 
								m = (timeleft - (double)h) * 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return bprintf("%" PRIu64 "h %" PRIu64 "m", h, m);
 | 
								return bprintf("%" PRIuMAX "h %" PRIuMAX "m", h, m);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return "";
 | 
							return "";
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,11 +11,11 @@
 | 
				
			|||||||
	const char *
 | 
						const char *
 | 
				
			||||||
	cpu_freq(void)
 | 
						cpu_freq(void)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uint64_t freq;
 | 
							uintmax_t freq;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* in kHz */
 | 
							/* in kHz */
 | 
				
			||||||
		if (pscanf("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq",
 | 
							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)
 | 
						cpu_perc(void)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		int mib[2];
 | 
							int mib[2];
 | 
				
			||||||
		static uint64_t a[CPUSTATES];
 | 
							static uintmax_t a[CPUSTATES];
 | 
				
			||||||
		uint64_t b[CPUSTATES];
 | 
							uintmax_t b[CPUSTATES];
 | 
				
			||||||
		size_t size;
 | 
							size_t size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		mib[0] = CTL_KERN;
 | 
							mib[0] = CTL_KERN;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,14 +8,14 @@
 | 
				
			|||||||
	const char *
 | 
						const char *
 | 
				
			||||||
	entropy(void)
 | 
						entropy(void)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uint64_t num;
 | 
							uintmax_t num;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (pscanf("/proc/sys/kernel/random/entropy_avail",
 | 
							if (pscanf("/proc/sys/kernel/random/entropy_avail",
 | 
				
			||||||
		           "%" PRIu64, &num) != 1) {
 | 
							           "%" PRIuMAX, &num) != 1) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return bprintf("%" PRIu64, num);
 | 
							return bprintf("%" PRIuMAX, num);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#elif defined(__OpenBSD__)
 | 
					#elif defined(__OpenBSD__)
 | 
				
			||||||
	const char *
 | 
						const char *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,13 +5,13 @@
 | 
				
			|||||||
#include "../util.h"
 | 
					#include "../util.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(__linux__)
 | 
					#if defined(__linux__)
 | 
				
			||||||
	#include <stdint.h>
 | 
						#include <inttypes.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *
 | 
						const char *
 | 
				
			||||||
	netspeed_rx(const char *interface)
 | 
						netspeed_rx(const char *interface)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uint64_t oldrxbytes;
 | 
							uintmax_t oldrxbytes;
 | 
				
			||||||
		static uint64_t rxbytes;
 | 
							static uintmax_t rxbytes;
 | 
				
			||||||
		extern const unsigned int interval;
 | 
							extern const unsigned int interval;
 | 
				
			||||||
		char path[PATH_MAX];
 | 
							char path[PATH_MAX];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -22,7 +22,7 @@
 | 
				
			|||||||
		              interface) < 0) {
 | 
							              interface) < 0) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (pscanf(path, "%llu", &rxbytes) != 1) {
 | 
							if (pscanf(path, "%" PRIuMAX, &rxbytes) != 1) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (oldrxbytes == 0) {
 | 
							if (oldrxbytes == 0) {
 | 
				
			||||||
@@ -36,8 +36,8 @@
 | 
				
			|||||||
	const char *
 | 
						const char *
 | 
				
			||||||
	netspeed_tx(const char *interface)
 | 
						netspeed_tx(const char *interface)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uint64_t oldtxbytes;
 | 
							uintmax_t oldtxbytes;
 | 
				
			||||||
		static uint64_t txbytes;
 | 
							static uintmax_t txbytes;
 | 
				
			||||||
		extern const unsigned int interval;
 | 
							extern const unsigned int interval;
 | 
				
			||||||
		char path[PATH_MAX];
 | 
							char path[PATH_MAX];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -48,7 +48,7 @@
 | 
				
			|||||||
		              interface) < 0) {
 | 
							              interface) < 0) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (pscanf(path, "%llu", &txbytes) != 1) {
 | 
							if (pscanf(path, "%" PRIuMAX, &txbytes) != 1) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (oldtxbytes == 0) {
 | 
							if (oldtxbytes == 0) {
 | 
				
			||||||
@@ -70,8 +70,8 @@
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		struct ifaddrs *ifal, *ifa;
 | 
							struct ifaddrs *ifal, *ifa;
 | 
				
			||||||
		struct if_data *ifd;
 | 
							struct if_data *ifd;
 | 
				
			||||||
		uint64_t oldrxbytes;
 | 
							uintmax_t oldrxbytes;
 | 
				
			||||||
		static uint64_t rxbytes;
 | 
							static uintmax_t rxbytes;
 | 
				
			||||||
		extern const unsigned int interval;
 | 
							extern const unsigned int interval;
 | 
				
			||||||
		int if_ok = 0;
 | 
							int if_ok = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -106,8 +106,8 @@
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		struct ifaddrs *ifal, *ifa;
 | 
							struct ifaddrs *ifal, *ifa;
 | 
				
			||||||
		struct if_data *ifd;
 | 
							struct if_data *ifd;
 | 
				
			||||||
		uint64_t oldtxbytes;
 | 
							uintmax_t oldtxbytes;
 | 
				
			||||||
		static uint64_t txbytes;
 | 
							static uintmax_t txbytes;
 | 
				
			||||||
		extern const unsigned int interval;
 | 
							extern const unsigned int interval;
 | 
				
			||||||
		int if_ok = 0;
 | 
							int if_ok = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,12 +9,12 @@
 | 
				
			|||||||
	const char *
 | 
						const char *
 | 
				
			||||||
	ram_free(void)
 | 
						ram_free(void)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uint64_t free;
 | 
							uintmax_t free;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (pscanf("/proc/meminfo",
 | 
							if (pscanf("/proc/meminfo",
 | 
				
			||||||
		           "MemTotal: %" PRIu64 " kB\n"
 | 
							           "MemTotal: %" PRIuMAX " kB\n"
 | 
				
			||||||
		           "MemFree: %" PRIu64 " kB\n"
 | 
							           "MemFree: %" PRIuMAX " kB\n"
 | 
				
			||||||
		           "MemAvailable: %" PRIu64 " kB\n",
 | 
							           "MemAvailable: %" PRIuMAX " kB\n",
 | 
				
			||||||
		           &free, &free, &free) != 3) {
 | 
							           &free, &free, &free) != 3) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -25,13 +25,13 @@
 | 
				
			|||||||
	const char *
 | 
						const char *
 | 
				
			||||||
	ram_perc(void)
 | 
						ram_perc(void)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uint64_t total, free, buffers, cached;
 | 
							uintmax_t total, free, buffers, cached;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (pscanf("/proc/meminfo",
 | 
							if (pscanf("/proc/meminfo",
 | 
				
			||||||
		           "MemTotal: %" PRIu64 " kB\n"
 | 
							           "MemTotal: %" PRIuMAX " kB\n"
 | 
				
			||||||
		           "MemFree: %" PRIu64 " kB\n"
 | 
							           "MemFree: %" PRIuMAX " kB\n"
 | 
				
			||||||
		           "MemAvailable: %" PRIu64 " kB\nBuffers: %ld kB\n"
 | 
							           "MemAvailable: %" PRIuMAX " kB\nBuffers: %ld kB\n"
 | 
				
			||||||
		           "Cached: %" PRIu64 " kB\n",
 | 
							           "Cached: %" PRIuMAX " kB\n",
 | 
				
			||||||
		           &total, &free, &buffers, &buffers, &cached) != 5) {
 | 
							           &total, &free, &buffers, &buffers, &cached) != 5) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -47,9 +47,9 @@
 | 
				
			|||||||
	const char *
 | 
						const char *
 | 
				
			||||||
	ram_total(void)
 | 
						ram_total(void)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uint64_t total;
 | 
							uintmax_t total;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (pscanf("/proc/meminfo", "MemTotal: %" PRIu64 " kB\n",
 | 
							if (pscanf("/proc/meminfo", "MemTotal: %" PRIuMAX " kB\n",
 | 
				
			||||||
		           &total) != 1) {
 | 
							           &total) != 1) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -60,13 +60,13 @@
 | 
				
			|||||||
	const char *
 | 
						const char *
 | 
				
			||||||
	ram_used(void)
 | 
						ram_used(void)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uint64_t total, free, buffers, cached;
 | 
							uintmax_t total, free, buffers, cached;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (pscanf("/proc/meminfo",
 | 
							if (pscanf("/proc/meminfo",
 | 
				
			||||||
		           "MemTotal: %" PRIu64 " kB\n"
 | 
							           "MemTotal: %" PRIuMAX " kB\n"
 | 
				
			||||||
		           "MemFree: %" PRIu64 " kB\n"
 | 
							           "MemFree: %" PRIuMAX " kB\n"
 | 
				
			||||||
		           "MemAvailable: %" PRIu64 " kB\nBuffers: %" PRIu64 " kB\n"
 | 
							           "MemAvailable: %" PRIuMAX " kB\nBuffers: %" PRIuMAX " kB\n"
 | 
				
			||||||
		           "Cached: %" PRIu64 " kB\n",
 | 
							           "Cached: %" PRIuMAX " kB\n",
 | 
				
			||||||
		           &total, &free, &buffers, &buffers, &cached) != 5) {
 | 
							           &total, &free, &buffers, &buffers, &cached) != 5) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,13 +9,13 @@
 | 
				
			|||||||
	const char *
 | 
						const char *
 | 
				
			||||||
	temp(const char *file)
 | 
						temp(const char *file)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uint64_t temp;
 | 
							uintmax_t temp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(pscanf(file, "%" PRIu64, &temp) != 1) {
 | 
							if(pscanf(file, "%" PRIuMAX, &temp) != 1) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return bprintf("%" PRIu64, temp / 1000);
 | 
							return bprintf("%" PRIuMAX, temp / 1000);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#elif defined(__OpenBSD__)
 | 
					#elif defined(__OpenBSD__)
 | 
				
			||||||
	#include <stdio.h>
 | 
						#include <stdio.h>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@
 | 
				
			|||||||
const char *
 | 
					const char *
 | 
				
			||||||
uptime(void)
 | 
					uptime(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	uint64_t h, m;
 | 
						uintmax_t h, m;
 | 
				
			||||||
	struct timespec uptime;
 | 
						struct timespec uptime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (clock_gettime(CLOCK_BOOTTIME, &uptime) < 0) {
 | 
						if (clock_gettime(CLOCK_BOOTTIME, &uptime) < 0) {
 | 
				
			||||||
@@ -19,5 +19,5 @@ uptime(void)
 | 
				
			|||||||
	h = uptime.tv_sec / 3600;
 | 
						h = uptime.tv_sec / 3600;
 | 
				
			||||||
	m = uptime.tv_sec % 3600 / 60;
 | 
						m = uptime.tv_sec % 3600 / 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return bprintf("%" PRIu64 "h %" PRIu64 "m", h, m);
 | 
						return bprintf("%" PRIuMAX "h %" PRIuMAX "m", h, m);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								util.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								util.c
									
									
									
									
									
								
							@@ -94,7 +94,7 @@ bprintf(const char *fmt, ...)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *
 | 
					const char *
 | 
				
			||||||
fmt_human(uint64_t num, int base)
 | 
					fmt_human(uintmax_t num, int base)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	double scaled;
 | 
						double scaled;
 | 
				
			||||||
	size_t i, prefixlen;
 | 
						size_t i, prefixlen;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								util.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								util.h
									
									
									
									
									
								
							@@ -12,5 +12,5 @@ void die(const char *, ...);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int esnprintf(char *str, size_t size, const char *fmt, ...);
 | 
					int esnprintf(char *str, size_t size, const char *fmt, ...);
 | 
				
			||||||
const char *bprintf(const char *fmt, ...);
 | 
					const char *bprintf(const char *fmt, ...);
 | 
				
			||||||
const char *fmt_human(uint64_t num, int base);
 | 
					const char *fmt_human(uintmax_t num, int base);
 | 
				
			||||||
int pscanf(const char *path, const char *fmt, ...);
 | 
					int pscanf(const char *path, const char *fmt, ...);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user