mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/4] Make fprintf return number of bytes written
Date: Fri, 11 Nov 2011 12:27:38 +0100	[thread overview]
Message-ID: <20111111112738.GQ16886@pengutronix.de> (raw)
In-Reply-To: <1320874797-14270-2-git-send-email-lucas.demarchi@profusion.mobi>

On Wed, Nov 09, 2011 at 07:39:54PM -0200, Lucas De Marchi wrote:
> Return number of bytes written, like its siblings function. This also
> removes the warning below on gcc >= 4.6.
> 
> common/console.c:333:7: warning: variable ‘i’ set but not used
> [-Wunused-but-set-variable]
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
> ---
>  common/console.c        |    4 +++-
>  common/console_simple.c |    4 +++-
>  include/stdio.h         |    2 +-
>  3 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/common/console.c b/common/console.c
> index 06e9c29..7f2810e 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -327,7 +327,7 @@ void console_flush(void)
>  }
>  EXPORT_SYMBOL(console_flush);
>  
> -void fprintf (int file, const char *fmt, ...)
> +int fprintf (int file, const char *fmt, ...)
>  {
>  	va_list args;
>  	uint i;
> @@ -343,6 +343,8 @@ void fprintf (int file, const char *fmt, ...)
>  
>  	/* Print the string */
>  	fputs (file, printbuffer);
> +
> +        return i;
>  }

I just applied another patch I suggested earlier which fixes the return
value of the various puts functions. With this I suggest returning the
return value of fputs here instead of a bogus 1.


From 1856d45fbc2fa01415d97ea868d16ea7a974f66b Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Fri, 11 Nov 2011 12:25:53 +0100
Subject: [PATCH] fix fprintf prototype and return value

The puts functions now properly return the number of characters
written. With this we can also fix fprintf.
Also, remove never reached return in fputs.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/console.c |    5 ++---
 include/stdio.h  |    2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/console.c b/common/console.c
index e82934b..944dd07 100644
--- a/common/console.c
+++ b/common/console.c
@@ -318,7 +318,6 @@ int fputs(int fd, const char *s)
 		return eputs(s);
 	else
 		return write(fd, s, strlen(s));
-	return 0;
 }
 EXPORT_SYMBOL(fputs);
 
@@ -333,7 +332,7 @@ void console_flush(void)
 }
 EXPORT_SYMBOL(console_flush);
 
-void fprintf (int file, const char *fmt, ...)
+int fprintf(int file, const char *fmt, ...)
 {
 	va_list args;
 	uint i;
@@ -348,7 +347,7 @@ void fprintf (int file, const char *fmt, ...)
 	va_end (args);
 
 	/* Print the string */
-	fputs (file, printbuffer);
+	return fputs(file, printbuffer);
 }
 EXPORT_SYMBOL(fprintf);
 
diff --git a/include/stdio.h b/include/stdio.h
index bfaeb6c..4901bc7 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -54,7 +54,7 @@ int	vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
 #define stderr		2
 #define MAX_FILES	128
 
-void	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
+int	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
 int	fputs(int file, const char *s);
 int	fputc(int file, const char c);
 int	ftstc(int file);
-- 
1.7.7.1

-- 
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 |

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

  parent reply	other threads:[~2011-11-11 11:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-09 21:39 [PATCH 0/4] Fixes for x86 Lucas De Marchi
2011-11-09 21:39 ` [PATCH 1/4] Make fprintf return number of bytes written Lucas De Marchi
2011-11-10 10:53   ` Marc Kleine-Budde
2011-11-10 13:15     ` Lucas De Marchi
2011-11-10 13:20       ` Marc Kleine-Budde
2011-11-11 11:27   ` Sascha Hauer [this message]
2011-11-11 13:39     ` Lucas De Marchi
2011-11-09 21:39 ` [PATCH 2/4] Add setupmbr to gitignore Lucas De Marchi
2011-11-09 21:39 ` [PATCH 3/4] x86: fix build error because of missing header Lucas De Marchi
2011-11-09 21:39 ` [PATCH 4/4] x86: fix symbol size calculation Lucas De Marchi
2011-11-11 11:29 ` [PATCH 0/4] Fixes for x86 Sascha Hauer

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=20111111112738.GQ16886@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=lucas.demarchi@profusion.mobi \
    /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