|
@@ -89,17 +89,28 @@ int cg_read(const char *cgroup, const char *control, char *buf, size_t len)
|
|
|
int cg_read_strcmp(const char *cgroup, const char *control,
|
|
|
const char *expected)
|
|
|
{
|
|
|
- size_t size = strlen(expected) + 1;
|
|
|
+ size_t size;
|
|
|
char *buf;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ /* Handle the case of comparing against empty string */
|
|
|
+ if (!expected)
|
|
|
+ size = 32;
|
|
|
+ else
|
|
|
+ size = strlen(expected) + 1;
|
|
|
|
|
|
buf = malloc(size);
|
|
|
if (!buf)
|
|
|
return -1;
|
|
|
|
|
|
- if (cg_read(cgroup, control, buf, size))
|
|
|
+ if (cg_read(cgroup, control, buf, size)) {
|
|
|
+ free(buf);
|
|
|
return -1;
|
|
|
+ }
|
|
|
|
|
|
- return strcmp(expected, buf);
|
|
|
+ ret = strcmp(expected, buf);
|
|
|
+ free(buf);
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int cg_read_strstr(const char *cgroup, const char *control, const char *needle)
|