Skip to contentSkip to conversation

API/CGroups: Remove TEST macro use from library

PATCH New Richard Palethorpe 2 participants 2 messages Jun 4, 2021 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 API/CGroups: Remove TEST macro use from library

---
 lib/tst_cgroup.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
lib/tst_cgroup.c +7 -6
index 6d94ea41c..2b99c81a4 100644
@@ -1073,6 +1073,7 @@ ssize_t safe_cgroup_read(const char *const file, const int lineno,
 	const char *alias;
 	size_t prev_len = 0;
 	char prev_buf[BUFSIZ];
+	ssize_t read_ret = 0;
 
 	for_each_dir(cg, cfile->ctrl_indx, dir) {
 		if (!(alias = cgroup_file_alias(cfile, *dir)))
@@ -1081,9 +1082,9 @@ ssize_t safe_cgroup_read(const char *const file, const int lineno,
 		if (prev_len)
 			memcpy(prev_buf, out, prev_len);
 
-		TEST(safe_file_readat(file, lineno,
-				      (*dir)->dir_fd, alias, out, len));
-		if (TST_RET < 0)
+		read_ret = safe_file_readat(file, lineno,
+					    (*dir)->dir_fd, alias, out, len);
+		if (read_ret < 0)
 			continue;
 
 		if (prev_len && memcmp(out, prev_buf, prev_len)) {
@@ -1093,12 +1094,12 @@ ssize_t safe_cgroup_read(const char *const file, const int lineno,
 			break;
 		}
 
-		prev_len = MIN(sizeof(prev_buf), (size_t)TST_RET);
+		prev_len = MIN(sizeof(prev_buf), (size_t)read_ret);
 	}
 
-	out[MAX(TST_RET, 0)] = '\0';
+	out[MAX(read_ret, 0)] = '\0';
 
-	return TST_RET;
+	return read_ret;
 }
 
 void safe_cgroup_printf(const char *const file, const int lineno,
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/1 API/CGroups: Remove TEST macro use from library

Hi!
Huh, this is subset of the pach in the RFC I'm just started to look at.

I guess that we can apply the RFC patch "Add scripts to remove TEST in library" or do you want to send split into several pieces?

Signature · 2 lines
Cyril Hrubis
[email protected]