avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Standard IO - function fwrite


From: Marjan Fojkar
Subject: Re: [avr-gcc-list] Standard IO - function fwrite
Date: Mon, 11 Jun 2007 16:53:47 +0200
User-agent: Thunderbird 1.5.0.12 (Windows/20070509)



Joerg Wunsch wrote:
(Please don't send HTML mails, it's cumbersome to handle.)

Marjan Fojkar <address@hidden> wrote:

Yes you are right. But if you use this function for binary data it
doesn't work.

Why?

Function fwrite enters into for loop and stays there
until putc returns zero or all data have been written.

It's not putc() but rather the put() backend function you provided in
fdevopen()/fdev_setup_stream(), and it stops when this put() function
returns *non*-zero, as that indicates an error or EOF condition.

I see now it is truly function put which represents pointer to my
backend function put and not putc. I'm gessing
it is time to buy glasses for myself :-)
And as you wrote below i have bug in my backend put function which behaves like putc.
Thanks for help!
If data contain zero values the fwrite will exit on first zero
value.

I suspect you simply botched your put() backend function.  That
function is supposed to return 0 on success, _FDEV_ERR (-1) on error,
or _FDEV_EOF (-2) on EOF in case your driver/device can experience
some kind of end-of-file situation that is distinguishable from a
simple write error.
Btw., vfprintf() has a bug in that it ignores the error/EOF status
when writing, and proceeds anyway.  Feel free to write a bug report
for that.  Also, fputc() does not appropriately set the error and EOF
flags, another bug.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]