This is the mail archive of the ecos-discuss@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: system ASSERT problem


>-----Original Message-----
>From: Kurt Siedenburg [mailto:kurt.siedenburg@vicom.com]
>Sent: Wednesday, March 21, 2007 11:07 AM
>To: 'Tomasz Kutyła', ecos-discuss@ecos.sourceware.org
>Subject: RE: [ECOS] system ASSERT problem
>
>My best guess is that due to advanced compiler optimization the compiler determines that the line
>   e = mcard_open(&mcard);
>either always sets mcard.mcard_hdl to NULL.
>Or the whole call to mcard_open gets optimized away.

We did not see the code of mcard_open. Does it actually change the value of mcard.mcard_hdl? If it doesn't, the assert just does what it is supposed to do.

>  Kurt

Bob

>
>-----Original Message-----
>From: ecos-discuss-owner@ecos.sourceware.org [mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Tomasz Kutyla
>Sent: Wednesday, March 21, 2007 3:32 AM
>To: ecos-discuss@ecos.sourceware.org
>Subject: Re: [ECOS] system ASSERT problem
>
>
>>> I got strange problem with my application. When I compile system with 
>>> global compiler flags
>>>
>>> -ml -m4 -O2 -Wall -Wpointer-arith -Wstrict-prototypes -Winline 
>>> -Wundef -Woverloaded-virtual -ggdb -ffunction-sections 
>>> -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority 
>>> -save-temps
>>>
>>> I got info on terminal:
>>>
>>> ASSERT FAIL: <3>mcard.c[193]int mcard_write_bmask() Valid card 
>>> handler required
>>> ASSERT FAIL: mcard.c             [ 193] int 
>>> mcard_write_bmask()                                                         
>>> Valid card handler required
>>>
>>> But when I remove '-O2' flag the problems doesn't occur. What can be 
>>> the problem???
>>>     
>>
>> There is no mcard.c in the repository, so i guess it is something you 
>> have added. Without the code it is hard to guess what is happening.
>Below is the code that generates the ASSERT:
>
>int mcard_write_bmask(mcard_t *card)
>{
>   CYG_CHECK_DATA_PTR(card, "valid card pointer required");
>   CYG_CHECK_DATA_PTR(card->bmask, "valid mask pointer required");
>   CYG_ASSERT(card->mcard_hdl,"Valid card handler required");
>
>   if( !card->mcard_hdl ) return -EINVAL;
>   if( !card->bmask ) return -EINVAL;
>
>   int e;
>   e = mcard_verify_card(card);
>   if( e ) return e;
>
>   e = cyg_io_set_config(card->mcard_hdl,CYG_IO_SET_CONFIG_CARD_LOCK,0,0);
>   if( e ) return -EIO;
>
>   cyg_uint32 address = card->header.bmask_offset;
>    cyg_uint32 len = sizeof(cyg_uint32);
>    
>cyg_io_set_config(card->mcard_hdl,CYG_IO_SET_CONFIG_CARD_WRITE_POS,&address,&len);
>    len = card->header.bmask_size;
> 
>    e = cyg_io_write(card->mcard_hdl,card->bmask,&len);
>   
>   cyg_io_set_config(card->mcard_hdl,CYG_IO_SET_CONFIG_CARD_UNLOCK,0,0);
>
>   if( e ) return -EIO;
>
>   return ENOERR;
>}
>
>**************************
>
>and the mcard_write_bmask function is called from function below:
>
>typedef struct mcard_t
>{
>   cyg_io_handle_t   mcard_hdl;
>   mcard_header_t    header;
>   mcard_bmask_t    *bmask;
>   cyg_uint8         opened;
>} mcard_t;
>
>int I::formatCard()
>{
>   int e;
>
>   mcard_t mcard;
>   mcard.mcard_hdl = 0;
>   e = mcard_open(&mcard);
>   if( e ) return -1;
>
>   MCARD_PRINT_HEADER(&mcard.header);
>
>   CLEAR_BUF(mcard.bmask,mcard.header.bmask_size);
>   e = mcard_write_bmask(&mcard);
>   if( e ) return e;
>
>   MCARD_PRINT_BMASK(&mcard);
>
>   mcard_pdata_t pdata;
>   CLEAR_BUF(&pdata,sizeof(mcard_pdata_t))
>   e = mcard_write_pdata(&mcard, &pdata);
>   if( e ) return e;
>
>   MCARD_PRINT_PDATA(&pdata);
>
>   return 0;
>}
>
>--
>Tomasz Kutyla, Design Engineer
>MARP Electronic Sp. z o.o., ul. Pachonskiego 9, 31-223 Krakow tel. +48 12 415-87-29 (ext. 35), mob.: +48 693 112 191 fax +48 12 415-86-80
>
>e-mail: tkutyla@marp.pl; http://www.marp.pl
>
>
>--
>Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
>and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
>
>-- 
>Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
>and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
>



-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


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