From 1b75b0cd1e95784d0f28401844f9306a365d01e7 Mon Sep 17 00:00:00 2001 From: RajaniRanjan Date: Mon, 4 Mar 2024 15:11:08 +0530 Subject: [PATCH] Fix Static Analysis Issues for HOST thermal Utility Module. 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 Signed-off-by: Vilas R K --- vm_thermal_utility/thermal_sysfsread.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/vm_thermal_utility/thermal_sysfsread.c b/vm_thermal_utility/thermal_sysfsread.c index a2da1c9..7f1bb67 100644 --- a/vm_thermal_utility/thermal_sysfsread.c +++ b/vm_thermal_utility/thermal_sysfsread.c @@ -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; }