aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPA4WDH2024-08-26 19:56:17 +0200
committerPA4WDH2024-08-26 19:56:17 +0200
commitf47ea91e2d1b04aea2c23f40c98801e948d7a950 (patch)
treea949edc52e7ad7bbb2413107fd29ab1dc5af85c9
parentSmall fixes in cpulist.c (diff)
downloadcputemp2maxfreq-f47ea91e2d1b04aea2c23f40c98801e948d7a950.tar.gz
cputemp2maxfreq-f47ea91e2d1b04aea2c23f40c98801e948d7a950.tar.bz2
cputemp2maxfreq-f47ea91e2d1b04aea2c23f40c98801e948d7a950.zip
Add more compiler warnings
-rw-r--r--Makefile2
-rw-r--r--argparse.c4
-rw-r--r--cpulist.c4
-rw-r--r--cputemp.c2
-rw-r--r--sysfs.c8
-rw-r--r--sysfs.h2
6 files changed, 11 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index ccbcac1..005d7b7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
CC=gcc
-CFLAGS=-Wall -Werror
+CFLAGS=-Wall -Wformat -Wconversion -Wtrampolines -Wimplicit-fallthrough -Werror
cputemp2maxfreq: version.o debug.o sysfs.o cpufreq.o failsafe.o argparse.o logger.o cputemp.o cpulist.o
diff --git a/argparse.c b/argparse.c
index 19a6493..e748b3e 100644
--- a/argparse.c
+++ b/argparse.c
@@ -120,14 +120,14 @@ void argparse(int argc, char **argv)
userconfig.log_data=1;
break;
case 'p':
- userconfig.interval=strtoll(optarg,NULL,10);
+ userconfig.interval=(unsigned int) strtoll(optarg,NULL,10);
break;
case 'P':
if (strcmp(optarg,"all")==0)
{
userconfig.cpu=-1;
} else {
- userconfig.cpu=strtoll(optarg,NULL,10);
+ userconfig.cpu=(int) strtoll(optarg,NULL,10);
}
break;
case 's':
diff --git a/cpulist.c b/cpulist.c
index eb219b5..c6af342 100644
--- a/cpulist.c
+++ b/cpulist.c
@@ -19,7 +19,7 @@ void cpulist_add(char *cpu)
int newlen;
newlen=cpudata.cpulist_len+1;
- cpudata.cpulist=reallocarray(cpudata.cpulist,newlen,sizeof(char *));
+ cpudata.cpulist=reallocarray(cpudata.cpulist,(size_t) newlen,sizeof(char *));
cpudata.cpulist[cpudata.cpulist_len]=malloc(strlen(cpu)+1);
strcpy(cpudata.cpulist[cpudata.cpulist_len],cpu);
@@ -77,7 +77,7 @@ int cpulist_find_cpus()
{
DEBUG2_CPULIST("Found CPU %s\n",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);
+ package=(int) sysfs_read_long_int(sysfs_file);
DEBUG2_CPULIST("CPU Belongs to package id %d\n",package);
if ((package==config.cpu) || (config.cpu<0))
{
diff --git a/cputemp.c b/cputemp.c
index ca616b1..95ce517 100644
--- a/cputemp.c
+++ b/cputemp.c
@@ -102,7 +102,7 @@ void cputemp_read_hwmon(char *hwmon,char *sensor_name,struct s_sensor *sensor)
DEBUG2_CPUTEMP("Found label %s\n",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;
+ offset=(int) strlen(input_file)-5;
strncpy(input_file+offset,"input",6);
cputemp_match_and_validate(name_file,input_file,sensor_name,sensor);
}
diff --git a/sysfs.c b/sysfs.c
index d6e4d60..6ea7701 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -12,7 +12,7 @@ extern struct s_config config;
int sysfs_read_str(char *sysfs_file,char *buf,size_t bufsize)
{
int sysfs_handle;
- size_t datalen;
+ ssize_t datalen;
DEBUG1_SYSFS("Reading sysfs file %s\n",sysfs_file);
@@ -35,7 +35,7 @@ int sysfs_read_str(char *sysfs_file,char *buf,size_t bufsize)
buf[datalen]=0;
}
- return datalen;
+ return (int) datalen;
}
long int sysfs_read_long_int(char *sysfs_file)
@@ -54,7 +54,7 @@ long int sysfs_read_long_int(char *sysfs_file)
int sysfs_write_str(char *sysfs_file,char *value,long int checkdelay)
{
int sysfs_handle;
- size_t len;
+ ssize_t len;
char buf[255];
DEBUG1_SYSFS("Writing %s to sysfs file %s\n",value,sysfs_file);
@@ -75,7 +75,7 @@ int sysfs_write_str(char *sysfs_file,char *value,long int checkdelay)
DEBUG2_SYSFS("Written %zd bytes\n",len);
// Wait if instructed to
- if (checkdelay>0) usleep(checkdelay);
+ if (checkdelay>0) usleep((unsigned int) checkdelay);
// Validate we actually set what we want to set
sysfs_read_str(sysfs_file,buf,sizeof(buf));
diff --git a/sysfs.h b/sysfs.h
index 3acecc9..68ff808 100644
--- a/sysfs.h
+++ b/sysfs.h
@@ -3,6 +3,6 @@
int sysfs_read_str(char *sysfs_file,char *buf,size_t bufsize);
long int sysfs_read_long_int(char *sysfs_file);
-int sysfs_write_str(char *sysfs_file,char *value,int checkdelay);
+int sysfs_write_str(char *sysfs_file,char *value,long int checkdelay);
#endif