This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: sscanf() exception issue of C lib
- From: Jonathan Larmour <jifl at eCosCentric dot com>
- To: Xiaochen Zhou <zhouxiaochen at h3c dot com>
- Cc: eCos discussion <ecos-discuss at ecos dot sourceware dot org>
- Date: Wed, 14 Jan 2009 17:34:25 +0000
- Subject: Re: [ECOS] sscanf() exception issue of C lib
- Openpgp: id=A5FB74E6
- References: <496C3E08.7050400@h3c.com>
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