diff options
author | David <dbphillipsnz@gmail.com> | 2014-04-04 16:39:54 +1300 |
---|---|---|
committer | David <dbphillipsnz@gmail.com> | 2014-04-04 16:39:54 +1300 |
commit | 3259ddd1e74e88642913c2b6facc1377ac875a9e (patch) | |
tree | 617194833363e3bc7780ad38621fb154fe99023d | |
parent | 057f2e83f04459fef5d88f6c49bb9db5cc22693f (diff) | |
download | paramano-3259ddd1e74e88642913c2b6facc1377ac875a9e.tar.xz |
Segfault bugfix
-rw-r--r-- | trayfreq.c | 2 | ||||
-rw-r--r-- | trayfreq_set/trayfreq_set.c | 28 |
2 files changed, 22 insertions, 8 deletions
@@ -39,6 +39,8 @@ void config_init() gboolean home_config_exists; config.key_file = NULL; + printf("Battery governor: %s",_DEFAULT_BAT_GOV); + config.file_name = g_strconcat(getenv("HOME"), "/.trayfreq.config", NULL); // Check if ~/.trayfreq.config exists 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) |