Hello,
I ran powerdebug on i386 (ubuntu 13.04) and it seems its outputting wrong information in "Sensors" info page. Suspects are colored blue below -
# sudo ./powerdebug
PowerDebug 0.7.2 Clocks Regulators Sensors Gpio Name Value coretemp temp1_crit_alarm 0.0 temp3_input 34.0 temp3_label 34.0 ----> This seems incorrect temp2_crit_alarm 0.0 temp1_crit 99.0 temp2_crit 99.0 temp3_crit 99.0 temp4_crit 99.0 temp5_crit 99.0 temp4_input 23.0 temp4_label 23.0 ----> This seems incorrect temp3_crit_alarm 0.0 temp4_crit_alarm 0.0 temp5_input 34.0 temp5_label 34.0 ----> This seems incorrect temp5_crit_alarm 0.0 temp1_input 34.0 temp1_label 34.0 ----> This seems incorrect temp1_max 80.0 temp2_max 80.0 temp3_max 80.0 temp4_max 80.0 temp5_max 80.0 temp2_input 28.0 temp2_label 28.0 ----> This seems incorrect
The contents of these files are not any legal integer value as expected -
# cat temp*_label Physical id 0 Core 0 Core 1 Core 2 Core 3
The problem I think is in the below code in utils.c/file_read_value()-
ret = fscanf(file, format, value) == EOF ? -1 : 0;
We are comparing with EOF. In this case fscanf is returning zero. So this check passes and returns success. So old value is retained in "value" from previous read.
A simple fix would be to change the line to -
ret = fscanf(file, format, value) <= 0 ? -1 : 0;
Would you care to check?
diff --git a/utils.c b/utils.c index 4d4b780..bfe2ba3 100644 --- a/utils.c +++ b/utils.c @@ -46,7 +46,7 @@ int file_read_value(const char *path, const char *name, goto out_free; }
- ret = fscanf(file, format, value) == EOF ? -1 : 0; + ret = fscanf(file, format, value) <= 0 ? -1 : 0;
fclose(file); out_free:
-- Thanks, -Meraj