From 4297d84d20dee84620e600a29bfa24572677cf05 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 25 Jul 2014 22:11:01 +1200 Subject: Moved from sprintf to asprintf --- getcore.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'getcore.c') 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); } -- cgit v1.1