avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] New device support


From: Bob Paddock
Subject: Re: [avr-libc-dev] New device support
Date: Sat, 14 Jul 2007 20:50:04 -0400
User-agent: KMail/1.9.5

On Saturday 14 July 2007 15:24, Joerg Wunsch wrote:
> As Bob Paddock wrote:

> > Rule 6.5: "Bit fields of type signed int shall be at least two bits
> > long".
> 
> That makes no sense at all to me (but that's not surprising with
> MISRA, I'd say ;-).  I don't see any value in that requirement,
> and 
> it's in the way not only of using bit-fields for IO bits as proposed

A *signed* integer requires two bits, one for the value, the other
for the sign of the value.  Don't see that as an issue,
as it would not make sense to have a signed register bit for I/O.

> obviously, MISRA is not concerned about resource consumption anyway.

They are better than some of the others.  Maybe I'll ask on the AVR-GCC
list what, if any, standards people use for their code.

I use MISRA because it is practical for applications that the AVR's are
good for.  Using something like DO-178B would just not be all that
much fun on the AVR, but I've considered it.

> you could easily mix up the bit names (which are just numbers then),

"Magic Numbers" are never allowed in the code, this includes the I/O usage.
Everything beyond the simple values like 0 through 9, are syboles.

> and e.g. try to assign WGM02 to register TCCR0A rather than TCCR0B,
> yielding something completely different than you intended.  This
> cannot happen when saying »TCCR0B_.wgm02 = 1;« because the wrong
> statement »TCCR0A_.wgm02 = 1;« would not be accepted by the compiler.

I agree.  If I was writing new code, and it did not make the code grow in size,
or get slower, I'd use them, when operating on a single bit value.
My point was with backwards compatibility.

> The question arises then: do you need a compile-time option (say,
> define _NO_IO_BITFIELDS from the command-line) to turn IO bit-fields
> completely off so they won't be seen by the MISRA checker?  Or would
> it be sufficient if they were present in a header file but are not
> used by your code?

Headers are treated differently that than the actual code, as
far as the checker goes.  I use Gimpel Lint myself, but there
is also the open source Splint.  http://www.splint.org/
No reason that they need to be turned on or off.



-- 
                http://www.wearablesmartsensors.com/
 http://www.softwaresafety.net/ http://www.designer-iii.com/
                 http://www.unusualresearch.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]