public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/6] Make *printf() return "int" instead of "void"
Date: Thu, 24 Jun 2010 00:06:12 +0200	[thread overview]
Message-ID: <1277330773-28395-6-git-send-email-wd@denx.de> (raw)
In-Reply-To: <1277330773-28395-1-git-send-email-wd@denx.de>

Change the return type of the *printf() functions to the standard
"int"; no changes are needed but returning the already available
length count.

This will save a few additional strlen() calls later...

Signed-off-by: Wolfgang Denk <wd@denx.de>
---
 common/console.c          |   12 ++++++++----
 examples/api/libgenwrap.c |    6 ++++--
 include/common.h          |    8 ++++----
 include/exports.h         |    4 ++--
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/common/console.c b/common/console.c
index b09b7d1..7e01886 100644
--- a/common/console.c
+++ b/common/console.c
@@ -201,7 +201,7 @@ static inline void console_doenv(int file, struct stdio_dev *dev)
 
 /** U-Boot INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS *************************/
 
-void serial_printf(const char *fmt, ...)
+int serial_printf(const char *fmt, ...)
 {
 	va_list args;
 	uint i;
@@ -216,6 +216,7 @@ void serial_printf(const char *fmt, ...)
 	va_end(args);
 
 	serial_puts(printbuffer);
+	return i;
 }
 
 int fgetc(int file)
@@ -269,7 +270,7 @@ void fputs(int file, const char *s)
 		console_puts(file, s);
 }
 
-void fprintf(int file, const char *fmt, ...)
+int fprintf(int file, const char *fmt, ...)
 {
 	va_list args;
 	uint i;
@@ -285,6 +286,7 @@ void fprintf(int file, const char *fmt, ...)
 
 	/* Send to desired file */
 	fputs(file, printbuffer);
+	return i;
 }
 
 /** U-Boot INITIAL CONSOLE-COMPATIBLE FUNCTION *****************************/
@@ -363,7 +365,7 @@ void puts(const char *s)
 	}
 }
 
-void printf(const char *fmt, ...)
+int printf(const char *fmt, ...)
 {
 	va_list args;
 	uint i;
@@ -379,9 +381,10 @@ void printf(const char *fmt, ...)
 
 	/* Print the string */
 	puts(printbuffer);
+	return i;
 }
 
-void vprintf(const char *fmt, va_list args)
+int vprintf(const char *fmt, va_list args)
 {
 	uint i;
 	char printbuffer[CONFIG_SYS_PBSIZE];
@@ -393,6 +396,7 @@ void vprintf(const char *fmt, va_list args)
 
 	/* Print the string */
 	puts(printbuffer);
+	return i;
 }
 
 /* test if ctrl-c was pressed */
diff --git a/examples/api/libgenwrap.c b/examples/api/libgenwrap.c
index b435dde..9733bbc 100644
--- a/examples/api/libgenwrap.c
+++ b/examples/api/libgenwrap.c
@@ -37,7 +37,7 @@
 /*
  * printf() and vprintf() are stolen from u-boot/common/console.c
  */
-void printf (const char *fmt, ...)
+int printf (const char *fmt, ...)
 {
 	va_list args;
 	uint i;
@@ -53,9 +53,10 @@ void printf (const char *fmt, ...)
 
 	/* Print the string */
 	ub_puts (printbuffer);
+	return i;
 }
 
-void vprintf (const char *fmt, va_list args)
+int vprintf (const char *fmt, va_list args)
 {
 	uint i;
 	char printbuffer[256];
@@ -67,6 +68,7 @@ void vprintf (const char *fmt, va_list args)
 
 	/* Print the string */
 	ub_puts (printbuffer);
+	return i;
 }
 
 void putc (const char c)
diff --git a/include/common.h b/include/common.h
index 8bca04f..48f6a1a 100644
--- a/include/common.h
+++ b/include/common.h
@@ -663,7 +663,7 @@ int	disable_ctrlc (int);	/* 1 to disable, 0 to enable Control-C detect */
  * STDIO based functions (can always be used)
  */
 /* serial stuff */
-void	serial_printf (const char *fmt, ...)
+int	serial_printf (const char *fmt, ...)
 		__attribute__ ((format (__printf__, 1, 2)));
 /* stdin */
 int	getc(void);
@@ -672,9 +672,9 @@ int	tstc(void);
 /* stdout */
 void	putc(const char c);
 void	puts(const char *s);
-void	printf(const char *fmt, ...)
+int	printf(const char *fmt, ...)
 		__attribute__ ((format (__printf__, 1, 2)));
-void	vprintf(const char *fmt, va_list args);
+int	vprintf(const char *fmt, va_list args);
 
 /* stderr */
 #define eputc(c)		fputc(stderr, c)
@@ -689,7 +689,7 @@ void	vprintf(const char *fmt, va_list args);
 #define stderr		2
 #define MAX_FILES	3
 
-void	fprintf(int file, const char *fmt, ...)
+int	fprintf(int file, const char *fmt, ...)
 		__attribute__ ((format (__printf__, 2, 3)));
 void	fputs(int file, const char *s);
 void	fputc(int file, const char c);
diff --git a/include/exports.h b/include/exports.h
index c3a5d2f..9588bc9 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -11,14 +11,14 @@ int  getc(void);
 int  tstc(void);
 void putc(const char);
 void puts(const char*);
-void printf(const char* fmt, ...);
+int printf(const char* fmt, ...);
 void install_hdlr(int, interrupt_handler_t*, void*);
 void free_hdlr(int);
 void *malloc(size_t);
 void free(void*);
 void __udelay(unsigned long);
 unsigned long get_timer(unsigned long);
-void vprintf(const char *, va_list);
+int vprintf(const char *, va_list);
 void do_reset (void);
 unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base);
 char *getenv (char *name);
-- 
1.7.0.1

  parent reply	other threads:[~2010-06-23 22:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-23 22:06 [U-Boot] [PATCH 0/6] misc fixes / cleanups Wolfgang Denk
2010-06-23 22:06 ` [U-Boot] [PATCH 1/6] boards.cfg: fix board directory name for ML2 board Wolfgang Denk
2010-06-23 22:06 ` [U-Boot] [PATCH 2/6] shannon/INFERNO: fix special handling of environment configuration Wolfgang Denk
2010-07-04 21:49   ` Wolfgang Denk
2010-06-23 22:06 ` [U-Boot] [PATCH 3/6] cmd_ide.c: fix unused variable warning for SC3 board Wolfgang Denk
2010-07-04 21:49   ` Wolfgang Denk
2010-06-23 22:06 ` [U-Boot] [PATCH 4/6] exports.c: fix warning: 'dummy' defined but not used Wolfgang Denk
2010-06-23 23:32   ` Mike Frysinger
2010-06-29  9:52   ` [U-Boot] [PATCH 4/6 v2] " Wolfgang Denk
2010-06-29 20:00     ` Mike Frysinger
2010-06-29 21:07       ` Wolfgang Denk
2010-06-30 22:44   ` [U-Boot] [PATCH 4/6 v3] " Wolfgang Denk
2010-06-30 23:04     ` Mike Frysinger
2010-07-01  7:30       ` Wolfgang Denk
2010-07-01  7:31   ` [U-Boot] [PATCH 4/6 v4] " Wolfgang Denk
2010-07-04 21:51     ` Wolfgang Denk
2010-06-23 22:06 ` Wolfgang Denk [this message]
2010-07-04 21:52   ` [U-Boot] [PATCH 5/6] Make *printf() return "int" instead of "void" Wolfgang Denk
2010-06-23 22:06 ` [U-Boot] [PATCH 6/6] Redundant environment: move flag definitions to header file Wolfgang Denk
2010-07-04 21:52   ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1277330773-28395-6-git-send-email-wd@denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox