From 744eec841a15484d3bf992fb27b8ebf7580dcab2 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Thu, 25 May 2017 15:43:16 +0800 Subject: [PATCH] fix sprintf warming fix #309 Signed-off-by: Lai Jiangshan --- src/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util.c b/src/util.c index 77b4f22d..ad602e3c 100644 --- a/src/util.c +++ b/src/util.c @@ -511,7 +511,7 @@ void online_cpu(void) ret = sscanf(entry->d_name, "cpu%d", &num); if (ret < 1 || num == 0) /* skip none cpu%d and cpu0 */ continue; - sprintf(path, "/sys/devices/system/cpu/%s/online", entry->d_name); + sprintf(path, "/sys/devices/system/cpu/cpu%d/online", num); fd = open(path, O_RDWR); if (fd < 0) { fprintf(stderr, "open %s failed\n", path); @@ -547,7 +547,7 @@ void online_memory(void) ret = sscanf(entry->d_name, "memory%d", &num); if (ret < 1 || num == 0) /* skip none memory%d and memory0 */ continue; - sprintf(path, "/sys/devices/system/memory/%s/online", entry->d_name); + sprintf(path, "/sys/devices/system/memory/memory%d/online", num); fd = open(path, O_RDWR); if (fd < 0) { fprintf(stderr, "open %s failed\n", path);