public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] cgroup: Handle trailing new line in cgroup.controllers
@ 2023-10-25 11:05 Richard Palethorpe via ltp
  2023-10-25 11:19 ` Marius Kittler
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Palethorpe via ltp @ 2023-10-25 11:05 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

The last item in cgroup.controllers (misc in my case) contained a new
line character which caused the controller search to fail.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---

This stops cgroup_regression_test.sh from failing on
Tumbleweed. However there are other issues with that test which are
not addressed by this patch.

 lib/tst_cgroup.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index 5240aadaa..d70b5431d 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -433,9 +433,20 @@ __attribute__ ((nonnull, warn_unused_result))
 static struct cgroup_ctrl *cgroup_find_ctrl(const char *const ctrl_name)
 {
 	struct cgroup_ctrl *ctrl;
+	int l = 0;
+
+	while (ctrl_name[l] >= 'a' && ctrl_name[l] <= 'z')
+		l++;
+
+	switch (ctrl_name[l]) {
+	case '\n': break;
+	case '\0': break;
+	default:
+		tst_brk(TBROK, "Unexpected char in %s: %c", ctrl_name, ctrl_name[l]);
+	}
 
 	for_each_ctrl(ctrl) {
-		if (!strcmp(ctrl_name, ctrl->ctrl_name))
+		if (!strncmp(ctrl_name, ctrl->ctrl_name, l))
 			return ctrl;
 	}
 
-- 
2.40.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-26  9:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-25 11:05 [LTP] [PATCH] cgroup: Handle trailing new line in cgroup.controllers Richard Palethorpe via ltp
2023-10-25 11:19 ` Marius Kittler
2023-10-25 15:18   ` Petr Vorel
2023-10-26  7:32     ` Richard Palethorpe
2023-10-26  9:34       ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox