aboutsummaryrefslogtreecommitdiff
path: root/trayfreq_set
diff options
context:
space:
mode:
authorDavid <dbphillipsnz@gmail.com>2014-04-04 16:39:54 +1300
committerDavid <dbphillipsnz@gmail.com>2014-04-04 16:39:54 +1300
commit3259ddd1e74e88642913c2b6facc1377ac875a9e (patch)
tree617194833363e3bc7780ad38621fb154fe99023d /trayfreq_set
parent057f2e83f04459fef5d88f6c49bb9db5cc22693f (diff)
downloadparamano-3259ddd1e74e88642913c2b6facc1377ac875a9e.tar.xz
Segfault bugfix
Diffstat (limited to 'trayfreq_set')
-rw-r--r--trayfreq_set/trayfreq_set.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/trayfreq_set/trayfreq_set.c b/trayfreq_set/trayfreq_set.c
index 083d993..d90717a 100644
--- a/trayfreq_set/trayfreq_set.c
+++ b/trayfreq_set/trayfreq_set.c
@@ -29,8 +29,11 @@ void set_freq_max(char* freq, char* core)
sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_max_freq", core);
FILE* fd = fopen(file_path, "w");
- fprintf(fd, freq);
- fclose(fd);
+ if (fd)
+ {
+ fprintf(fd, freq);
+ fclose(fd);
+ }
}
void set_freq_min(char* freq, char* core)
@@ -39,8 +42,11 @@ void set_freq_min(char* freq, char* core)
sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_min_freq", core);
FILE* fd = fopen(file_path, "w");
- fprintf(fd, freq);
- fclose(fd);
+ if (fd)
+ {
+ fprintf(fd, freq);
+ fclose(fd);
+ }
}
static void set_speed(char* freq, char* core)
@@ -49,8 +55,11 @@ static void set_speed(char* freq, char* core)
sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_setspeed", core);
FILE* fd = fopen(file_path, "w");
- fprintf(fd, freq);
- fclose(fd);
+ if (fd)
+ {
+ fprintf(fd, freq);
+ fclose(fd);
+ }
}
void set_gov(char* gov, char* core)
@@ -59,8 +68,11 @@ void set_gov(char* gov, char* core)
sprintf(file_path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_governor", core);
FILE* fd = fopen(file_path, "w");
- fprintf(fd, gov);
- fclose(fd);
+ if (fd)
+ {
+ fprintf(fd, gov);
+ fclose(fd);
+ }
}
void set_freq(char* freq, char* core)