From 7ef7501c22f91a3793b46edbdad10ea6fa8115fd Mon Sep 17 00:00:00 2001 From: Martin Mares <mj@ucw.cz> Date: Mon, 17 Oct 2016 15:10:51 +0200 Subject: [PATCH] Avoid warnings on unused result of fscanf() --- cgroup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cgroup.c b/cgroup.c index c2b0b17..4ed8872 100644 --- a/cgroup.c +++ b/cgroup.c @@ -133,9 +133,9 @@ cgroup_get_mem_limit(const char *chier, const char *cgroup) return -1; } size_t nlimit = 0; - fscanf(limit, "%zu", &nlimit); + int ok = fscanf(limit, "%zu", &nlimit); fclose(limit); - return nlimit; + return ok ? nlimit : 0; } static int @@ -198,7 +198,7 @@ cgroup_get_mem_usage(const char *chier, const char *cgroup) return -1; } size_t nusage = 0; - fscanf(usage, "%zu", &nusage); + int ok = fscanf(usage, "%zu", &nusage); fclose(usage); - return nusage; + return ok ? nusage : 0; } -- GitLab