This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: _vprintf() return code fix and diag_vsnprintf() addition


On Mon, Oct 20, 2008 at 07:32:19PM -0700, Berend Ozceri wrote:
> This fixes a return value error in _vprintf() (if _sputc() clips the  
> output due to the maximum output buffer length being reached) 

Could you explain this a bit more. Which functions are returning the
wrong value?

The man page for vprintf says this:

       Upon successful return, these functions return the number of
       characters printed (not including the trailing '\0' used to end
       output to strings).

       The functions snprintf() and vsnprintf() do not write more than
       size bytes (including the trailing '\0').  If the output was
       truncated due to this limit then the return value is the
       number of characters (not including the trailing '\0') which
       would have been written to the final string if enough space had
       been available.  Thus, a return value of size or more means
       that the output was truncated.

My understanding of the eCos code is that the current _vprintf()
function returns the unrestricted number of characters. info->len is
the number of characters actually output, which may of been truncated.

It seems to me diag_vsprintf(), diag_snprintf() and diag_sprintf() are
wrong. These all return info.len when they should return the return
value from _vprintf().

Would you agree?

      Thanks
        Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]