diff options
author | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-09-20 00:54:04 +0000 |
---|---|---|
committer | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-09-20 00:54:04 +0000 |
commit | 1450796033fc6c06694b4a4853f9c8c62e532564 (patch) | |
tree | 27d67ac8692eb43a6c1b44011b1e3cc23c6dff2b /api.c | |
parent | 096af9029b89dc982e3849bcb3da49268abcd2cb (diff) | |
download | libcg-1450796033fc6c06694b4a4853f9c8c62e532564.tar.gz libcg-1450796033fc6c06694b4a4853f9c8c62e532564.tar.xz libcg-1450796033fc6c06694b4a4853f9c8c62e532564.zip |
Fix a warning in api.c, where we ignore the fscanf value.
I've tested the patch by running the tests available in the tests
directory.
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@185 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'api.c')
-rw-r--r-- | api.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -902,6 +902,7 @@ static char *cg_rd_ctrl_file(char *subsys, char *cgroup, char *file) char *value; char path[FILENAME_MAX]; FILE *ctrl_file; + int ret; if (!cg_build_path_locked(cgroup, path, subsys)) return NULL; @@ -919,7 +920,11 @@ static char *cg_rd_ctrl_file(char *subsys, char *cgroup, char *file) * using %as crashes when we try to read from files like * memory.stat */ - fscanf(ctrl_file, "%s", value); + ret = fscanf(ctrl_file, "%s", value); + if (ret == 0 || ret == EOF) { + free(value); + value = NULL; + } fclose(ctrl_file); |