mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-25 04:06:03 +00:00
i8k: allocate i8k_procbuf after opening /proc/i8k
this lets us simplify error handling
This commit is contained in:
parent
48154e9805
commit
74de272dce
@ -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...");
|
||||
|
Loading…
Reference in New Issue
Block a user