[ECOS] sscanf() exception issue of C lib
Jonathan Larmour
jifl@eCosCentric.com
Wed Jan 14 17:35:00 GMT 2009
Xiaochen Zhou wrote:
> I try hard to check my code, but does not work. At last I browse the c
> lib code, and have some doubts with the
> language/c/libc/stdio/current/src/common/fflush.cxx
>
> // flush all but one stream
> externC Cyg_ErrNo
> cyg_libc_stdio_flush_all_but( Cyg_StdioStream *not_this_stream )
> {
[snip]
> (1) only initialize the files_flushed[0] , not all elements.
The C standard mandates that any initialiser causes any remaining elements
to be initialised to 0.
> (2) Cyg_libc_stdio_files::get_file_stream(i) is not safe here. I think
> it should need Cyg_libc_stdio_files::lock() &
> Cyg_libc_stdio_files::unlock() to protect.
>
> I'm not sure of this, can someone affirm? thanks!
Although I can't remember the details, you have to be careful in this code
to avoid deadlock. Is there any particular problem scenario you are hitting
as a result? Has your problem gone away if you add such a lock?
Jifl
--
eCosCentric Limited http://www.eCosCentric.com/ The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------ Opinions==mine
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
More information about the Ecos-discuss
mailing list