diff mbox series

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

Message ID 46af6d78ec4a1f6d0eb12da5d578b200f12e4281.1658433280.git.luke.nowakowskikrijger@canonical.com
State Accepted
Headers show
Series Expand Cgroup lib and modify controller tests | expand

Commit Message

Luke Nowakowski-Krijger July 21, 2022, 8:52 p.m. UTC
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 mbox series

Patch

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;