[PATCH 1/4] Make fprintf return number of bytes written

Marc Kleine-Budde mkl at pengutronix.de
Thu Nov 10 08:20:51 EST 2011


On 11/10/2011 02:15 PM, 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 at profusion.mobi>

Acked-by: Marc Kleine-Budde <mkl at pengutronix.de>

> ---
> 
> v2: use proper indentation
> 
>  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..0d2a33b 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;
>  }
>  EXPORT_SYMBOL(fprintf);
>  
> diff --git a/common/console_simple.c b/common/console_simple.c
> index 7304d8e..1f60e79 100644
> --- a/common/console_simple.c
> +++ b/common/console_simple.c
> @@ -45,7 +45,7 @@ int vprintf (const char *fmt, va_list args)
>  }
>  EXPORT_SYMBOL(vprintf);
>  
> -void fprintf (int file, const char *fmt, ...)
> +int fprintf (int file, const char *fmt, ...)
>  {
>  	va_list args;
>  	uint i;
> @@ -61,6 +61,8 @@ void fprintf (int file, const char *fmt, ...)
>  
>  	/* Print the string */
>  	fputs(file, printbuffer);
> +
> +	return i;
>  }
>  EXPORT_SYMBOL(fprintf);
>  
> diff --git a/include/stdio.h b/include/stdio.h
> index a0d81d3..0c68fa8 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);


-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20111110/2344d565/attachment.sig>


More information about the barebox mailing list