[LTP] [PATCH 04/18] API/cgroup: Add CTRL_NAME_MAX define

Luke Nowakowski-Krijger luke.nowakowskikrijger@canonical.com
Thu Jul 21 22:52:14 CEST 2022


Add a define for max controller name that will be useful for parsing
controller names from strings and helps avoid having unexplained numbers
in the codebase.

Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
---
 lib/tst_cgroup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index 677a6f318..e9652703f 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -196,6 +196,7 @@ static const struct cgroup_file io_ctrl_files[] = {
 	{ }
 };
 
+#define CTRL_NAME_MAX 31
 /* Lookup tree for item names. */
 static struct cgroup_ctrl controllers[] = {
 	[0] = { "cgroup", cgroup_ctrl_files, 0, NULL, 0 },
@@ -966,7 +967,7 @@ static const struct cgroup_file *cgroup_file_find(const char *const file,
 {
 	const struct cgroup_file *cfile;
 	const struct cgroup_ctrl *ctrl;
-	char ctrl_name[32];
+	char ctrl_name[CTRL_NAME_MAX + 1];
 	const char *const sep = strchr(file_name, '.');
 	size_t len;
 
-- 
2.34.1



More information about the ltp mailing list