uwu
This commit is contained in:
@@ -56,18 +56,17 @@ int get_hwmon_dir(char *path, const size_t bufsz) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* instead of building the path here we could build it once in *_detect funcs for each sensor, but thats a lot of paths damn
|
/* instead of building the path here we could build it once in *_detect funcs for each sensor, but thats a lot of paths damn
|
||||||
* actual slowdown is in the syscalls anyway, open(), read(), close () */
|
* actual slowdown is in the syscalls anyway, open(), read(), close () */
|
||||||
|
|
||||||
/* read n bytes from path into buffer */
|
/* read n bytes from path into buffer */
|
||||||
inline size_t read_file(const char *dir, const char *file, char *buffer, const size_t n) {
|
inline size_t read_file(const char *dir, const char *file, char *buffer, const size_t n) {
|
||||||
char path[192]; // bug alert
|
char path[160]; // bug alert
|
||||||
char *nt = stpcpy(path, dir); // nt is a pointer to the null terminator of the copied string
|
char *nt = stpcpy(path, dir); // nt is a pointer to the null terminator of the copied string
|
||||||
stpcpy(nt, file); // write at the null terminator address, aka append to the end
|
stpcpy(nt, file); // write at the null terminator address, aka append to the end
|
||||||
const int fd = open(path, O_RDONLY | O_CLOEXEC);
|
const int fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (buffer != NULL)
|
if (buffer != NULL) // if its null means we're just checking if it exists at all, so dont log it
|
||||||
applog(LOG_ERR, "Error reading %s", path);
|
applog(LOG_ERR, "Error reading %s", path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user