[PATCH 24/27] console: Simplify dputs()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Knowing that puts() is just a wrapper around a call to
console_puts(CONSOLE_STDOUT, str) we can simplify the code of
dputs(). While at it, make use of *_FILENO constants to get rid of
magic numbers.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
---
 common/console_common.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/common/console_common.c b/common/console_common.c
index ce7e50dbc..6e098b27d 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -355,11 +355,19 @@ EXPORT_SYMBOL(dprintf);
 
 int dputs(int fd, const char *s)
 {
-	if (fd == 1)
-		return puts(s);
-	else if (fd == 2)
-		return console_puts(CONSOLE_STDERR, s);
-	else
+	unsigned int ch;
+
+	switch (fd) {
+	case STDOUT_FILENO:
+		ch = CONSOLE_STDOUT;
+		break;
+	case STDERR_FILENO:
+		ch = CONSOLE_STDERR;
+		break;
+	default:
 		return write(fd, s, strlen(s));
+	}
+
+	return console_puts(ch, s);
 }
 EXPORT_SYMBOL(dputs);
\ No newline at end of file
-- 
2.17.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux