diff mbox series

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

Message ID 4aeef9742f059e0c2f4c0941790829a82299f715.1651176646.git.luke.nowakowskikrijger@canonical.com
State Changes Requested
Headers show
Series Expand Cgroup lib and modify controller tests | expand

Commit Message

Luke Nowakowski-Krijger April 28, 2022, 8:39 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(-)

Comments

Petr Vorel May 3, 2022, 2:26 p.m. UTC | #1
Hi Luke,

obviously correct.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr
diff mbox series

Patch

diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index b8632cdf3..2d4e4a2fe 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -197,6 +197,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 },
@@ -967,7 +968,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;