diff options
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | cpulist.c | 4 | ||||
-rw-r--r-- | cputemp.c | 12 | ||||
-rw-r--r-- | sysfs.c | 9 |
4 files changed, 20 insertions, 8 deletions
@@ -1,3 +1,6 @@ +CC=gcc +CFLAGS=-Wall -Werror + cputemp2maxfreq: version.o debug.o sysfs.o cpufreq.o failsafe.o argparse.o logger.o cputemp.o cpulist.o version.h: generate_version_h.sh .git/index @@ -44,7 +44,7 @@ int cpulist_find_cpus() { DIR *cpudir; struct dirent *cpu_dirent; - char sysfs_file[128]; + char sysfs_file[309]; int package; DEBUG1_CPULIST("Started\n") @@ -72,7 +72,7 @@ int cpulist_find_cpus() if (cpulist_is_cpu(cpu_dirent->d_name)) { DEBUG2_CPULIST("Found CPU %s\n",cpu_dirent->d_name); - snprintf(sysfs_file,128,"/sys/devices/system/cpu/%s/topology/physical_package_id",cpu_dirent->d_name); + snprintf(sysfs_file,309,"/sys/devices/system/cpu/%s/topology/physical_package_id",cpu_dirent->d_name); package=sysfs_read_long_int(sysfs_file); DEBUG2_CPULIST("CPU Belongs to package id %d\n",package); if ((package==config.cpu) || (config.cpu<0)) @@ -79,7 +79,7 @@ void cputemp_read_hwmon(char *hwmon,char *sensor_name,struct s_sensor *sensor) { DIR *hwmon_dir; struct dirent *hwmon_dirent; - char name_file[255]; + char name_file[258]; char input_file[255]; int offset; @@ -100,10 +100,10 @@ void cputemp_read_hwmon(char *hwmon,char *sensor_name,struct s_sensor *sensor) if (cputemp_is_label(hwmon_dirent->d_name)) { DEBUG2_CPUTEMP("Found label %s\n",hwmon_dirent->d_name); - sprintf(name_file,"%s/%s",hwmon,hwmon_dirent->d_name); - sprintf(input_file,"%s/%s",hwmon,hwmon_dirent->d_name); + snprintf(name_file,258,"%s/%s",hwmon,hwmon_dirent->d_name); + snprintf(input_file,258,"%s/%s",hwmon,hwmon_dirent->d_name); offset=strlen(input_file)-5; - strncpy(input_file+offset,"input",5); + strncpy(input_file+offset,"input",6); cputemp_match_and_validate(name_file,input_file,sensor_name,sensor); } hwmon_dirent=readdir(hwmon_dir); @@ -126,7 +126,7 @@ void cputemp_find_sensor(char *sensor_name,struct s_sensor *sensor) { DIR *hwmon_dir; struct dirent *hwmon_dirent; - char subdir[255]; + char subdir[273]; DEBUG1_CPUTEMP("Searching for sensor %s\n",sensor_name); @@ -149,7 +149,7 @@ void cputemp_find_sensor(char *sensor_name,struct s_sensor *sensor) // Note that /sys/class/hwmon actually contains symlinks but we treat them like directories if (strncmp(hwmon_dirent->d_name,"hwmon",5)==0) { - sprintf(subdir,"/sys/class/hwmon/%s",hwmon_dirent->d_name); + snprintf(subdir,273,"/sys/class/hwmon/%s",hwmon_dirent->d_name); DEBUG2_CPUTEMP("Found hwmon entry: %s\n",subdir); cputemp_read_hwmon(subdir,sensor_name,sensor); } @@ -3,7 +3,11 @@ #include <unistd.h> #include <stdlib.h> #include <string.h> +#include <errno.h> #include "debug.h" +#include "cputemp2maxfreq.h" + +extern struct s_config config; int sysfs_read_str(char *sysfs_file,char *buf,size_t bufsize) { @@ -62,6 +66,11 @@ int sysfs_write_str(char *sysfs_file,char *value,long int checkdelay) // Write the data len=write(sysfs_handle,value,strlen(value)); + if (len<0) + { + config.logger("Error %d occoured while writing to sysfs",errno); + } + close(sysfs_handle); DEBUG2_SYSFS("Written %zd bytes\n",len); |