aboutsummaryrefslogtreecommitdiff
path: root/getcore.c
diff options
context:
space:
mode:
authorDavid <dbphillipsnz@gmail.com>2014-07-25 22:11:01 +1200
committerDavid <dbphillipsnz@gmail.com>2014-07-25 22:11:01 +1200
commit4297d84d20dee84620e600a29bfa24572677cf05 (patch)
treec138d20b170beebc2b65619992e0b57282c40d5a /getcore.c
parent42d79b75c81f6d25293c02eab71e3437d9d892b5 (diff)
downloadparamano-4297d84d20dee84620e600a29bfa24572677cf05.tar.xz
Moved from sprintf to asprintf
Diffstat (limited to 'getcore.c')
-rw-r--r--getcore.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/getcore.c b/getcore.c
index 51ac0e4..3014db0 100644
--- a/getcore.c
+++ b/getcore.c
@@ -33,12 +33,13 @@ unsigned int cores;
**********************************************************************/
bool core_exists(unsigned int core)
{
- FILE* fd;
- char path[128];
-
- sprintf(path, "/sys/devices/system/cpu/cpu%d/cpufreq", core);
+ char* path;
+ int result;
+ asprintf(&path, "/sys/devices/system/cpu/cpu%d/cpufreq", core);
debug("Checking if core %d exists by opening '%s'\n",core,path);
- return (access(path, F_OK) != -1);
+ result = access(path, F_OK);
+ free (path);
+ return (result != -1);
}