c99 now
This commit is contained in:
14
src/utils.c
14
src/utils.c
@@ -36,7 +36,7 @@ inline char *pretty_num(const double num, char *buf, const size_t bufsz) {
|
||||
}
|
||||
|
||||
inline char *pretty_bytes(const uint64_t bytes, int8_t start_suffix, char *buf, const size_t bufsz) {
|
||||
constexpr char suffix_list[] = {'K', 'M', 'G', 'T', 'P', 'E', 'Z'};
|
||||
const char suffix_list[] = {'K', 'M', 'G', 'T', 'P', 'E', 'Z'};
|
||||
start_suffix *= -1;
|
||||
double bytes_d = (double)bytes;
|
||||
while (bytes_d > 1024.0) {
|
||||
@@ -57,7 +57,7 @@ int get_hwmon_dir(char* path) {
|
||||
glob_t g;
|
||||
strncat(path, "/hwmon*", 10);
|
||||
|
||||
if (glob(path, 0, nullptr, &g) == 0) {
|
||||
if (glob(path, 0, NULL, &g) == 0) {
|
||||
strncpy(path, g.gl_pathv[0], 128); // bug prone, careful
|
||||
globfree(&g);
|
||||
return 0;
|
||||
@@ -82,33 +82,33 @@ inline void fast_read_num_u64(const char* dir, const char* file, char* buf, uint
|
||||
char path[256];
|
||||
MKPATH(path, dir, file);
|
||||
read_file(path, buf, 32);
|
||||
*result = strtoull(buf, nullptr, 10) / divider;
|
||||
*result = strtoull(buf, NULL, 10) / divider;
|
||||
}
|
||||
|
||||
inline void fast_read_num_u16(const char* dir, const char* file, char* buf, uint16_t* result, const uint32_t divider) {
|
||||
char path[256];
|
||||
MKPATH(path, dir, file);
|
||||
read_file(path, buf, 32);
|
||||
*result = strtol(buf, nullptr, 10) / divider;
|
||||
*result = strtol(buf, NULL, 10) / divider;
|
||||
}
|
||||
|
||||
inline void fast_read_num_u8(const char* dir, const char* file, char* buf, uint8_t* result, const uint32_t divider) {
|
||||
char path[256];
|
||||
MKPATH(path, dir, file);
|
||||
read_file(path, buf, 32);
|
||||
*result = strtol(buf, nullptr, 10) / divider;
|
||||
*result = strtol(buf, NULL, 10) / divider;
|
||||
}
|
||||
|
||||
inline void fast_read_num_i16(const char* dir, const char* file, char* buf, int16_t* result, const uint32_t divider) {
|
||||
char path[256];
|
||||
MKPATH(path, dir, file);
|
||||
read_file(path, buf, 32);
|
||||
*result = strtol(buf, nullptr, 10) / divider;
|
||||
*result = strtol(buf, NULL, 10) / divider;
|
||||
}
|
||||
|
||||
inline void fast_read_num_f(const char* dir, const char* file, char* buf, float* result, const uint32_t divider) {
|
||||
char path[256];
|
||||
MKPATH(path, dir, file);
|
||||
read_file(path, buf, 32);
|
||||
*result = (float)strtoull(buf, nullptr, 10) / (float)divider;
|
||||
*result = (float)strtoull(buf, NULL, 10) / (float)divider;
|
||||
}
|
||||
Reference in New Issue
Block a user