[CRIU] [PATCH 2/6] tty: Use find_next_bit helper to test tty_active_pairs bitmap

Cyrill Gorcunov gorcunov at openvz.org
Wed Sep 26 09:05:43 EDT 2012


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 tty.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/tty.c b/tty.c
index 0749e40..ee63273 100644
--- a/tty.c
+++ b/tty.c
@@ -146,11 +146,21 @@ static int tty_get_index(u32 id)
 /* Make sure the active pairs do exist */
 int tty_verify_active_pairs(void)
 {
-	int i;
+	unsigned long i;
+
+	for (i = 0; i < sizeof(tty_active_pairs); i++) {
+		i = find_next_bit(tty_active_pairs,
+				  sizeof(tty_active_pairs), i);
+
+		if (i >= sizeof(tty_active_pairs))
+			break;
+
+		if (is_log2(i)) {
+			if (test_bit(i + 1, tty_active_pairs)) {
+				i++;
+				continue;
+			}
 
-	for (i = 0; i < (MAX_TTYS << 1); i += 2) {
-		if (test_bit(i, tty_active_pairs) &&
-		    !test_bit(i + 1, tty_active_pairs)) {
 			pr_err("Found slave peer index %d without "
 				"correspond master peer\n",
 				tty_get_index(i));
-- 
1.7.7.6



More information about the CRIU mailing list