Skip to content

Commit

Permalink
Fix Static Analysis Issues for HOST thermal Utility Module.
Browse files Browse the repository at this point in the history
Below mentioned Static Analysis issues have been fixed.
+-----------------------------------------+
| 1. Unchecked return value from library  |
|                                         |
| 2. Ignoring number of bytes read        |
+-----------------------------------------+

Tracked-On: OAM-115786
Signed-off-by: RajaniRanjan <[email protected]>
  • Loading branch information
RajaniRanjan committed Feb 28, 2024
1 parent 7616257 commit 108b120
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions vm_thermal_utility/thermal_sysfsread.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,18 @@ void read_sysfs_values(char *base_path, char *filename, void *buf, int len, int
return;
}

if (flag==0)
fread(buf, len, 1, fp);
else
fscanf (fp, "%d", (int*)buf); /* read/validate value */
if (flag==0) {
if (fread(buf, len, 1, fp) == EOF) {
fclose (fp);
return;
}
}
else {
if (fscanf (fp, "%d", (int*)buf) < 0) {
fclose (fp);
return;
}
}
fclose (fp);
return;
}
Expand Down

0 comments on commit 108b120

Please sign in to comment.