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

Lucas De Marchi lucas.demarchi at profusion.mobi
Fri Nov 11 08:39:02 EST 2011


On Fri, Nov 11, 2011 at 9:27 AM, Sascha Hauer <s.hauer at pengutronix.de> wrote:
> 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 at 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.

It makes sense. Thanks

Lucas De Marchi



More information about the barebox mailing list