public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Tomasz Kutyla <tkutyla@marp.pl>
To: bob.koninckx@o-3s.com
Cc: Kurt Siedenburg <kurt.siedenburg@vicom.com>,
	  ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] system ASSERT problem
Date: Wed, 21 Mar 2007 16:02:00 -0000	[thread overview]
Message-ID: <460156F7.9030908@marp.pl> (raw)
In-Reply-To: <W918531533933611174492007@webmail2>

Below is the code for mcard_open:

int mcard_open(mcard_t *card)
{
   CYG_CHECK_DATA_PTR(card, "Valid card pointer required");

   if( !card ) return -EINVAL;

   if( card->opened ) return 0;

   card->bmask = NULL;
   card->mcard_hdl = 0;

   int e;

   e = cyg_io_lookup ("/dev/i2c/m14c64", &card->mcard_hdl);

   if( !card->mcard_hdl ) return e;

   e = mcard_read_header(card);
   if( e ) return e;
   
   MCARD_PRINT_HEADER(&card->header);

   e = mcard_read_bmask(card);
   if( e ) return e;

   MCARD_PRINT_BMASK(card);

   card->opened = true;

   return 0;
}

Tomasz



bob.koninckx@o-3s.com napisaÂł(a):
>> -----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
>>
>>
>>     
>
>
>
>   

-- 
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

  reply	other threads:[~2007-03-21 16:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-21 15:47 bob.koninckx
2007-03-21 16:02 ` Tomasz Kutyla [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-03-21 17:23 bob.koninckx
2007-03-26 15:39 ` Tomasz Kutyla
2007-03-21 10:09 Tomasz Kutyła
2007-03-21 10:14 ` Andrew Lunn
2007-03-21 10:32   ` Tomasz Kutyła
2007-03-21 13:36     ` Andrew Lunn
2007-03-21 16:00       ` Tomasz Kutyla
2007-03-21 16:03         ` Andrew Lunn
2007-03-21 15:09     ` Kurt Siedenburg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=460156F7.9030908@marp.pl \
    --to=tkutyla@marp.pl \
    --cc=bob.koninckx@o-3s.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    --cc=kurt.siedenburg@vicom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).