[PATCH] console: fix return values of puts functions

Sascha Hauer s.hauer at pengutronix.de
Fri Oct 14 02:56:22 EDT 2011


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/console.c |   14 ++++++++++----
 include/stdio.h  |    6 +++---
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/common/console.c b/common/console.c
index 0d2a33b..6216e88 100644
--- a/common/console.c
+++ b/common/console.c
@@ -292,24 +292,30 @@ int fputc(int fd, char c)
 }
 EXPORT_SYMBOL(fputc);
 
-void console_puts(unsigned int ch, const char *str)
+int console_puts(unsigned int ch, const char *str)
 {
 	const char *s = str;
+	int n = 0;
+
 	while (*s) {
-		if (*s == '\n')
+		if (*s == '\n') {
 			console_putc(ch, '\r');
+			n++;
+		}
 		console_putc(ch, *s);
+		n++;
 		s++;
 	}
+	return n;
 }
 EXPORT_SYMBOL(console_puts);
 
 int fputs(int fd, const char *s)
 {
 	if (fd == 1)
-		puts(s);
+		return puts(s);
 	else if (fd == 2)
-		eputs(s);
+		return eputs(s);
 	else
 		return write(fd, s, strlen(s));
 	return 0;
diff --git a/include/stdio.h b/include/stdio.h
index 0c68fa8..4901bc7 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -17,12 +17,12 @@ int	tstc(void);
 /* stdout */
 void	console_putc(unsigned int ch, const char c);
 int	getc(void);
-void	console_puts(unsigned int ch, const char *s);
+int	console_puts(unsigned int ch, const char *s);
 void	console_flush(void);
 
-static inline void puts(const char *s)
+static inline int puts(const char *s)
 {
-	console_puts(CONSOLE_STDOUT, s);
+	return console_puts(CONSOLE_STDOUT, s);
 }
 
 static inline void putchar(char c)
-- 
1.7.7

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list