[PATCH 09/27] console: Fix console_get_first_active()

Andrey Smirnov andrew.smirnov at gmail.com
Thu Jun 14 21:11:18 PDT 2018


Fix if condition in console_get_first_active() to actually check that
both bit are set.

Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
---
 common/console_common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/console_common.c b/common/console_common.c
index 00e020bd3..0131a1190 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -301,12 +301,13 @@ EXPORT_SYMBOL(console_get_by_name);
 struct console_device *console_get_first_active(void)
 {
 	struct console_device *cdev;
+	const unsigned char active = CONSOLE_STDIN | CONSOLE_STDOUT;
 	/*
 	 * Assumption to have BOTH CONSOLE_STDIN AND STDOUT in the
 	 * same output console
 	 */
 	for_each_console(cdev) {
-		if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT)))
+		if ((cdev->f_active & active) == active)
 			return cdev;
 	}
 
-- 
2.17.0




More information about the barebox mailing list