Properly initialize file pointers to null

If in `init_cpu_power_data_k10temp` we fail to initialize all paths,
and fail initialization, then in the destructor, we will most likely
pass invalid value to the `fclose`.
pull/414/head
Witold Baryluk 3 years ago committed by jackun
parent 26262e24ff
commit 558b8eb093

@ -68,10 +68,10 @@ struct CPUPowerData_k10temp : public CPUPowerData {
fclose(this->socCurrentFile); fclose(this->socCurrentFile);
}; };
FILE* coreVoltageFile; FILE* coreVoltageFile {nullptr};
FILE* coreCurrentFile; FILE* coreCurrentFile {nullptr};
FILE* socVoltageFile; FILE* socVoltageFile {nullptr};
FILE* socCurrentFile; FILE* socCurrentFile {nullptr};
}; };
struct CPUPowerData_zenpower : public CPUPowerData { struct CPUPowerData_zenpower : public CPUPowerData {
@ -86,8 +86,8 @@ struct CPUPowerData_zenpower : public CPUPowerData {
fclose(this->socPowerFile); fclose(this->socPowerFile);
}; };
FILE* corePowerFile; FILE* corePowerFile {nullptr};
FILE* socPowerFile; FILE* socPowerFile {nullptr};
}; };
struct CPUPowerData_rapl : public CPUPowerData { struct CPUPowerData_rapl : public CPUPowerData {
@ -101,7 +101,7 @@ struct CPUPowerData_rapl : public CPUPowerData {
fclose(this->energyCounterFile); fclose(this->energyCounterFile);
}; };
FILE* energyCounterFile; FILE* energyCounterFile {nullptr};
int lastCounterValue; int lastCounterValue;
Clock::time_point lastCounterValueTime; Clock::time_point lastCounterValueTime;
}; };

Loading…
Cancel
Save