1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 12:10:03 +00:00

i8k: allocate i8k_procbuf after opening /proc/i8k

this lets us simplify error handling
This commit is contained in:
bi4k8 2023-05-05 00:48:51 +00:00 committed by bi4k8
parent 48154e9805
commit 74de272dce

View File

@ -56,17 +56,14 @@ static char *i8k_procbuf = nullptr;
int update_i8k(void) {
FILE *fp;
if (!i8k_procbuf) { i8k_procbuf = (char *)malloc(128 * sizeof(char)); }
if ((fp = fopen(PROC_I8K, "r")) == nullptr) {
free_and_zero(i8k_procbuf);
/*THREAD_CRIT_ERR(nullptr, NULL, "/proc/i8k doesn't exist! use insmod to
make sure the kernel " "driver is loaded...");*/
NORM_ERR(
"/proc/i8k doesn't exist! use insmod to make sure the kernel driver is "
"loaded...");
return 1;
}
if (!i8k_procbuf) { i8k_procbuf = (char *)malloc(128 * sizeof(char)); }
memset(&i8k_procbuf[0], 0, 128);
if (fread(&i8k_procbuf[0], sizeof(char), 128, fp) == 0) {
NORM_ERR("something wrong with /proc/i8k...");