[CRIU] [PATCH 2/4] cg: Strip trailing \n from property's value
Pavel Emelyanov
xemul at parallels.com
Tue Aug 12 06:19:01 PDT 2014
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
cgroup.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/cgroup.c b/cgroup.c
index 5b9900d..3efbd2f 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -281,6 +281,20 @@ static int find_dir(const char *path, struct list_head *dirs, struct cgroup_dir
}
/*
+ * Strips trailing '\n' from the string
+ */
+static inline char *strip(char *str)
+{
+ char *e;
+
+ e = strchr(str, '\0');
+ if (e != str && *(e - 1) == '\n')
+ *(e - 1) = '\0';
+
+ return str;
+}
+
+/*
* Currently this function only supports properties that have 1 value, under 100
* chars
*/
@@ -315,7 +329,7 @@ static int read_cgroup_prop(struct cgroup_prop *property, const char *fpath)
return -1;
}
- property->value = xstrdup(buf);
+ property->value = xstrdup(strip(buf));
if (!property->value)
return -1;
--
1.8.4.2
More information about the CRIU
mailing list