<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Evaluating embedded code</title>
	<atom:link href="http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/</link>
	<description>Thoughts on embedded systems by Nigel Jones</description>
	<lastBuildDate>Thu, 09 Feb 2012 07:32:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Patrick</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/comment-page-1/#comment-3740</link>
		<dc:creator>Patrick</dc:creator>
		<pubDate>Mon, 11 Apr 2011 22:33:56 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=471#comment-3740</guid>
		<description>The vast majority of them are in code that looks like:

...
sched_lock()
if (error_1) {
    err = EINVAL;
    goto out;
}

if (error_2) {
    err = ENOMEM;
    goto out;
}

// real work happens here

out:

sched_unlock();
return err;</description>
		<content:encoded><![CDATA[<p>The vast majority of them are in code that looks like:</p>
<p>&#8230;<br />
sched_lock()<br />
if (error_1) {<br />
    err = EINVAL;<br />
    goto out;<br />
}</p>
<p>if (error_2) {<br />
    err = ENOMEM;<br />
    goto out;<br />
}</p>
<p>// real work happens here</p>
<p>out:</p>
<p>sched_unlock();<br />
return err;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/comment-page-1/#comment-3739</link>
		<dc:creator>Patrick</dc:creator>
		<pubDate>Mon, 11 Apr 2011 22:31:38 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=471#comment-3739</guid>
		<description>The vast majority of them are in code that looks like:

...
sched_lock()
if (error_1)
    goto out;

if (error_2)</description>
		<content:encoded><![CDATA[<p>The vast majority of them are in code that looks like:</p>
<p>&#8230;<br />
sched_lock()<br />
if (error_1)<br />
    goto out;</p>
<p>if (error_2)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/comment-page-1/#comment-3731</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Mon, 11 Apr 2011 10:41:45 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=471#comment-3731</guid>
		<description>1891 incidences of goto - what are the authors doing to justify that number?</description>
		<content:encoded><![CDATA[<p>1891 incidences of goto &#8211; what are the authors doing to justify that number?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/comment-page-1/#comment-3728</link>
		<dc:creator>Patrick</dc:creator>
		<pubDate>Mon, 11 Apr 2011 02:44:21 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=471#comment-3728</guid>
		<description>I only just came across this interesting post. I work on a reasonably sized embedded controller project and thought I might give this tool a run for your interest. When doing this type of checking I also like to do a quick grep for goto statements.

Here&#039;s the stats:

Metrics Summary For Checkpoint &#039;Baseline&#039;
--------------------------------------------------------------------------------------------

Parameter				Value
=========				=====
Project Directory			Z:\home\patrick\src\e7\prex\
Project Name				e7
Checkpoint Name				Baseline
Created On				11 Apr 2011, 12:42:03
Files					2071
Lines					320,507
Statements				151,780
Percent Branch Statements		15.6
Percent Lines with Comments		25.7
Classes Defined				82
Methods Implemented per Class		5.93
Average Statements per Method		7.1
Maximum Complexity			109
Maximum Block Depth			9+
Average Block Depth			1.37
Average Complexity			4.44
Functions				5,961

--------------------------------------------------------------------------------------------
Block Depth				Statements

0					32,735
1					67,619
2					25,782
3					17,484
4					5,092
5					2,111
6					749
7					160
8					39
9+					9
--------------------------------------------------------------------------------------------

const: 5635
volatile: 209
static: 4995
case: 4307
goto: 1891</description>
		<content:encoded><![CDATA[<p>I only just came across this interesting post. I work on a reasonably sized embedded controller project and thought I might give this tool a run for your interest. When doing this type of checking I also like to do a quick grep for goto statements.</p>
<p>Here&#8217;s the stats:</p>
<p>Metrics Summary For Checkpoint &#8216;Baseline&#8217;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Parameter				Value<br />
=========				=====<br />
Project Directory			Z:\home\patrick\src\e7\prex\<br />
Project Name				e7<br />
Checkpoint Name				Baseline<br />
Created On				11 Apr 2011, 12:42:03<br />
Files					2071<br />
Lines					320,507<br />
Statements				151,780<br />
Percent Branch Statements		15.6<br />
Percent Lines with Comments		25.7<br />
Classes Defined				82<br />
Methods Implemented per Class		5.93<br />
Average Statements per Method		7.1<br />
Maximum Complexity			109<br />
Maximum Block Depth			9+<br />
Average Block Depth			1.37<br />
Average Complexity			4.44<br />
Functions				5,961</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Block Depth				Statements</p>
<p>0					32,735<br />
1					67,619<br />
2					25,782<br />
3					17,484<br />
4					5,092<br />
5					2,111<br />
6					749<br />
7					160<br />
8					39<br />
9+					9<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>const: 5635<br />
volatile: 209<br />
static: 4995<br />
case: 4307<br />
goto: 1891</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Joseph</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/comment-page-1/#comment-3361</link>
		<dc:creator>Andrew Joseph</dc:creator>
		<pubDate>Fri, 11 Feb 2011 17:01:49 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=471#comment-3361</guid>
		<description>Took me time to read all the comments, but I really enjoyed the post. It proved to be really useful to me and I&#039;m sure to all of the commenters right here! It&#039;s usually good when you can not only be informed, but additionally engaged! I am certain you had joy writing this article.</description>
		<content:encoded><![CDATA[<p>Took me time to read all the comments, but I really enjoyed the post. It proved to be really useful to me and I&#8217;m sure to all of the commenters right here! It&#8217;s usually good when you can not only be informed, but additionally engaged! I am certain you had joy writing this article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/comment-page-1/#comment-1499</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Sat, 14 Aug 2010 00:44:24 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=471#comment-1499</guid>
		<description>I&#039;m not sure if you are regular reader of this blog. However &#039;volatile&#039; is a topic that I frequently touch upon. I thought this &lt;a href=&quot;http://embeddedgurus.com/stack-overflow/2009/01/using-volatile-to-achieve-persistence/&quot; rel=&quot;nofollow&quot;&gt;post &lt;/a&gt;was entertaining. I also from time to time discuss compiler selection and have expressed the opinion that IAR compiler&#039;s are really very good and that&lt;a href=&quot;http://embeddedgurus.com/stack-overflow/2010/02/is-gcc-a-good-compiler/&quot; rel=&quot;nofollow&quot;&gt; GCC is not for me&lt;/a&gt;.

BTW, I&#039;m really enjoying your comments!</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure if you are regular reader of this blog. However &#8216;volatile&#8217; is a topic that I frequently touch upon. I thought this <a href="http://embeddedgurus.com/stack-overflow/2009/01/using-volatile-to-achieve-persistence/" rel="nofollow">post </a>was entertaining. I also from time to time discuss compiler selection and have expressed the opinion that IAR compiler&#8217;s are really very good and that<a href="http://embeddedgurus.com/stack-overflow/2010/02/is-gcc-a-good-compiler/" rel="nofollow"> GCC is not for me</a>.</p>
<p>BTW, I&#8217;m really enjoying your comments!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashleigh</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/comment-page-1/#comment-1494</link>
		<dc:creator>Ashleigh</dc:creator>
		<pubDate>Sat, 14 Aug 2010 00:22:48 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=471#comment-1494</guid>
		<description>Part of the reason volatile works reasonably well on IAR is the bugs I reported in their compiler a few years back :-)

I recently did a benchmarking of GCC for MSP430 vs IAR - compiling the same code (about 600 lines of source) which included an interrupt handler. For both compilers I set maximum optimisation (for smallest code side). I was kind of stunned by the results. The code side generated for GCC was about 50% larger than IAR. This was all confirmed by inspecting the generated code for each and counting bytes.

While at it I checked a number of other compilers and was astonished to find that some of them can&#039;t even generate a proper compiler listing file. How on earth can a serious embedded engineer work with a compiler where you can&#039;t see what it does? (Looking at the mnemonics does not count, I want to see the byte stream and the size / offset from the start for every function.)</description>
		<content:encoded><![CDATA[<p>Part of the reason volatile works reasonably well on IAR is the bugs I reported in their compiler a few years back <img src='http://embeddedgurus.com/stack-overflow/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I recently did a benchmarking of GCC for MSP430 vs IAR &#8211; compiling the same code (about 600 lines of source) which included an interrupt handler. For both compilers I set maximum optimisation (for smallest code side). I was kind of stunned by the results. The code side generated for GCC was about 50% larger than IAR. This was all confirmed by inspecting the generated code for each and counting bytes.</p>
<p>While at it I checked a number of other compilers and was astonished to find that some of them can&#8217;t even generate a proper compiler listing file. How on earth can a serious embedded engineer work with a compiler where you can&#8217;t see what it does? (Looking at the mnemonics does not count, I want to see the byte stream and the size / offset from the start for every function.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lundin</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/comment-page-1/#comment-1205</link>
		<dc:creator>Lundin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 13:33:13 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=471#comment-1205</guid>
		<description>I think that this method works for detecting utterly horrible, broken code. For anything less coarse, I don&#039;t think it will work.

I have one example of two programs. They are both running on the same hardware, they are nearly identical in size and functionality (safety-critical field bus systems). But the code quality is very different.

One of the programs contains excellent code. Very easy to read, throughoutly tested with static analyzers and with full MISRA-C compliance. The other program contains sloppy, complex and fairly unreadable/unmaintainable code, with lots of MISRA-C violations. 

Results below. I stripped away all search hits of volatile that directly referred to hardware register maps, as that seems highly irrelevant to the quality of the program. Also, both programs are dealing with dip-SWITCHes, so the number of switch hits is mostly from code comments regarding dip-switches... Lesson learnt from that is that one should probably only run &quot;grep&quot; on raw pre-processor output.


Files:		36
Lines:		14,269
Statements:	5,227
% Branches:	10.9
% Comments:	40.6
Functions:	171
Avg stms/func:	19.3
Max complexity:	69
Max depth:	9+
Avg depth:	0.86
Avg complexity:	4.25
volatile:	41
const:		197
static:		117
switch:		20


Files:		41
Lines:		15,427
Statements:	5,866
% Branches	12.8
% Comments	38.2
Functions:	189
Avg stms/func:	22.3
Max complexity:	133
Max depth:	9+
Avg depth:	1.09
Avg complexity:	4.87
volatile:	43
const:		201
static:		171
switch:		23

As you can see, the results are almost identical. Just by the metrics, it is impossible to tell which one that is the good program (it is the 1st one).</description>
		<content:encoded><![CDATA[<p>I think that this method works for detecting utterly horrible, broken code. For anything less coarse, I don&#8217;t think it will work.</p>
<p>I have one example of two programs. They are both running on the same hardware, they are nearly identical in size and functionality (safety-critical field bus systems). But the code quality is very different.</p>
<p>One of the programs contains excellent code. Very easy to read, throughoutly tested with static analyzers and with full MISRA-C compliance. The other program contains sloppy, complex and fairly unreadable/unmaintainable code, with lots of MISRA-C violations. </p>
<p>Results below. I stripped away all search hits of volatile that directly referred to hardware register maps, as that seems highly irrelevant to the quality of the program. Also, both programs are dealing with dip-SWITCHes, so the number of switch hits is mostly from code comments regarding dip-switches&#8230; Lesson learnt from that is that one should probably only run &#8220;grep&#8221; on raw pre-processor output.</p>
<p>Files:		36<br />
Lines:		14,269<br />
Statements:	5,227<br />
% Branches:	10.9<br />
% Comments:	40.6<br />
Functions:	171<br />
Avg stms/func:	19.3<br />
Max complexity:	69<br />
Max depth:	9+<br />
Avg depth:	0.86<br />
Avg complexity:	4.25<br />
volatile:	41<br />
const:		197<br />
static:		117<br />
switch:		20</p>
<p>Files:		41<br />
Lines:		15,427<br />
Statements:	5,866<br />
% Branches	12.8<br />
% Comments	38.2<br />
Functions:	189<br />
Avg stms/func:	22.3<br />
Max complexity:	133<br />
Max depth:	9+<br />
Avg depth:	1.09<br />
Avg complexity:	4.87<br />
volatile:	43<br />
const:		201<br />
static:		171<br />
switch:		23</p>
<p>As you can see, the results are almost identical. Just by the metrics, it is impossible to tell which one that is the good program (it is the 1st one).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/comment-page-1/#comment-1204</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Wed, 30 Jun 2010 13:16:25 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=471#comment-1204</guid>
		<description>I can&#039;t see why we would need their consent. However their help is indeed useful. I&#039;m also happy to report that IAR was enthusiastic about working with John Regehr. I suspect that John will be reporting on the results at some point.</description>
		<content:encoded><![CDATA[<p>I can&#8217;t see why we would need their consent. However their help is indeed useful. I&#8217;m also happy to report that IAR was enthusiastic about working with John Regehr. I suspect that John will be reporting on the results at some point.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gauthier</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/06/evaluating-embedded-code/comment-page-1/#comment-1203</link>
		<dc:creator>Gauthier</dc:creator>
		<pubDate>Wed, 30 Jun 2010 13:02:35 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=471#comment-1203</guid>
		<description>Do you need their help or consent to analyse the volatile behaviour of their compiler? I thought you were analysing the assembly output in different cases.
Although I would understand if you did not want to do it without them hiring you for it.</description>
		<content:encoded><![CDATA[<p>Do you need their help or consent to analyse the volatile behaviour of their compiler? I thought you were analysing the assembly output in different cases.<br />
Although I would understand if you did not want to do it without them hiring you for it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

