diff options
author | David Phillips <dbphillipsnz@gmail.com> | 2015-09-01 19:19:24 +1200 |
---|---|---|
committer | David Phillips <dbphillipsnz@gmail.com> | 2015-09-01 19:19:24 +1200 |
commit | dec1efba06aeadcd9a4f13e8591f2efa016a24a0 (patch) | |
tree | 1293bc4cf8bc8a5acd3f9aef5fbc7215f3689983 /getgov.c | |
parent | 93b76533735fc1d9fd666787acd65db8507d9119 (diff) | |
download | paramano-dec1efba06aeadcd9a4f13e8591f2efa016a24a0.tar.xz |
Replace asprintf calls with snprintf
Diffstat (limited to 'getgov.c')
-rw-r--r-- | getgov.c | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -57,14 +57,11 @@ void gg_init() bool gg_current(int core, char* out, int size) { FILE* fd; - char *path; - asprintf(&path, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", core); + char path[1024]; + snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", core); if (!(fd = fopen(path, "r"))) - { - free(path); return false; - } fgets(out, size, fd); @@ -73,7 +70,6 @@ bool gg_current(int core, char* out, int size) *newline = '\0'; fclose(fd); - free(path); return true; } @@ -83,18 +79,15 @@ bool gg_current(int core, char* out, int size) **********************************************************************/ bool gg_available(int core, char* out, int size) { - char *path; + char path[1024]; FILE *fd; - asprintf(&path, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_available_governors", core); + snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_available_governors", core); if (!(fd = fopen(path, "r"))) - { - free(path); return false; - } + fgets(out, size, fd); fclose(fd); - free(path); return true; } |