<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" 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/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>&gt;kloctalk</title>
	
	<link>http://www.klocwork.com/blog</link>
	<description>&gt;kloctalk is a blog and a community for software development professionals who create and maintain mission-critical software and the challenges they face on a daily basis.</description>
	<lastBuildDate>Tue, 22 May 2012 17:24:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Kloctalk" /><feedburner:info uri="kloctalk" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>The business case for source code analysis</title>
		<link>http://www.klocwork.com/blog/2012/05/the-business-case-for-source-code-analysis/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=the-business-case-for-source-code-analysis</link>
		<comments>http://www.klocwork.com/blog/2012/05/the-business-case-for-source-code-analysis/#comments</comments>
		<pubDate>Tue, 15 May 2012 16:38:11 +0000</pubDate>
		<dc:creator>Brendan Harrison</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[General Industry]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[development lifecycle]]></category>
		<category><![CDATA[ROI]]></category>
		<category><![CDATA[source code analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1494</guid>
		<description><![CDATA[Everyone knows this chart, right? The later bugs are introduced, the more they cost. Of course, common sense. But it also happens to be true. As the chart shows, very little bug detection is happening before testing, while a developer is coding. So, if you find more bugs when the cost of repair is least [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone knows this chart, right?</p>
<p><img class="alignnone" style="border: 1px solid black;" title="Cost of Defects Chart (source: http://blogs.windriver.com/graham/2010/01/service-and-repair-is-not-the-only-option.html)" src="http://blogs.windriver.com/.a/6a00d83451f5c369e20120a7b67f33970b-800wi" alt="" width="527" height="263" /></p>
<p>The later bugs are introduced, the more they cost. Of course, common sense. But it also happens to be true.</p>
<p>As the chart shows, very little bug detection is happening before testing, while a developer is coding. So, if you find more bugs when the cost of repair is least expensive and risky, you&#8217;re obviously going to get a big payoff.</p>
<p>Ok, so far you haven&#8217;t heard anything that every software development professional doesn&#8217;t already know. What everyone doesn&#8217;t know is that source code analysis can deliver this payoff.</p>
<p>We just published a few new case studies from <a title="Canfield Scientific Case Study" href="http://www.klocwork.com/resources/case-study/canfield" target="_blank">Canfield Scientific</a>, <a title="Overture Case Study" href="http://www.klocwork.com/resources/case-study/overture" target="_blank">Overture Networks</a>, and <a title="Polycom Case Study" href="http://www.klocwork.com/resources/case-study/polycom" target="_blank">Polycom</a>. Here&#8217;s a sampling of what these customers are telling us about the benefits from using Klocwork:</p>
<blockquote><p><span style="font-size: small;">&#8220;Our code is more stable and reliable today, and I would say we are in a best-in class category when compared to other software companies in the industry. We can see this when development starts new coding and there is a very minimal dip in stability. Development also recovers faster and starts working on new products faster.&#8221;</span></p>
<p><span style="font-size: small;">&#8220;Many of our developers use Visual Studio and like the ability to see and address potential problems on-the-fly from their desktop. It’s not an intrusion for them – they find it to be a big time saver.&#8221;</span></p>
<p><span style="font-size: small;">Impressively, within just a few months of use, Klocwork Insight had resolved a major field issue that the company was dealing with. Even more critically, “Klocwork Insight also found three other bugs that had caused several field outages – this is a very significant achievement for us.”</span></p>
</blockquote>
<p><span style="font-size: small;">Check out these case studies in full, and you&#8217;ll see how the benefits these customers are realizing all go back to the chart above &#8211; find issues earlier, make your developers&#8217; lives easier, reduce costs, and build better software. Great to see our customers achieving these results!<br />
 </span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2012/05/the-business-case-for-source-code-analysis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Static analysis is NOT Bugzilla</title>
		<link>http://www.klocwork.com/blog/2012/04/static-analysis-is-not-bugzilla/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=static-analysis-is-not-bugzilla</link>
		<comments>http://www.klocwork.com/blog/2012/04/static-analysis-is-not-bugzilla/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 20:09:04 +0000</pubDate>
		<dc:creator>Alen Zukich</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[General Coding]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[Bugzilla]]></category>
		<category><![CDATA[source code analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1487</guid>
		<description><![CDATA[Time and time again I get asked, how does static analysis fit into my existing bug tracking system? &#8221;I need an integration with my system (i.e. Bugzilla) because that is what we use everyday. Every time I find a bug I need to track this through my system.&#8221; This is where I take a deep breath as [...]]]></description>
			<content:encoded><![CDATA[<p>Time and time again I get asked, how does static analysis fit into my existing bug tracking system? &#8221;I need an integration with my system (i.e. Bugzilla) because that is what we use everyday. Every time I find a bug I need to track this through my system.&#8221;</p>
<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2012/04/blog1.png"><img class="size-full wp-image-1489 alignright" title="blog1" src="http://www.klocwork.com/blog/wp-content/uploads/2012/04/blog1.png" alt="" width="374" height="249" /></a></p>
<p>This is where I take a deep breath as I scream on the inside. Taking every bug and putting that into your bug tracking system is just wrong. Horribly wrong.</p>
<p>The best way I can describe this is through the compiler analogy. Every time you add a feature or bug fix, you run your compiler. Your compiler complains, saying you have a syntax error and you just fix that, rinse and repeat.  Would you ever send your syntax errors to your bug tracking system? Uh, no. So why do the same for static analysis? Just because it is a critical buffer overflow or memory leak? No.</p>
<p>Why impose any kind of workflow for the developer when it comes to bugs? There should only be one thing the developer has in mind. Either fix the issue or ignore it. Just like they do for any syntax error from the compiler.</p>
<p>This is really a discussion of your usage of your static analysis (or source code analysis) tool.  What I&#8217;ve described is the process where the developer is using static analysis at the desktop, in their favorite text editor or IDE. Of course, there is an exception to this. You can use static analysis on the full system run only. I highly discourage this for various <a href="http://www.klocwork.com/blog/2011/06/the-evolution-of-static-code-analysis-part-3-the-present-day/" target="_blank">reasons</a> but I&#8217;ll save that for another discussion.</p>
<p>The chances are that you could have a product that is already established, so you probably have a backlog of issues.  Static analysis can certainly be used to triage these bugs and output them to your bug tracking system.</p>
<p>I hope my message is clear, if you use static analysis correctly (allowing the developers to fix bugs as they create them) and a bug appears, just plain fix it.  Yes, it&#8217;s that simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2012/04/static-analysis-is-not-bugzilla/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making static analysis simple, one squiggly line at a time</title>
		<link>http://www.klocwork.com/blog/2012/04/making-static-analysis-simple-one-squiggly-line-at-a-time/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=making-static-analysis-simple-one-squiggly-line-at-a-time</link>
		<comments>http://www.klocwork.com/blog/2012/04/making-static-analysis-simple-one-squiggly-line-at-a-time/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 16:28:21 +0000</pubDate>
		<dc:creator>Brendan Harrison</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[General Coding]]></category>
		<category><![CDATA[desktop analysis]]></category>
		<category><![CDATA[spell checker]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1476</guid>
		<description><![CDATA[As we continue to rollout Klocwork Insight 9.5 our message around making static analysis simple is taking hold. To put the change we&#8217;ve made into its appropriate context, let&#8217;s think about how spell checkers mainstreamed, and how a somewhat obvious (looking back) usability change turned this amazingly useful technology from something you do at the [...]]]></description>
			<content:encoded><![CDATA[<p>As we continue to rollout <a href="http://www.klocwork.com/products/klocwork-insight-95-whats-new/">Klocwork Insight 9.5</a> our <a title="Klocwork Insight 9.5 Available" href="http://www.klocwork.com/blog/2012/01/its-been-a-while-since-our-last-post-but-weve-been-busy/">message</a> around making <a href="http://www.klocwork.com/products/insight/klocwork-truepath/">static analysis</a> simple is taking hold.   To put the change we&#8217;ve made into its appropriate context, let&#8217;s think about how spell checkers mainstreamed, and how a somewhat obvious (looking back) usability change turned this amazingly useful technology from something you do at the end of writing a document, to an activity that just automatically works while you create documents, making people more productive in the process.</p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<div id="attachment_1484" class="wp-caption aligncenter" style="width: 710px"><a href="http://www.klocwork.com/blog/wp-content/uploads/2012/04/spellcheck-new-old.png"><img class="size-full wp-image-1484    " title="Two Spell Check Usability Models" src="http://www.klocwork.com/blog/wp-content/uploads/2012/04/spellcheck-new-old.png" alt="" width="700" height="175" /></a><p class="wp-caption-text">Two Different Spell Checker Usability Models</p></div>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p style="text-align: left;">On the surface the difference looks subtle but the changes are huge. The first scenario required the user to take action, interrupt their workflow, and was a &#8220;separate&#8221; activity from writing a document. The usability model we&#8217;re all familiar with now is naturally incorporated into a writer&#8217;s workflow. It still does the same thing: it checks your spelling against its dictionary, provides suggestions, and will auto-correct for you. But the difference in ease-of-use and end-user adoption of the technology has obviously been huge.</p>
<p style="text-align: left;">That&#8217;s what we&#8217;ve done with static analysis. We&#8217;ve taken a complex analysis technology that used to only live at integration build time, moved it down to the desktop in 2008 (much like the usability model on the left above), and now with Klocwork Insight 9.5 have introduced the model to the right. Here are some links to short <a title="Klocwork Plug-in for Visual Studio" href="http://www.klocwork.com/resources/video/static-analysis-for-visual-studio/display">Klocwork Desktop Analysis for Visual Studio demos </a>showing this capability in-action.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2012/04/making-static-analysis-simple-one-squiggly-line-at-a-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Answering questions about your code base — Part 2</title>
		<link>http://www.klocwork.com/blog/2012/04/answering-questions-about-your-code-base-part-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=answering-questions-about-your-code-base-part-2</link>
		<comments>http://www.klocwork.com/blog/2012/04/answering-questions-about-your-code-base-part-2/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 14:00:35 +0000</pubDate>
		<dc:creator>Patti Murphy</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[Software Complexity]]></category>
		<category><![CDATA[Software Quality]]></category>
		<category><![CDATA[Static Analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1467</guid>
		<description><![CDATA[In this continuing story about the journey to source code awesomeness, we left off at the point where we identified priority defect types for your organization, kicked off pre-checkin static analysis on developer desktops and saw build-over-build improvements in our trending reports as a result. The next question we tackle here is: What is my [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">In this continuing story about the journey to source code awesomeness, we left off at the point where we identified priority defect types for your organization, <a href="http://www.klocwork.com/blog/2012/02/answering-questions-about-your-code-base-part-1/" target="_blank">kicked off pre-checkin static analysis on developer desktops</a> and saw build-over-build improvements in our trending reports as a result.</p>
<p style="text-align: left;">The next question we tackle here is: What is my cost of ownership?</p>
<p style="text-align: left;">The answer, my friend, is not blowing in the wind, it&#8217;s in your Complexity Trend report:</p>
<div id="attachment_1471" class="wp-caption aligncenter" style="width: 564px"><a href="http://www.klocwork.com/blog/wp-content/uploads/2012/03/Picture18.png"><img class="size-full wp-image-1471 " title="Picture18" src="http://www.klocwork.com/blog/wp-content/uploads/2012/03/Picture18.png" alt="" width="554" height="423" /></a><p class="wp-caption-text">Complexity Trend report</p></div>
<p style="text-align: left;">Why there? you might ask. Well, it&#8217;s because there&#8217;s a straight-line correlation between the complexity of a function and its cost per line to code and test.</p>
<p style="text-align: left;">If we see an increase in the Complexity Trend, we can use Complexity Details to pinpoint modules or files containing the most complex methods:</p>
<div id="attachment_1472" class="wp-caption aligncenter" style="width: 593px"><a href="http://www.klocwork.com/blog/wp-content/uploads/2012/03/Complexity_Details_highlight.png"><img class="size-full wp-image-1472 " title="Complexity_Details_highlight" src="http://www.klocwork.com/blog/wp-content/uploads/2012/03/Complexity_Details_highlight.png" alt="" width="583" height="349" /></a><p class="wp-caption-text">Complexity Details report</p></div>
<p style="text-align: left;">Looking at this report, I can see where my ownership cost is localized. More often than not, we find that the modules that contain the most defects are also those that contain the highest number of  complex methods.</p>
<p style="text-align: left;">Klocwork Insight metrics use <a href="http://www.klocwork.com/products/documentation/current/McCabe_Cyclomatic_Complexity" target="_blank">McCabe Cyclomatic Complexity</a> to assess the complexity of a program.</p>
<p style="text-align: left;">Another indicator of the high cost of ownership is the point at which defects are caught and fixed. Finding and removing bugs as early as possible in the development cycle lowers your ownership costs. This report shows fix activity between builds. You can toggle between views showing fix activity in the integration build and on the desktop. For now, we’ll look at <em>All </em>fix activity:</p>
<p style="text-align: center;"> </p>
<div id="attachment_1479" class="wp-caption aligncenter" style="width: 558px"><a href="http://www.klocwork.com/blog/wp-content/uploads/2012/04/Fix_activity_by_module.png"><img class="size-full wp-image-1479   " title="Fix_activity_by_module" src="http://www.klocwork.com/blog/wp-content/uploads/2012/04/Fix_activity_by_module.png" alt="" width="548" height="420" /></a><p class="wp-caption-text">Fix activity by module</p></div>
<p style="text-align: left;">Here we see a spike in activity that occurred during the start of a new feature release.  If the upward trend continues, it can indicate a couple of scenarios. Either:</p>
<ul style="text-align: left;">
<li>Your development team is growing and more developers are using static analysis on the desktop, or </li>
<li>Your team size is the same but developers are using static analysis more consistently. </li>
</ul>
<p style="text-align: left;">Either way, more activity means more value from the tools and a lower cost of ownership. Developers fixing defects before check-in lowers your cost of ownership considerably.</p>
<p style="text-align: left;">Any more questions?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2012/04/answering-questions-about-your-code-base-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perceptual False Positives</title>
		<link>http://www.klocwork.com/blog/2012/03/perceptual-false-positives/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=perceptual-false-positives</link>
		<comments>http://www.klocwork.com/blog/2012/03/perceptual-false-positives/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 15:18:38 +0000</pubDate>
		<dc:creator>Alen Zukich</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[buffer overflow]]></category>
		<category><![CDATA[false positives]]></category>
		<category><![CDATA[source code analysis]]></category>
		<category><![CDATA[Static Analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1462</guid>
		<description><![CDATA[As any static analysis or source code analysis vendor will tell you, false positives are a way of life.  As any user will tell you, false positives suck!  So what do you do about them?  Make the tools better at finding the real issues and provide automated filtering capabilities.  But I&#8217;m not here to talk [...]]]></description>
			<content:encoded><![CDATA[<p>As any static analysis or source code analysis vendor will tell you, false positives are a way of life.  As any user will tell you, false positives suck!  So what do you do about them?  Make the tools better at finding the real issues and provide automated filtering capabilities.  But I&#8217;m not here to talk about false positives where the tool is utterly wrong.  What I want to talk about today is what I call &#8220;perceptual false positives&#8221;.</p>
<p>I&#8217;ve had discussions with customers where they tell me 80% of all their defects are false.  Odd, I know static analysis tools today are much, much better than that.  In fact it usually tends to be the other way around &#8212; 80%+ are real.  So in situations like that, you have to analyze the defects further.  After analyzing a few I can see many have been marked as &#8220;false positives&#8221; even though they are real.  When I challenge the customer it fits into either one of two categories:</p>
<p>1. I don&#8217;t care, that will never happen in my lifetime.</p>
<p>2. You&#8217;re wrong.</p>
<p>For #1, not everyone believes in defensive programming.  In some cases it doesn&#8217;t even make sense, in others I&#8217;ll still argue that it is important.  For example a customer once told me that the memory leak we identified is real but they don&#8217;t care, because it is initialization code.  Meaning when it starts, it leaks memory but it is closed off shortly after that.  I understand that sometimes you don&#8217;t have time to address every single issue, but what if someone decides to learn from you and copies that code.  Or later that code turns into something more than initialization.  It <span style="text-decoration: underline;">will</span> happen.</p>
<p>For #2, typically the customer believes we are outright wrong.  Certainly in some cases we are, but in others we are just not providing the proper tools for the developers to understand the issue.  The best tool for that is what&#8217;s called &#8220;traceback&#8221;.  <a href="http://www.klocwork.com/products/documentation/current/Traceback_information" target="_blank">Traceback</a> provides you clear instructions on the conditions and assignments of any detected defect.  One of my favorite examples is a buffer overflow.  The traceback below shows you the size of the array and where you are exceeding the bounds of that array.</p>
<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2012/03/trace1.jpg"><img class="aligncenter size-full wp-image-1463" title="Traceback" src="http://www.klocwork.com/blog/wp-content/uploads/2012/03/trace1.jpg" alt="" width="291" height="92" /></a></p>
<p>In this example, it says we exceed that bounds by 15 (we are accessing the array from values 0-65).  The obvious question now is where on earth do you come up with 65?  When we expand the traceback, we can see the full details of that calculation.  The traceback proceeds through the details of every expression until we arrive at the right value, in this case 10+10+10+10+10+10+5=65.</p>
<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2012/03/trace2.jpg"><img class="aligncenter size-full wp-image-1464" title="trace2" src="http://www.klocwork.com/blog/wp-content/uploads/2012/03/trace2.jpg" alt="" width="279" height="561" /></a></p>
<p><br class="spacer_" /></p>
<p>False positives may be a way of life but when addressing them it is important to make sure you are not looking at a perceptual false positive.  The traceback tool is helpful in assessing not just perceptual false positives but other identified defects as well.  It will only make your life easier.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2012/03/perceptual-false-positives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Klocwork Insight 9.5 Continues to Roll…</title>
		<link>http://www.klocwork.com/blog/2012/03/klocwork-insight-9-5-continues-to-roll/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=klocwork-insight-9-5-continues-to-roll</link>
		<comments>http://www.klocwork.com/blog/2012/03/klocwork-insight-9-5-continues-to-roll/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 19:53:54 +0000</pubDate>
		<dc:creator>Brendan Harrison</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[cwe]]></category>
		<category><![CDATA[klocwork insight 9.5]]></category>
		<category><![CDATA[on-the-fly analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1451</guid>
		<description><![CDATA[Wow, what a week last week. We&#8217;ve been busy spreading the word about Klocwork Insight 9.5 and all its on-the-fly-analysis goodness since late January and the reaction has been amazing, but last week took the cake. First, Klocwork Insight 9.5 won its first award: the Military Embedded Systems Editor&#8217;s Choice. Here&#8217;s an excerpt from their [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, what a week last week. We&#8217;ve been busy spreading the word about Klocwork Insight 9.5 and all its <a title="On-the-fly Desktop Analysis" href="http://www.klocwork.com/products/insight/continuous-desktop-analysis/">on-the-fly-analysis</a> goodness since late January and the reaction has been amazing, but last week took the cake.</p>
<p>First, Klocwork Insight 9.5 won its first award: the <a title="Military Embedded Systems Editor's Choice" href="http://mil-embedded.com/editors-choice/source-analysis-easy-a-spell-checker/" target="_blank">Military Embedded Systems Editor&#8217;s Choice</a>. Here&#8217;s an excerpt from their write-up:</p>
<blockquote><p><em>Software  developers have enough on their plates without having to spend undue  time analyzing their code. Sure, there is traditional source code analysis, whether done manually or by using techniques such as static or dynamic analysis, but Klocwork’s  Insight 9.5 is intriguing because it strays away from the centralized  batch-processing analysis modus operandi and instead implements  on-the-fly, as-it’s-created code analysis.</em></p>
</blockquote>
<p>Also last week, Klocwork Insight was one of 5 products to be awarded with <a href="http://cwe.mitre.org/news/index.html#20120228a">CWE&#8217;s Official Certificates of CWE Compatibility</a>.  This means our customers can rest assured that our products are &#8220;CWE Compatible&#8221;, based on CWE&#8217;s own criteria. Great news for all our customers who care about creating more secure code!</p>
<p>Klocwork Insight 9.5 was also a finalist for the <a href="http://www.embedded-world.de/en/at-a-glance/supporting_programme/award/winner/" target="_blank">Embedded World Award 2012</a>, losing out in a close fought battle (so I&#8217;m told:) to <a href="http://www.windriver.com" target="_blank">Windriver</a> and <a href="http://www.willert.de/" target="_blank">Willert </a>for their software development tools. Congrats to the winners!</p>
<p>And that&#8217;s just in the the last few weeks since we launched the product.</p>
<p>Speaking of Embedded World, what a great event that was last week. Aside from the vast quantity of Nurnberg sausages we all ate, the sheer size of the event and quality of attendees was top-notch. The whole Klocwork team was run ragged all week hosting a customer event, doing demos at the booth, meeting partners, and just generally getting the word out.</p>
<p>So, good stuff all around for a product that was released barely one month ago!</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">CWE  has awarded its first-ever Official Certificates of CWE Compatibility</div>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2012/03/klocwork-insight-9-5-continues-to-roll/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Answering questions about your code base – Part 1</title>
		<link>http://www.klocwork.com/blog/2012/02/answering-questions-about-your-code-base-part-1/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=answering-questions-about-your-code-base-part-1</link>
		<comments>http://www.klocwork.com/blog/2012/02/answering-questions-about-your-code-base-part-1/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 13:45:32 +0000</pubDate>
		<dc:creator>Patti Murphy</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Software Quality]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[source code analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1444</guid>
		<description><![CDATA[Static analysis captures the current state of your code base and helps you answer key questions about the quality, security and maintainability of your software project. Think Magic 8 Ball with build omniscience and powerful reporting tools. OK, maybe Magic 8 Ball isn&#8217;t a good analogy. Answers to what questions, you ask? One we often [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2012/02/Magic8ball_x.jpg"><img class="alignright size-full wp-image-1445" title="Magic8ball_x" src="http://www.klocwork.com/blog/wp-content/uploads/2012/02/Magic8ball_x.jpg" alt="" width="203" height="203" /></a>Static analysis captures the current state of your code base and helps you answer key questions about the quality, security and maintainability of your software project.</p>
<p>Think Magic 8 Ball with build omniscience and powerful reporting tools. OK, maybe Magic 8 Ball isn&#8217;t a good analogy.</p>
<p>Answers to what questions, you ask? One we often hear from customers is: <strong>Where do I start?</strong></p>
<p>A good place to start is a report that captures the distribution of defect types from your current build.  For example, we recommend that our customers glance over the Top 10 Issues report in our web-based build reporting tool, <a href="http://www.youtube.com/watch?feature=player_embedded&amp;list=PL1A2FCC17F8F213D5&amp;v=G20amVkXw0g" target="_blank">Klocwork Review</a> while indulging in their morning cup of coffee:</p>
<div id="attachment_1447" class="wp-caption aligncenter" style="width: 624px"><a href="http://www.klocwork.com/blog/wp-content/uploads/2012/02/top10-21.png"><img class="size-full wp-image-1447 " title="top10-2" src="http://www.klocwork.com/blog/wp-content/uploads/2012/02/top10-21.png" alt="" width="614" height="505" /></a><p class="wp-caption-text">Magic 8 Ball can&#39;t do this. Here&#39;s a defect distrubtion view of your build.</p></div>
<p>With this build snapshot and your caffeine jolt,  you can quickly identify defects of interest to your organization, such as null pointer dereferences and memory leaks. If you wish, you can set up filters (we call <a href="http://www.klocwork.com/products/documentation/current/Customizing_your_view_of_the_integration_build_analysis" target="_blank">views</a>) to show only these defect types in your report.</p>
<p>Your next step is to get your developers using static analysis on their desktops to prevent the injection of these high-priority defects into the build in the first place.</p>
<p>Once a policy of pre-checkin static analysis usage is put in place, pay attention to new defects injected into the build from that point on. If you see a spike in new defects, then investigate.</p>
<p>The magnitude of that y-axis is not what matters most; it&#8217;s the overall trend that counts.</p>
<p>For my next post, I&#8217;ll take a look at reports that track your cost of ownership and show you what success looks like.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2012/02/answering-questions-about-your-code-base-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Golden rules of AST checker development</title>
		<link>http://www.klocwork.com/blog/2012/01/golden-rules-of-ast-checker-development/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=golden-rules-of-ast-checker-development</link>
		<comments>http://www.klocwork.com/blog/2012/01/golden-rules-of-ast-checker-development/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 14:57:10 +0000</pubDate>
		<dc:creator>Patti Murphy</dc:creator>
				<category><![CDATA[Coding Standards]]></category>
		<category><![CDATA[General Coding]]></category>
		<category><![CDATA[Software Quality]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[coding standards]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[source code analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1427</guid>
		<description><![CDATA[In my previous post, It&#8217;s time to create a custom checker&#8230;, we looked at the considerations involved in deciding which checker to create&#8211;AST or path? In this post, we&#8217;re going to use a custom checker to enforce an internal coding standard that extends the default set of checkers in our source code analysis tool. To [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post, <a href="http://www.klocwork.com/blog/2011/11/its-time-to-create-a-custom-checker-but-what-kind/" target="_blank">It&#8217;s time to create a custom checker&#8230;</a>, we looked at the considerations involved in deciding which checker to create&#8211;AST or path?</p>
<p>In this post, we&#8217;re going to use a custom checker to enforce an internal coding standard that extends the default set of checkers in our source code analysis tool.</p>
<p>To do this, I&#8217;ve called upon Steve Howard, our head of Partner Support in Europe, to get us started with an AST checker to accomplish our goal.</p>
<p>Steve has coached many customers through the checker creation process. In his experience, the appeal of custom checkers lies in their ability  to <a href="http://www.klocwork.com/blog/2011/01/in-standards-we-unite-in-agile-we-diverge/" target="_blank">enforce naming conventions and code constructions across organizations</a>.</p>
<p>The standard we want to enforce is the use of a compound statement block rather than single statements as the body of a <em>for loop</em>. An AST checker is the way to go because detection depends solely on the syntax of the code itself and not runtime behavior.</p>
<p>See the example below:</p>
<table>
</table>
<table cellspacing="5" cellpadding="2">
<tbody>
<tr>
<td><strong>Incorrect:</strong></td>
<td><strong>Correct:</strong></td>
</tr>
<tr>
<td>for( i &#8211; 0; i &lt; 10; i++ )<br />
 doSomething( );</td>
<td>for( i &#8211; 0; i &lt; 10; i++ ) {<br />
 doSomething();<br />
 }</td>
</tr>
</tbody>
</table>
<p>To flag this violation, we need to instruct the checker to find all instances of <em>for loop</em> nodes that contain a <em>Statement </em>node as an immediate descendant.</p>
<p>A tool that shows you a visual representation of the AST for the test case is quite helpful in the checker creation process. Here at Klocwork, we use <a href="http://www.klocwork.com/products/documentation/current/Tutorial_1_-_Introducing_Checker_Studio" target="_blank">Checker Studio</a> to:</p>
<ul>
<li>browse the AST structure of test cases,</li>
<li>identify nodes of interest, and </li>
<li>test XPath-like expressions that identify node types, qualifiers, conditions and variables to traverse the AST and flag the defect.</li>
</ul>
<p><strong>Note</strong>: If we wanted to enforce the compound statement rule in all loops, then we’d need to have one pattern (created using the XPath-like expression) for each possible kind, such as <em>while loops</em> and <em>do while  loops</em>.</p>
<p>Armed with the test case, Checker Studio, and a <a href="http://www.klocwork.com/products/documentation/current/All_about_C/C%2B%2B_KAST_expressions" target="_blank">syntax guide</a>, Steve identified the following expression that flags the infraction:</p>
<p>// ForStmt [not (Stmt::CompoundStmt)]</p>
<p>Here&#8217;s how the test case and expression appear in Checker Studio:</p>
<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2012/01/GoldenRules_Studio2.png"><img class="aligncenter size-full wp-image-1436" title="GoldenRules_Studio" src="http://www.klocwork.com/blog/wp-content/uploads/2012/01/GoldenRules_Studio2.png" alt="" width="623" height="516" /></a></p>
<p><strong>Golden rules</strong></p>
<p>Based on his experience, Steve has a number of golden rules that get you from idea to defect detection faster:</p>
<ul>
<li><strong>Start simple</strong>: Use a simple test case that contains the defect you want to detect and work with one simple pattern at a time. Add more complexity as you go along</li>
<li><strong>Start rough and refine later:</strong> Don&#8217;t worry about false positives at first. In some cases it may even be easier to search for  instances that are OK and then negate the rule at the end</li>
<li><strong>Divide and conquer:</strong> With a more complex checker, work separately on each aspect of the defect you want to detect and then bring it all together at the end for testing in Checker Studio</li>
<li><strong>Watch your levels:</strong> Make the highlighting as relevant as possible for the issue you&#8217;re trying to find. For example, “// ClassType [MemberDecls[*]::MemberDecl]” will highlight classes that match, whereas “// ClassType/MemberDecls[*]::MemberDecl”  will highlight class members that match. The rule is the same, but the focus is different</li>
<li><strong>Weed out false negatives:</strong> Add negative examples (good code) to check for false negatives</li>
</ul>
<p>For more information about our custom AST checkers, watch our <a href="http://www.klocwork.com/resources/video/tag/insight-9.5/static-analysis-custom-checkers/display" target="_blank">Checker Studio video</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2012/01/golden-rules-of-ast-checker-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It’s been a while since our last post, but we’ve been busy…</title>
		<link>http://www.klocwork.com/blog/2012/01/its-been-a-while-since-our-last-post-but-weve-been-busy/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=its-been-a-while-since-our-last-post-but-weve-been-busy</link>
		<comments>http://www.klocwork.com/blog/2012/01/its-been-a-while-since-our-last-post-but-weve-been-busy/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 16:54:31 +0000</pubDate>
		<dc:creator>Gwyn Fisher</dc:creator>
				<category><![CDATA[General Coding]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1430</guid>
		<description><![CDATA[So it&#8217;s that time again, when our team finally gets to sleep for a day or two and get their lives back in order. What am I talking about? Answer: Klocwork Insight 9.5 releases today and boy are we ever happy to see it go live &#8212; we&#8217;re &#8220;out there Jerry&#8221; and yes, of course [...]]]></description>
			<content:encoded><![CDATA[<p>So it&#8217;s that time again, when our team finally gets to sleep for a day or two and get their lives back in order. What am I talking about?</p>
<p>Answer: <a title="Klocwork Insight 9.5" href="http://www.klocwork.com/products/klocwork-insight-95-whats-new/">Klocwork Insight 9.5</a> releases today and boy are we ever happy to see it go live &#8212; we&#8217;re &#8220;out there Jerry&#8221; and yes, of course we&#8217;re loving every minute of it.</p>
<p>This has been a long release, taking significant research and development to bring to fruition, all the while continuing to release more traditional shipments as we went, but finally culminating in a new, game-changing technology for source code analysis. On-the-fly, as-you-type, instant-like-for-reals, call it what you like&#8230; full-on, in-depth C/C++ analysis performed as the developer enters their code, using the &#8220;squiggly line&#8221; usability metaphor created by spell checkers. It&#8217;s one of those &#8220;why would you do it any other way&#8221; moments and we&#8217;re happy to be unique.</p>
<p>Not to be outdone, our web tools team has done amazing stuff with a complete redesign of our Review and Inspect tools, showcasing an awesome look and feel that leverages the toys that come with HTML5 and, amongst many other new capabilities, brings drag/drop pivot report design to the web for on-the-fly metrics and trending analysis that managers and development leads will just eat up.</p>
<p>To our customers, our partners and our friends in the industry, we&#8217;d like to say Welcome to Insight 9.5, hope you enjoy it.</p>
<p><br class="spacer_" /></p>
<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2012/01/kw-insight.png"><img class="aligncenter size-full wp-image-1432" title="kw-insight" src="http://www.klocwork.com/blog/wp-content/uploads/2012/01/kw-insight.png" alt="Klocwork Insight Logo" width="450" height="79" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2012/01/its-been-a-while-since-our-last-post-but-weve-been-busy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>It’s time to create a custom checker, but what kind?</title>
		<link>http://www.klocwork.com/blog/2011/11/its-time-to-create-a-custom-checker-but-what-kind/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=its-time-to-create-a-custom-checker-but-what-kind</link>
		<comments>http://www.klocwork.com/blog/2011/11/its-time-to-create-a-custom-checker-but-what-kind/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 14:56:15 +0000</pubDate>
		<dc:creator>Patti Murphy</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[custom checkers]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1388</guid>
		<description><![CDATA[You&#8217;ve been using source code analysis on your integration build or your desktop, or (ideally) both. And then there&#8217;s &#8220;a situation&#8221;. The situation Either you: Noticed a false negative you want detected, or Need a way to enforce a corporate coding standard, such as the requirement for the use of  a compound statement block rather [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2011/09/checkers.gif"><img class="alignright size-full wp-image-1390" title="checkers" src="http://www.klocwork.com/blog/wp-content/uploads/2011/09/checkers.gif" alt="" width="369" height="254" /></a></p>
<p>You&#8217;ve been using source code analysis on your integration build or your desktop, or (ideally) both. And then there&#8217;s &#8220;a situation&#8221;.</p>
<p><strong>The situation</strong></p>
<p>Either you:</p>
<ul>
<li>Noticed a false negative you want detected, or </li>
<li>Need a way to enforce a corporate coding standard, such as the requirement for the use of  a compound statement block rather than single statements as the body of a loop.</li>
</ul>
<p><strong>Now what?</strong></p>
<p>Time to create a custom checker, that&#8217;s what. But what kind of checker?</p>
<p>Source code analysis involves two families of checkers, those that involve:</p>
<ul>
<li>Abstract Syntax Tree (AST) validation, and </li>
<li>Code path analysis.</li>
</ul>
<p>An AST provides a tree-based structural representation of the source code. An AST checker allows you to pinpoint problematic syntax using XPath or XPath-derived grammar to define the problem you&#8217;re looking for. AST checkers (our version is called Klockwork AST checkers, or KAST for short) don&#8217;t require program execution to run; they detect defects right away on source code.</p>
<p>Code path analysis, on the other hand, targets defects related to value tracking at program execution time. Instead of style violations, you&#8217;d use a path checker to answer questions such as:</p>
<ul>
<li>Is this newly-created object released before all aliases to it are removed from scope?</li>
<li>Is this data object ever range-checked before being passed to an OS function?</li>
<li>Is this string checked for special characters before being submitted as an SQL query?</li>
</ul>
<p>To create a path checker, you don&#8217;t need to know how data is tracked by the checker. What you do need to know are the function types and values you want to track for the analysis starting point and the analysis end point where the defect (or event) is recognized and reported.</p>
<p><strong>Which checker when?</strong></p>
<p>Create an AST checker when the problem you want to detect:</p>
<ul>
<li>is a local defect</li>
<li>does not involve program execution</li>
<li>has to do with the way the program was written</li>
<li>does not involve tracking a value</li>
<li>does not involve a path</li>
</ul>
<p>Create a path checker when the problem you want to detect:</p>
<ul>
<li>involves tracking a value</li>
<li>has a starting point (where the analysis starts) and end point (where the defect is detected)</li>
<li>involves program execution</li>
</ul>
<p>Stay tuned for the next post in this series on best practices for AST checker creation.</p>
<p>For more information, see <a href="http://www.klocwork.com/products/documentation/current/Writing_custom_checkers_with_Klocwork_Extensibility" target="_blank">Writing custom checkers with Klocwork Extensibility</a> or check out our member discussions in the <a href="http://developer.klocwork.com/community/forums/customization/cc-checkers" target="_blank">C/C++ custom checkers forum</a>.</p>
<p><em>&#8211;With files from CTO Gwyn Fisher</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/11/its-time-to-create-a-custom-checker-but-what-kind/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Security Issues with Apple iOS?</title>
		<link>http://www.klocwork.com/blog/2011/11/security-issues-with-apple-ios/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=security-issues-with-apple-ios</link>
		<comments>http://www.klocwork.com/blog/2011/11/security-issues-with-apple-ios/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 18:01:04 +0000</pubDate>
		<dc:creator>Todd Landry</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[software security]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1419</guid>
		<description><![CDATA[As a pretty avid Apple user (2 iPhones, 1 iPad2, iMac, iPod Touch, MacBook Pro, etc.), and the fact that I work in the business of software quality and security, I must admit that this article caught my attention. The article outlines how a well-known security researcher, who focuses on Apple, has found a software [...]]]></description>
			<content:encoded><![CDATA[<p>As a pretty avid Apple user (2 iPhones, 1 iPad2, iMac, iPod Touch, MacBook Pro, etc.), and the fact that I work in the business of software quality and security, I must admit that this <a href="http://ca.reuters.com/article/technologyNews/idCATRE7A708Q20111108">article</a> caught my attention. The article outlines how a well-known security researcher, who focuses on Apple, has found a software flaw in the iPhone and iPad, which could allow hackers to build malicious apps.What makes this even more scary is that the Apple Store may not catch these malicious apps.<a href="http://www.klocwork.com/blog/wp-content/uploads/2011/11/download.jpeg"><img class="alignright size-full wp-image-1422" title="download" src="http://www.klocwork.com/blog/wp-content/uploads/2011/11/download.jpeg" alt="" width="254" height="198" /></a></p>
<p>To add another twist to this story, the researcher in question has been ejected from participating in Apple&#8217;s developer programs. Read about that <a href="http://news.cnet.com/8301-27076_3-57320190-248/apple-boots-security-guru-who-exposed-iphone-exploit/">here</a>.</p>
<p>Are we now getting to the point where hackers are going to start trying more aggressively to exploit Apple products? In a <a href="http://news.cnet.com/8301-27080_3-10444561-245.html">survey</a> done in 2010, over 50% of respondents thought Windows was either &#8220;very&#8221; or &#8220;extremely&#8221; vulnerable compared to only 20% for Apple. I wonder if that has changed? More importantly, do I need to start worrying about my daughter downloading the Archie comic app from the App Store?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/11/security-issues-with-apple-ios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What’s the Right Iteration Length?</title>
		<link>http://www.klocwork.com/blog/2011/11/whats-the-right-iteration-length/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=whats-the-right-iteration-length</link>
		<comments>http://www.klocwork.com/blog/2011/11/whats-the-right-iteration-length/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 13:00:44 +0000</pubDate>
		<dc:creator>Todd Landry</dc:creator>
				<category><![CDATA[Agile Development]]></category>
		<category><![CDATA[General Coding]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1410</guid>
		<description><![CDATA[The question of &#8220;what&#8217;s the right iteration length&#8221; may not be as interesting as any of the questions found here (gum really doesn&#8217;t stay in you for 7 years. Who knew?), but it is a common question from organizations moving to agile development. You can certainly get a lot of different opinions on this from [...]]]></description>
			<content:encoded><![CDATA[<p>The question of &#8220;what&#8217;s the right iteration length&#8221; may not be as interesting as any of the questions found <a href="http://www.telegraph.co.uk/news/newstopics/howaboutthat/4696372/Greatest-101-questions-of-all-time-1-20.html">here</a> (gum really doesn&#8217;t stay in you for 7 years. Who knew?), but it is a common question from organizations moving to agile development. You can certainly get a lot of different <a href="http://www.mountaingoatsoftware.com/articles/30-selecting-the-right-iteration-length-for-your-software-development-process">opinions</a> on this from a Google search, but since you&#8217;re reading this now, I&#8217;ll give you mine, based on personal experience.</p>
<p>A number of years ago, one of the projects I was PM on decided to try out Scrum. I had attended some Product Owner <a href="http://www.mountaingoatsoftware.com/certified-product-owner-training">training</a>, and our soon-to-be Scrum Master had been on some training as well, but we were very green and decided to approach things with a &#8220;let&#8217;s see what works best for us&#8221; mentality. At the time, we thought the best way for us to get immersed and efficient with Scrum was lots of repetitions. We went with 1-week iterations, thinking that by having a rapid and regular cycle of sprint planning meetings, demo meetings, retrospective meetings, etc. we would learn more quickly the &#8220;proper&#8221; way of doing development with Scrum.</p>
<p>We certainly did learn a lot during our first 3 or 4 sprints, mainly that having this regular weekly cycle of meetings was just too much overhead, and the actual amount of value produced at the end of each sprint was too little. Next on our list, the 2-week sprint.<a href="http://www.klocwork.com/blog/wp-content/uploads/2011/10/monkey.jpeg"><img class="alignright size-full wp-image-1411" title="monkey" src="http://www.klocwork.com/blog/wp-content/uploads/2011/10/monkey.jpeg" alt="" width="259" height="194" /></a></p>
<p>The 2-week sprints worked great for us, and we saw the differences from the 1-week sprints almost immediately. We were producing what we thought was a good amount of value from each sprint, but with a better and more balanced level of overhead. We hit our groove and established a good cadence with these 2-week sprints, and from the looks of the burn-down chart, we were becoming a more efficient team with every sprint.</p>
<p>The team definitely was cruising and enjoying the pace, but the holiday season snuck up on us and we thought that it might make sense to make some adjustments to deal with the vacation time various team members would be taking.</p>
<p>After collecting everyone&#8217;s vacation schedule, we were able to determine a start and finish date for our &#8220;holiday sprint&#8221; that would essentially start when everyone was still in the office, and finish when everyone returned from their vacation. Call it either luck or good management, but we had planned a 4-week sprint. I won&#8217;t go through all the gory details, but let&#8217;s just say that upon reflection, the 4-week iteration just felt wrong.</p>
<p>The initial planning session felt harder to estimate the amount of work we could do. The cadence we developed didn&#8217;t show itself, and it really felt like we never gained any momentum during the 4 weeks. Now I&#8217;m sure that the whole holiday season thing played a role in this, but it was our least effective iteration ever, and by a lot. We never tried the 4-week iteration again.</p>
<p>The bottom line is that all teams are different and need to go with the iteration length that feels right for them. For us, the 2-week one was best.</p>
<p>For the record, I have always wondered if the 7-year rule for chewing gum was true. Glad to hear it isn&#8217;t.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/11/whats-the-right-iteration-length/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiler configuration</title>
		<link>http://www.klocwork.com/blog/2011/10/compiler-configuration/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=compiler-configuration</link>
		<comments>http://www.klocwork.com/blog/2011/10/compiler-configuration/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 13:32:55 +0000</pubDate>
		<dc:creator>Alen Zukich</dc:creator>
				<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[gcc]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1403</guid>
		<description><![CDATA[Compiler configuration is a problem with static analysis tools.  In the past, a static analysis (or source code analysis) tool simply worked by pointing it at the source code and hitting &#8220;go&#8221;.  Now it is very different.  Without a complete understanding of the software build, including the compiler specifics, you will get inaccurate results. Under [...]]]></description>
			<content:encoded><![CDATA[<p>Compiler configuration is a problem with static analysis tools.  In the past, a static analysis (or source code analysis) tool simply worked by pointing it at the source code and hitting &#8220;go&#8221;.  Now it is very different.  Without a complete understanding of the software build, including the compiler specifics, you will get inaccurate results.</p>
<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2011/10/a12012.gif"><img class="alignleft size-full wp-image-1406" title="Compiler toolchain" src="http://www.klocwork.com/blog/wp-content/uploads/2011/10/a12012.gif" alt="" width="280" height="391" /></a>Under the covers, do you really know what is happening with your compiler?  Not usually.  You make changes to your code, call your compiler or build command to compile your code, and then fix the issues.  Rinse and repeat.</p>
<p>But what is really important for static analysis tools, is that the compiler contains some crucial information to successfully compile your code.  Namely, the internal compiler includes and defines.  Static analysis tools must generate this data, otherwise they won&#8217;t know where the system includes and defines are coming from for your specific compiler.  Hence, the static analysis results are about as accurate as the weather man&#8217;s weekly prediction.</p>
<p>Luckily most compilers have a way to capture this.  For example to find out the defines and includes from gcc:</p>
<pre><code>gcc -E -dM dummy.c

gcc -E -Wp,-v dummy.c
</code></pre>
<p>Where dummy.c is just an empty file.  This will give you a dump of all the defines and includes, respectively.  Now, when static analysis tools build their data they have a mapping of the proper defines and includes for your specific compiler and everyone is happy.</p>
<p>In the past, it seemed like a good idea to make compiler configuration extensible.  This meant that static analysis tools could support any compiler if you didn&#8217;t mind taking the time to build that support.  It wasn&#8217;t usually very complex but it could be prone to errors.  Instead, it makes more sense to just provide the support right out of the box, so taking the words from the late Steve Jobs: &#8220;<em>it just works</em>&#8220;.  As long as static analysis tools have an extensible interface, these tools should be able to support new and obscure compilers very quickly.  Make sure your static analysis vendor has support for your specific compiler that you use, and if they don&#8217;t they better turn that around in a snap.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/10/compiler-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is Pure Agile Always an Option?</title>
		<link>http://www.klocwork.com/blog/2011/10/is-pure-agile-always-an-option/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=is-pure-agile-always-an-option</link>
		<comments>http://www.klocwork.com/blog/2011/10/is-pure-agile-always-an-option/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 13:50:27 +0000</pubDate>
		<dc:creator>Todd Landry</dc:creator>
				<category><![CDATA[Agile Development]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[General Coding]]></category>
		<category><![CDATA[General Industry]]></category>
		<category><![CDATA[Medical Device Software]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[medical device software]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1397</guid>
		<description><![CDATA[Over the past few years I’ve talked to a number of customers in the embedded software and medical devices industries, and I continue to see a significant number of these organizations either moving to, or planning on moving to agile development processes. With all of the inherent challenges for agile in these organizations such as [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past few years I’ve talked to a number of customers in the embedded software and medical devices industries, and I continue to see a significant number of these organizations either moving to, or planning on moving to agile development processes.</p>
<p>With all of the inherent challenges for agile in these organizations such as standards/regulatory compliance, hardware changes and integration, security issues, etc. I must say that I’m a little shocked that customers are moving away from their current processes towards something like agile. Add to this the fact that the Agile Manifesto specifically states “Working software over comprehensive documentation” and it doesn’t exactly sound like agile is a great fit for embedded systems in general, let alone medical device.</p>
<p>Now, don’t get me wrong, I am a huge proponent of agile, and I certainly realize that there are many pros for moving to agile, and these have been well <a href="http://www.objectmentor.com/omSolutions/agile_why.html">documented</a>, but I have to wonder just how agile are these specific industries going?  I would bet that most (all?) of these organizations are adopting some of the key fundamentals of agile, but to say they are going “all in” would be a bit of a stretch.</p>
<p><br class="spacer_" /></p>
<div id="attachment_1400" class="wp-caption alignright" style="width: 310px"><a href="http://www.klocwork.com/blog/wp-content/uploads/2011/10/whales-10.jpg"><img class="size-medium wp-image-1400" title="whales-10" src="http://www.klocwork.com/blog/wp-content/uploads/2011/10/whales-10-300x193.jpg" alt="" width="300" height="193" /></a><p class="wp-caption-text">Even industries heavy on process (because of regulatory requirements) are taking the leap into agile. How agile are they?</p></div>
<p>Looking at the <a href="http://agilemanifesto.org/">manifesto</a> a little closer, some of the principles are fairly generic and feel more like common sense than anything revolutionary, so they probably apply to any industry. There are a few principles however that are fairly easy to imagine in these industries, such as:</p>
<ul>
<li> getting all stakeholders involved in defining requirements (Principle #4), or </li>
<li>embracing more face-to-face conversations (Principle #6), and </li>
<li>simplicity, or minimizing the amount of work not done (Principle #10). </li>
</ul>
<p>But do people really think that Principles #1 (early and often delivery of software), and #2 (welcome changing requirements) really apply to the embedded or medical devices industries? Personally I don’t see it.</p>
<p>So what do you think? Are the embedded software or medical devices industries capable of going full out Agile?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/10/is-pure-agile-always-an-option/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Microsoft banned function list</title>
		<link>http://www.klocwork.com/blog/2011/09/microsoft-banned-function-list/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=microsoft-banned-function-list</link>
		<comments>http://www.klocwork.com/blog/2011/09/microsoft-banned-function-list/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 19:58:37 +0000</pubDate>
		<dc:creator>Alen Zukich</dc:creator>
				<category><![CDATA[Software Security]]></category>
		<category><![CDATA[banned functions]]></category>
		<category><![CDATA[buffer overflow]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[source code analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1389</guid>
		<description><![CDATA[We have blogged before about software security guidelines, but there is one we haven&#8217;t discussed.  Several years ago Microsoft published the &#8220;Security Development Lifecycle (SDL) Banned Function Calls&#8221; list.  These banned functions can be a good way to remove a significant number of potential code vulnerabilities from C and C++ code.  They provide recommendations on [...]]]></description>
			<content:encoded><![CDATA[<p>We have blogged before about <a href="http://www.klocwork.com/blog/2010/06/the-alphabet-soup-of-software-security-guidelines/">software security guidelines</a>, but there is one we haven&#8217;t discussed.  Several years ago Microsoft published the &#8220;<a href="http://msdn.microsoft.com/en-us/library/bb288454.aspx" target="_blank">Security Development Lifecycle (SDL) Banned Function Calls</a>&#8221; list.  These banned functions can be a good way to remove a significant number of potential code vulnerabilities from C and C++ code.  They provide recommendations on better or safer functions to use with the caveat that even these &#8220;safer&#8221; function should be used with care.</p>
<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2011/09/banned.jpg"><img class="alignleft size-full wp-image-1391" title="banned" src="http://www.klocwork.com/blog/wp-content/uploads/2011/09/banned.jpg" alt="" width="204" height="204" /></a>You can use the <a href="http://www.microsoft.com/download/en/details.aspx?id=24817">banned.h</a> file to identify and obtain deprecation warnings or, even better, use this as part of your source code analysis.  Leveraging these warning as part of your source code analysis solution means you have better ways to filter and manage the solution as opposed to a dump of potentially thousands of warnings.  Add that into your code review tool and you have some good discussion points for your peer code reviews.</p>
<p>Like any security guideline, the question becomes how useful are these?  There is no question that these banned functions are <a href="http://sigttou.com/ban-programmers-not-functions" target="_blank">debatable</a>.  The complaint that I hear the most is that &#8220;n&#8221; functions can be used safely so they should not be part of the list.  But you can still get yourself in a whole heap of trouble with these functions as well.  Take this example from Micheal Howard&#8217;s blog:  <a href="http://blogs.msdn.com/b/michael_howard/archive/2004/10/29/249713.aspx" target="_blank">Buffer Overflow in Apache 1.3.xx fixed on Bugtraq &#8211; the evils of strncpy and strncat!</a>.</p>
<p>I believe there is merit in identifying these functions so you can ask yourself if you&#8217;re using them securely.  For more information and training on the Microsoft SDL you can look at the course &#8220;<a href="http://developer.klocwork.com/klocwork-university/security-innovation/microsoft-sdl" target="_blank">Intro to the Microsoft Security Development Lifecycle</a>&#8221; on our web page.</p>
<p>Is anyone out there using the Microsoft banned function list religiously?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/09/microsoft-banned-function-list/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Secure Coding eLearning Resource</title>
		<link>http://www.klocwork.com/blog/2011/09/secure-coding-elearning-resource/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=secure-coding-elearning-resource</link>
		<comments>http://www.klocwork.com/blog/2011/09/secure-coding-elearning-resource/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 14:49:13 +0000</pubDate>
		<dc:creator>Brendan Harrison</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[elearning]]></category>
		<category><![CDATA[Microsoft Security Development Lifecycle]]></category>
		<category><![CDATA[OWASP]]></category>
		<category><![CDATA[software security]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1382</guid>
		<description><![CDATA[One of the common challenges we hear from customers regarding their software security assurance programs is developer education. Sure, there are many great tools out there that can help with security, but when it comes down to it, if you&#8217;re going to truly build a culture of secure software (and not just audit your system [...]]]></description>
			<content:encoded><![CDATA[<p>One of the common challenges we hear from customers regarding their <a title="Software Security Assurance" href="http://www.klocwork.com/solutions/software-security-assurance/" target="_blank">software security assurance</a> programs is developer education. Sure, there are many great tools out there that can help with security, but when it comes down to it, if you&#8217;re going to truly build a culture of secure software (and not just audit your system now and then), your development team needs to be well versed on key security concepts, defensive coding principles, common attack vectors, not to mention the ins and outs of specific coding vulnerabilities like <a title="Buffer Overflow" href="http://www.klocwork.com/products/documentation/current/Checkers:ABR" target="_blank">buffer overflows</a>.</p>
<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2011/09/secure-coding-ccxx1.png"><img class="alignright size-full wp-image-1384" title="secure-coding-ccxx" src="http://www.klocwork.com/blog/wp-content/uploads/2011/09/secure-coding-ccxx1.png" alt="Secure Coding for C/C++ Course" width="697" height="560" /></a></p>
<p>Well, we agree. That&#8217;s why we&#8217;ve partnered with our friends at <a title="Security Innovation" href="http://www.securityinnovation.com/" target="_blank">Security Innovation</a> to make some of their developer eLearning courses available for free on the new, revamped <a title="Klocwork University" href="http://developer.klocwork.com/klocwork-university" target="_blank">Klocwork University</a>. I encourage you to check out the <a title="Secure Coding for C/C++" href="http://developer.klocwork.com/klocwork-university/security-innovation/secure-coding" target="_blank">Secure Coding for C/C++</a> course &#8211; it&#8217;s approx 60 minutes in length, features interactive material, and is a great introductory course into many of the key concepts required to build secure software. We also have a course on Microsoft&#8217;s Secure SDL and the OWASP Top 10. Check it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/09/secure-coding-elearning-resource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Klocwork University consolidates learning resources into a single roster</title>
		<link>http://www.klocwork.com/blog/2011/09/klocwork-university-consolidates-learning-resources-into-a-single-roster/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=klocwork-university-consolidates-learning-resources-into-a-single-roster</link>
		<comments>http://www.klocwork.com/blog/2011/09/klocwork-university-consolidates-learning-resources-into-a-single-roster/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 16:42:48 +0000</pubDate>
		<dc:creator>Patti Murphy</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[e-learning]]></category>
		<category><![CDATA[Klocwork Developer Network]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1368</guid>
		<description><![CDATA[Klocwork Developer Network presents Klocwork University, which consolidates all our online learning resources onto a single page. Klocwork University is your one stop for self-paced online learning and how-tos about: Setting up and using our static analysis tools on your desktop or integration build The latest trends in software security Agile coding practices and how [...]]]></description>
			<content:encoded><![CDATA[<p>Klocwork Developer Network presents <a href="http://developer.klocwork.com/klocwork-university/" target="_blank">Klocwork University</a>, which consolidates all our online learning resources onto a single page.</p>
<p><a href="http://developer.klocwork.com/klocwork-university/"><img class="alignright size-full wp-image-1379" title="KlocU3" src="http://www.klocwork.com/blog/wp-content/uploads/2011/09/KlocU31.png" alt="" width="381" height="207" /></a></p>
<p>Klocwork University is your one stop for self-paced online learning and how-tos about:</p>
<ul>
<li>Setting up and using our static analysis tools on your desktop or integration build </li>
<li>The latest trends in software security</li>
<li>Agile coding practices and how they intersect with static analysis</li>
<li>Klocwork product overviews</li>
</ul>
<p>At Klocwork University you&#8217;ll see helpful descriptions of:</p>
<ul>
<li> In-house and partner-generated e-learning courses</li>
<li>Video how-tos</li>
<li>Webinars</li>
</ul>
<p>After you  browse our offerings on the Klocwork University page, click your  selection and access your resource. If you&#8217;re not already logged in to  the Klocwork Developer Network, you&#8217;ll be prompted to log in or register  to use these free resources.</p>
<p>This change  pulls the course content descriptions from behind the login wall to  provide a searchable list for members and non-members alike.</p>
<p>At Klocwork  University, you get the information up front and you can schedule your  pub breaks when and where you want. Join today. There&#8217;s no free beer  though.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/09/klocwork-university-consolidates-learning-resources-into-a-single-roster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Squeezing max from the  ‘try/finally’ blocks</title>
		<link>http://www.klocwork.com/blog/2011/08/squeezing-max-from-the-tryfinally-blocks/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=squeezing-max-from-the-tryfinally-blocks</link>
		<comments>http://www.klocwork.com/blog/2011/08/squeezing-max-from-the-tryfinally-blocks/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 15:22:31 +0000</pubDate>
		<dc:creator>Mikhail Ksenzov</dc:creator>
				<category><![CDATA[General Coding]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1362</guid>
		<description><![CDATA[I often hear that closing resources properly is way too verbose in Java, especially considering that resource freeing methods such as ‘close()&#8217; are often throwing some type of an exception. However, if you handle resources properly it might turn out to be less of a burden than one might think. Let&#8217;s start with the following [...]]]></description>
			<content:encoded><![CDATA[<p>I often hear that closing resources properly is way too verbose in Java, especially considering that resource freeing methods such as ‘close()&#8217; are often throwing some type of an <a href="http://download.oracle.com/javase/1.5.0/docs/api/java/io/Closeable.html#close%28%29">exception</a>. However, if you handle resources properly it might turn out to be less of a burden than one might think. Let&#8217;s start with the following snippet, where I use an SQL driver to retrieve the list of “codes” matching the given “id”:</p>
<pre><span style="font-size: small;">09 List&lt;String&gt; requestCodes(String dbUrl, String id) {
10   List&lt;String&gt; result = <strong>new</strong> ArrayList&lt;String&gt;();
11   <strong>try</strong> {
12     Connection conn = DriverManager.getConnection(dbUrl);
13     PreparedStatement stmt = conn.prepareStatement("SELECT * FROM customers WHERE id = ?");
14     stmt.setString(1, id);
15     ResultSet rs = stmt.executeQuery();
16     <strong>while</strong> (rs.next()) {
17       result.add(rs.getString("code"));
18     }
19   } <strong>catch</strong> (SQLException e) {
20      e.printStackTrace();
21   }
22   <strong>return</strong> result;
23 }</span></pre>
<p>The problem with the code above is that it allocates SQL server resources but fails to properly release them. More specifically:</p>
<ul>
<li>Line 12: SQL connection &#8216;conn&#8217; is not closed on exit. </li>
<li>Line 13: SQL object &#8216;stmt&#8217; is not closed on exit. </li>
<li>Line 16: SQL object &#8216;rs&#8217; is not closed on exit. </li>
</ul>
<p>The next snippet illustrates how one can fix the defects listed above:</p>
<pre><span style="font-size: small;">09 List&lt;String&gt; requestCodes(String dbUrl, String id) {
10   List&lt;String&gt; result = new ArrayList&lt;String&gt;();
11   Connection conn = <strong>null</strong>;
12   PreparedStatement stmt = <strong>null</strong>;
13   ResultSet rs = <strong>null</strong>;
14   <strong>try</strong> {
15     conn = DriverManager.getConnection(dbUrl);
16     stmt = conn.prepareStatement("SELECT * FROM customers WHERE id = ?");
17     stmt.setString(1, id);
18     rs = stmt.executeQuery();
19     <strong>while</strong> (rs.next()) {
20       result.add(rs.getString("code"));
21     }
22   } <strong>catch</strong> (SQLException e) {
23     e.printStackTrace();
24   } <strong>finally</strong> {
25     <strong>if</strong> (rs != <strong>null</strong>) {
26       <strong>try</strong> {
27         rs.close();          // close() throws an exception...
28       } <strong>catch</strong> (SQLException e) {
29         e.printStackTrace(); // ...have to catch it to free 'stmt'
30       }
31     }
32     <strong>if</strong> (stmt != <strong>null</strong>) {
33       <strong>try</strong> {
34         stmt.close();        // again, close() throws an exception...
35       } <strong>catch</strong> (SQLException ignore) {
36         e.printStackTrace(); // ...have to catch it to free 'conn'
37       }
38     }
39     <strong>if</strong> (conn != <strong>null</strong>) {
30       <strong>try</strong> {
41         conn.close();
42       } <strong>catch</strong> (SQLException ignore) {
43         e.printStackTrace();
44       }
45     }
46   }
47   <strong>return</strong> result;
48 }</span></pre>
<p><span style="font-size: small;">T</span>he code above is correct but extremely verbose. However, it can be improved without sacrifices in semantics&#8230;</p>
<p><strong>Tip #1</strong>: It is better to allocate a resource before the &#8216;try/finally&#8217; block, not inside it. Let&#8217;s start with the following code:</p>
<pre><span style="font-size: small;">Connection conn = <strong>null</strong>;<strong>
try</strong> {
  conn = DriverManager.getConnection(dbUrl);
  // use conn
} <strong>finally</strong> {<strong>
  if</strong> (conn != <strong>null</strong>) {
    conn.close();
  }
}</span>
</pre>
<p>can be rewritten as:</p>
<pre><span style="font-size: small;">Connection conn = DriverManager.getConnection(dbUrl);<strong>
try</strong> {
  // use conn
} <strong>finally</strong> {
  conn.close();
}</span></pre>
<p><strong>Tip #2</strong>: Use nested &#8216;try/finally&#8217; blocks if you allocate a sequence of resources. Let’s start with a snippet:</p>
<pre><span style="font-size: small;"><strong>try</strong> {
  Connection conn = DriverManager.getConnection(dbUrl);
  PreparedStatement stmt = conn.prepareStatement("SELECT * FROM customers WHERE id = ?");<strong>
  try</strong> {
    // use conn
    // use stmt
  } <strong>finally</strong> {<strong>
    try</strong> {
      conn.close();
    } <strong>catch</strong> (SQLException e) {
      e.printStackTrace();
    }
<strong>    try</strong> {
       stmt.close();
    } <strong>catch</strong> (SQLException e) {
      e.printStackTrace();
    }
  }
} <strong>catch</strong> (SQLException e) {
  e.printStackTrace();
}</span></pre>
<p>How many problems have you noticed in the snippet above? I found three:</p>
<ul>
<li>Allocation of resource &#8216;stmt&#8217; can throw an exception before we enter the outer &#8216;try/catch/finally&#8217;. If happens &#8216;conn&#8217; will never be freed.</li>
<li>We duplicate code for the SQLException handling. We were lucky to have only one line of code replicated, but it in general cases exception handling can be a bit more involved that we see here&#8230;</li>
<li>The order of resource allocation does not match the order of deallocation: here the order of deallocation should be reversed to be correct.</li>
</ul>
<p>The only robust way to handle resource allocation/deallocation and to address the issues listed above is to use nested try/finally blocks:</p>
<pre><span style="font-size: small;"><strong>try</strong> {
  Connection conn = DriverManager.getConnection(dbUrl);
<strong>  try</strong> {
    // use conn
    PreparedStatement stmt = conn.prepareStatement("SELECT * FROM customers WHERE id = ?");<strong>
    try</strong> {<strong>
</strong>      // use stmt
    } <strong>finally</strong> {
      stmt.close();
    }
  } <strong>finally</strong> {
    conn.close();
  }
} <strong>catch</strong> (SQLException e) {
  e.printStackTrace();
}</span>
</pre>
<p>Let’s apply tips #1 and #2 to our original method and fix the resource leaks on lines 12, 13, 16:</p>
<pre><span style="font-size: small;">09 List&lt;String&gt; requestCodes(String dbUrl, String id) {
10   List&lt;String&gt; result = new ArrayList&lt;String&gt;();
11   <strong>try</strong> {
12     Connection conn = DriverManager.getConnection(dbUrl);
13     <strong>try</strong> {
14       PreparedStatement stmt = conn.prepareStatement("SELECT * FROM customers WHERE id = ?");
15       <strong>try</strong> {
16         stmt.setString(1, id);
17         ResultSet rs = stmt.executeQuery();
18         <strong>try</strong> {
19           <strong>while</strong> (rs.next()) {
20             result.add(rs.getString("code"));
21           }
22         } <strong>finally</strong> {
23           rs.close();
24         }
25       } <strong>finally</strong> {
26          stmt.close();
27       }
28     } <strong>finally</strong> {
29       conn.close();
30     }
31   } <strong>catch</strong> (SQLException e) {
32     e.printStackTrace();
33   }
34   <strong>return</strong> result;
35 }</span>
</pre>
<p>This is way shorter than the original solution!</p>
<p><strong>Tip #3</strong>: If after applying tip #2 you feel that all your code drifted way too close to the right page margin it means that you probably have too much nested &#8216;try/finally&#8217; blocks and that is time to check if you actually want to have all the resources allocated at the same time. Chances are that you do not need them all; otherwise use the <a href="http://c2.com/cgi/wiki?ExtractMethod">Extract Method</a> refactoring pattern to move out some of the resource access logic.</p>
<p><strong>Tip #4</strong>: Know specific behavior of resources you are dealing with. While tips #1 &#8211; #3 provide a robust and compact approach for dealing with resource allocation/deallocation <em>in general</em>, in certain cases you can make code even more compact. In our example: <a href="http://download.oracle.com/javase/6/docs/api/java/sql/Statement.html#close%28%29">Statement.close()</a> closes its current ResultSet object if one exists. Likewise <a href="http://download.oracle.com/javase/6/docs/api/java/sql/Connection.html#close%28%29">Connections.close()</a> releases JDBC resources. It means that if you deal specifically with JDBC it would be sufficient to close the ‘parent’ resource to be sure that all ‘subresources’ will be properly released:</p>
<pre><span style="font-size: small;">09 List&lt;String&gt; requestCodes(String dbUrl, String id) {
10   List&lt;String&gt; result = new ArrayList&lt;String&gt;();
11   <strong>try</strong> {
12     Connection conn = DriverManager.getConnection(dbUrl);
13     <strong>try</strong> {
14       PreparedStatement stmt = conn.prepareStatement("SELECT * FROM customers WHERE id = ?");
15       stmt.setString(1, id);
16       ResultSet rs = stmt.executeQuery();
17       <strong>while</strong> (rs.next()) {
18         result.add(rs.getString("code"));
19       }
20     } <strong>finally</strong> {
21       conn.close();
22     }
23   } <strong>catch</strong> (SQLException e) {
24     e.printStackTrace();
25   }
26   <strong>return</strong> result;
27 }</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/08/squeezing-max-from-the-tryfinally-blocks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Importance of MISRA</title>
		<link>http://www.klocwork.com/blog/2011/07/importance-of-misra/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=importance-of-misra</link>
		<comments>http://www.klocwork.com/blog/2011/07/importance-of-misra/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 12:58:42 +0000</pubDate>
		<dc:creator>Alen Zukich</dc:creator>
				<category><![CDATA[Coding Standards]]></category>
		<category><![CDATA[c99]]></category>
		<category><![CDATA[MISRA]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1338</guid>
		<description><![CDATA[Recently I was at our European partner advisory board.  This is a session where we all get together and talk about the current market, the upcoming release and anything else to help our partners be more successful.  The most valuable sessions for myself is hearing from the partners on what works and what doesn&#8217;t.  This [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2011/06/misralogo1.gif"><img class="alignleft size-full wp-image-1341" title="misralogo" src="http://www.klocwork.com/blog/wp-content/uploads/2011/06/misralogo1.gif" alt="" width="204" height="166" /></a>Recently I was at our European partner advisory board.  This is a session where we all get together and talk about the current market, the upcoming release and anything else to help our partners be more successful.  The most valuable sessions for myself is hearing from the partners on what works and what doesn&#8217;t.  This ranges from commercial issues to technical issues with the product.</p>
<p><br class="spacer_" /></p>
<p>One very clear message from all the partners was that our MISRA support was a huge plus.  Here in North America we have seen small pockets of adoption, but in Europe and even Asia it used quite a bit.  As we have mentioned in the <a href="http://www.klocwork.com/blog/2010/03/misra-more-irrelevant-software-requirements-again/" target="_blank">past</a>, it is not only automotive organization but all levels of business.</p>
<p><br class="spacer_" /></p>
<p>Soon MISRA C 2011 will be released.  Look forward to seeing all the changes especially with the added support of <a href="http://en.wikipedia.org/wiki/C99" target="_blank">C99</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/07/importance-of-misra/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Electronic imports contain security threats</title>
		<link>http://www.klocwork.com/blog/2011/07/electronic-imports-contain-security-threats/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=electronic-imports-contain-security-threats</link>
		<comments>http://www.klocwork.com/blog/2011/07/electronic-imports-contain-security-threats/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 17:29:26 +0000</pubDate>
		<dc:creator>Alen Zukich</dc:creator>
				<category><![CDATA[Software Security]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[software security]]></category>
		<category><![CDATA[Static Analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1354</guid>
		<description><![CDATA[I read an interesting post on electronic imports that could contain security threats.  I can only speak from the software perspective, but I can say that most customers I’ve dealt with usually integrate some sort of software security audit process with any 3rd-party integrator and from my experience that means adopting static analysis.  How many [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2011/07/computer-security.jpg"><img class="alignleft size-full wp-image-1356" title="computer-security" src="http://www.klocwork.com/blog/wp-content/uploads/2011/07/computer-security.jpg" alt="" width="196" height="258" /></a>I read an interesting <a href="http://www.reuters.com/article/2011/07/11/cybersecurity-electronics-idUSN1E76A0SF20110711" target="_blank">post</a> on electronic imports that could contain security threats.  I can only speak from the software perspective, but I can say that most customers I’ve dealt with usually integrate some sort of software security audit process with any 3<sup>rd</sup>-party integrator and from my experience that means adopting static analysis.  How many organizations are there that haven’t jumped on board with static analysis?  Probably more than I can count.</p>
<p>It would be very interesting to hear of some of the Armed Services and Intelligence cyber threats that the government has not publically disclosed.  That might be an eye opener.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/07/electronic-imports-contain-security-threats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>He crossed the line–testing to development</title>
		<link>http://www.klocwork.com/blog/2011/07/he-crossed-the-line-testing-to-development/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=he-crossed-the-line-testing-to-development</link>
		<comments>http://www.klocwork.com/blog/2011/07/he-crossed-the-line-testing-to-development/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 13:21:01 +0000</pubDate>
		<dc:creator>Patti Murphy</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[Software Career]]></category>
		<category><![CDATA[Software Testing]]></category>
		<category><![CDATA[testers and developers can get along]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[vampires]]></category>
		<category><![CDATA[werewolves]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1349</guid>
		<description><![CDATA[Instead of fomenting dissent (that barely exists) in a brazen attempt to boost readership, I&#8217;m changing tactics to look at ways in which testing and development are complementary, beyond their common goal of releasing quality software products. What can I say? After my previous post, How developers drive testers nuts–let’s count the ways, I&#8217;m clearly getting [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_1353" class="wp-caption alignright" style="width: 489px"><a href="http://www.klocwork.com/blog/wp-content/uploads/2011/07/Michail_vampire.png"><img class="size-full wp-image-1353 " title="Michail_vampire" src="http://www.klocwork.com/blog/wp-content/uploads/2011/07/Michail_vampire.png" alt="" width="479" height="358" /></a><p class="wp-caption-text">Michail the friendly, programming vampire.</p></div>
<p>Instead of fomenting dissent (that barely exists) in a brazen attempt to boost readership, I&#8217;m changing tactics to look at ways in which testing and development are complementary, beyond their common goal of releasing quality software products.</p>
<p>What can I say? After my previous post, <a href="http://www.klocwork.com/blog/2011/02/how-developers-drive-testers-nuts-lets-count-the-ways/" target="_blank">How developers drive testers nuts–let’s count the ways</a>, I&#8217;m clearly getting less edgy.</p>
<p>I approached our newest addition to the Klocwork development team, Michail Greshishchev. While he&#8217;s a new full-timer, Greshishchev is not a new face around here.</p>
<p>The recent Carleton University engineering graduate did two co-op terms here&#8211;one in professional services and the other in testing.</p>
<p>So I asked Greshishchev how his stint in testing affected his development. Here&#8217;s exactly what he said:</p>
<ol>
<li>Writing short, efficient unit tests comes naturally after dealing with mammoth testing frameworks. Most of the code I write are tests – the techniques and skills I&#8217;ve learned in testing are fully applicable to development.</li>
<li>Developers have no idea how to execute a test in our automated test system (I don&#8217;t blame them&#8211;the test machine is a large, well-oiled beast distributed over dozens of operating environments). Having the knowledge to run test team tests on developer builds means I don&#8217;t need to wait for nightly build test results to address issues. More importantly, I can add my own tests to the test team&#8217;s automated test system.</li>
<li>It&#8217;s common for a developer to request more information about a tester&#8217;s problem report. My experience with the test team allows me to access the information on test machines myself, saving time for everyone.</li>
<li>The test report pages actually make sense. This allows me to investigate test failures in the nightly build before a tester comes to my desk to tell me I broke something.</li>
</ol>
<p>His experience as part of the test team has been win-win for him and his colleagues. Testing and development sound like allies, don&#8217;t they? Well, as much as <a href="http://www.klocwork.com/blog/2011/02/how-developers-drive-testers-nuts-lets-count-the-ways/" target="_blank">werewolves</a> and vampires can be allies, I suppose. And he was such a nice guy too, but the change is upon him.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/07/he-crossed-the-line-testing-to-development/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New programs for software security</title>
		<link>http://www.klocwork.com/blog/2011/07/new-programs-for-software-security/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=new-programs-for-software-security</link>
		<comments>http://www.klocwork.com/blog/2011/07/new-programs-for-software-security/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 17:48:52 +0000</pubDate>
		<dc:creator>Alen Zukich</dc:creator>
				<category><![CDATA[General Coding]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1350</guid>
		<description><![CDATA[The U.S. Department of Homeland Security, in conjunction with the SANS Institute and Mitre have been hard at work again.  See the article.  There are two new programs called the Common Weakness Risk Analysis Framework (CWRAF) and the Common Weakness Scoring System (CWSS).  Using these two in conjunction will help users identify the most important [...]]]></description>
			<content:encoded><![CDATA[<p>The U.S. Department of Homeland Security, in conjunction with the SANS  Institute and Mitre have been hard at work again.  See the <a href="http://www.scmagazineus.com/dhs-unveils-new-programs-for-software-security/article/206253/" target="_blank">article</a>.  There are two new programs called the <a href="http://cwe.mitre.org/cwraf/index.html#overview" target="_blank">Common Weakness Risk Analysis Framework</a> (CWRAF) and the <a href="http://cwe.mitre.org/cwss/index.html">Common Weakness Scoring System</a> (CWSS).  Using these two in conjunction will help users identify the most   important weaknesses for their business.  It will be interesting to see adoption in the upcoming weeks.</p>
<p>In addition to CWRAF and CWSS the <a href="http://cwe.mitre.org/top25/" target="_blank">2011 CWE/SANS Top 25</a> list has been updated.  There has been a number of position changes and a few that have been knocked out and replaced by <a href="http://cwe.mitre.org/data/definitions/250.html" target="_blank">CWE-250</a>, <a href="http://cwe.mitre.org/data/definitions/676.html" target="_blank">CWE-676</a>, <a href="http://cwe.mitre.org/data/definitions/134.html" target="_blank">CWE-134</a>, and <a href="http://cwe.mitre.org/data/definitions/759.html" target="_blank">CWE-759</a>.  Not too many surprises but I never really noticed CWE-134 not in the list before.  That certainly makes sense.  However it does shock me that <a href="http://cwe.mitre.org/data/definitions/129.html" target="_blank">CWE-129</a> (Improper Validation of Array Index) didn&#8217;t make the list this year.  Certainly a problem that I&#8217;ve seen a ton, although it was close (#27).  To see Klocwork&#8217;s coverage of 2011 CWE/SANS Top 25 go <a href="http://www.klocwork.com/products/documentation/current/2011_CWE-SANS_Top_25_Most_Dangerous_Software_Errors_mapped_to_Klocwork_checkers" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/07/new-programs-for-software-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Evolution of Static Code Analysis – Part 3: The Present Day</title>
		<link>http://www.klocwork.com/blog/2011/06/the-evolution-of-static-code-analysis-part-3-the-present-day/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=the-evolution-of-static-code-analysis-part-3-the-present-day</link>
		<comments>http://www.klocwork.com/blog/2011/06/the-evolution-of-static-code-analysis-part-3-the-present-day/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 20:10:37 +0000</pubDate>
		<dc:creator>Todd Landry</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[General Industry]]></category>
		<category><![CDATA[Software Quality]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[code analysis]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[source code analysis]]></category>
		<category><![CDATA[Static Analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1322</guid>
		<description><![CDATA[My first 2 posts looked at 2 different eras of Static Code Analysis, the Early Years and the Early 21st Century. The SCA solutions of these times were revolutionary, and helped software development teams a great deal. But they had their warts. In the final post in this series, I’m going to introduce you to [...]]]></description>
			<content:encoded><![CDATA[<p>My first 2 posts looked at 2 different eras of Static Code Analysis, the <a href="http://www.klocwork.com/blog/2011/05/the-evolution-of-static-code-analysis-part-1-the-early-years/">Early Years</a> and the <a href="http://www.klocwork.com/blog/2011/05/the-evolution-of-source-code-analysis-part-2-the-early-21st-century/">Early 21</a><sup><a href="http://www.klocwork.com/blog/2011/05/the-evolution-of-source-code-analysis-part-2-the-early-21st-century/">st</a></sup><a href="http://www.klocwork.com/blog/2011/05/the-evolution-of-source-code-analysis-part-2-the-early-21st-century/"> Century</a>. The SCA solutions of these times were revolutionary, and helped software development teams a great deal. But they had their warts.</p>
<p>In the final post in this series, I’m going to introduce you to the present day Static Code Analysis technology and how it is impacting developers.</p>
<p><strong>The Present Day</strong></p>
<p>I’m a huge fan of Reece’s Peanut Butter Cups. I love them. I keep active so I don&#8217;t feel guilty eating them. In a strange, convoluted way, the 3<sup>rd</sup> generation of static code analysis tools are like this delicious combination of chocolate and peanut butter. Let me explain.</p>
<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2011/05/reeces.jpeg"><img class="size-full wp-image-1323 alignright" title="reeces" src="http://www.klocwork.com/blog/wp-content/uploads/2011/05/reeces.jpeg" alt="" width="259" height="194" /></a></p>
<div class="mceTemp">I’m sure you remember from my previous posts how the 1<sup>st</sup> generation tools (i.e. Lint) gave questionable results but was still considered by developers as a tool exclusively for them, and the 2<sup>nd</sup> generation tools gave really good results but moved away from being a developer tool.</div>
<div class="mceTemp">The 3<sup>rd</sup> generation tools recognized that the developer must be an integral part of the process of identifying, fixing and preventing bugs from reaching the code stream and so, they took the proven results from the 2<sup>nd</sup> gen tools and delivered them right to the developer’s desktop.</div>
<p>Eureka! Now developers are able to perform an analysis locally, using their development environment of choice, while still getting the high accuracy and consistency that was previously only possible by checking in their code and waiting for the integration build to take place.</p>
<p>Think about the ramifications of this:</p>
<ul>
<li>cleaner code is being checked in </li>
<li>the ‘rinse-repeat’ vicious cycle of rework is drastically reduced</li>
<li>quality teams are now able to focus on testing the product’s functionality rather than spending cycles uncovering something that could easily and quickly be found by automated tools. </li>
</ul>
<p>Mmmm-mmmm good. Sounds like a win-win-win to me!</p>
<p>I think the best thing about these 3rd generation tools is simply the fact that developers are now able to resume ownership of the quality and security of the code they are producing.</p>
<p>Well, I hope you enjoyed this walk down memory lane. I sure did. Now I&#8217;m looking for spare change because I see a trip to the vending machine in my immediate future.</p>
<p>If you want to know more about the 3rd Generation tools, feel free to drop me a line.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/06/the-evolution-of-static-code-analysis-part-3-the-present-day/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>To report, or not to report…</title>
		<link>http://www.klocwork.com/blog/2011/06/to-report-or-not-to-report/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=to-report-or-not-to-report</link>
		<comments>http://www.klocwork.com/blog/2011/06/to-report-or-not-to-report/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 20:10:20 +0000</pubDate>
		<dc:creator>Gwyn Fisher</dc:creator>
				<category><![CDATA[Nasty Bugs]]></category>
		<category><![CDATA[Software Quality]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[Static Analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1333</guid>
		<description><![CDATA[Creating a source code analysis (SCA) engine is a balancing act, a decision process of where you believe the most value can be found along the spectrum that is the signal-to-noise ratio of the detection process. At one end lies the realm of massive noise and hopefully complete coverage, whilst at the other is the [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="margin-left: 5px; margin-right: 5px;" src="http://images.all-free-download.com/images/graphiclarge/balance_scale_clip_art_10655.jpg" alt="Balance" width="425" height="274" />Creating a source code analysis (SCA) engine is a balancing act, a decision process of where you believe the most value can be found along the spectrum that is the signal-to-noise ratio of the detection process. At one end lies the realm of massive noise and hopefully complete coverage, whilst at the other is the quiet calm of the theoretically useful but ultimately useless realm of no noise, but ultimately no signal either.</p>
<p>That may sound counter-intuitive. Shouldn’t a zero noise point on the spectrum be accompanied by an infinitely strong signal? Perhaps in the world of DSP this is true, but in the world of SCA reducing noise comes right along with a reduction in detection capability &#8211; it’s unfortunately almost a straight-line correlation.</p>
<p>So if we assume that we’re trying to balance a couple of dials on our theoretical tuner, we might start by reducing or dampening noise – it’s the most obvious place to start, after all. Nobody likes to listen to their favorite FM station through the curtain of hissing and popping that accompanies the act of driving through a major city.  Likewise no developer likes sifting through a long list of bogus detection errors in order to find the hidden gems. But to drag out the analogy, assume that the only way of reducing hiss on your FM signal is to turn down the volume… now you’ve got less hiss, but also less Bruce Springsteen goodness to accompany it.</p>
<p>Balance is what we need here, obviously. Enough Boss to make us ignore the hiss, or to put it in a more SCA-like context, enough interesting bugs to make us ignore the incorrect, or the irrelevant (correct detections on the part of the engine that the developer just doesn’t care about, e.g. low memory conditions in a memory-insensitive environment).</p>
<p>Consider the following simple example that clearly lies &#8220;on the line&#8221;:</p>
<pre><span style="font-size: small;"><span style="font-family: courier new,courier;">    void foo(char* s, int a)</span><span style="font-family: courier new,courier;">
    {
</span><span style="font-family: courier new,courier;">        char* s1 = s;
</span><span style="font-family: courier new,courier;">        if( a &gt; 0 )
</span><span style="font-family: courier new,courier;">            *s1 = 'a';   // potentially use an uninitialized ‘s1’</span><span style="font-family: courier new,courier;">
    }
</span><span style="font-family: courier new,courier;">
    void bar(int m)
    {
        char *s;
        foo(s, m);       // s is not initialized prior to calling ‘foo’
    }</span></span></pre>
<p>So&#8230; to report, or not to report?</p>
<p>Lacking any other information, it is obvious that function ‘foo’ interacts under certain situations (when parameter ‘a’ is positive) with parameter ‘s’ (aliased as local variable ‘s1’). As we have no knowledge about the provenance of parameter ‘s’ when analyzing ‘foo’, however, there’s nothing here to cause a report and so we squirrel away the knowledge of what ‘foo’ does for later use.</p>
<p>When analyzing ‘bar’ we know what ‘foo’ does, and we know we’ve got an uninitialized local pointer, ‘s’. But again we’re lacking enough knowledge to know the valid values, or ranges, that parameter ‘m’ may take. There are definitely a set of circumstances here in which we know a problem will occur (if parameter ‘m’ is positive), and a set of circumstances in which we know a problem will not occur (if parameter ‘m’ is zero or negative) – this much is encoded in the functional behavior of ‘foo’. But is it a defect, or should we filter out the report in favor of providing only those situations in which we can be “sure” the bug not only exists, but can be proven to be exercised?</p>
<p>There’s the art of balance in a nut-shell, and it revolves around the phrase “lacking any other information.” In the ideal world, lacking any restrictions in terms of time, memory or computing power (or indeed actual from-the-wall power, as we have to worry about now), we might defer all such decisions until we categorically know that a particular data value is passed down the call graph far enough to get to ‘foo’. But in the real world of multi-million LOC projects, that approach simply can’t scale.</p>
<p>And so, calling on balance as our friend, we can bias a localized decision to report or not, given that we know to at least one order of approximation that bad things could happen here. Different engines pronounce that bias differently, leading to one of the greatest divides between prevalent solutions.</p>
<p>Now ask yourself, as the developer, is it a worthy report if you know that 10 levels up the call graph there’s a check on what eventually becomes parameter ‘m’ to ensure that it’s never positive? Perhaps you’d automatically classify this as a false positive and, annoyed at the tool, move onto the next report. Or perhaps, seeing the size of the gap in the call graph, you might just choose to code defensively, initializing ‘s’ to NULL in ‘bar’ and adding guard code to &#8216;foo&#8217; because, hey, you never know.</p>
<p>And as we’ve all seen so many times over the years, “you never know” might just as well be written “and so it came to pass&#8230;”</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/06/to-report-or-not-to-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 10 List: Well Traveled Path to Source Code Analysis Success</title>
		<link>http://www.klocwork.com/blog/2011/05/top-10-list-well-traveled-path-to-source-code-analysis-success/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=top-10-list-well-traveled-path-to-source-code-analysis-success</link>
		<comments>http://www.klocwork.com/blog/2011/05/top-10-list-well-traveled-path-to-source-code-analysis-success/#comments</comments>
		<pubDate>Tue, 31 May 2011 14:10:53 +0000</pubDate>
		<dc:creator>Brendan Harrison</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[source code analysis deployment]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=1324</guid>
		<description><![CDATA[The Code Integrity folks have developed a lot of best practices on deploying static analysis and have compiled many of them in a solid whitepaper. They include a Top 10 list of what they call &#8220;The Well Traveled Path to Success&#8221;. Below is their (somewhat paraphrased in spots) list. 1. Determine who cares. Who has [...]]]></description>
			<content:encoded><![CDATA[<p>The <a title="Code Integrity Solutions" href="http://codeintegritysolutions.com/" target="_blank">Code Integrity</a> folks have developed a lot of best practices on deploying static analysis and have compiled many of them in a solid <a title="Code Integrity Whitepaper" href="http://developer.klocwork.com/sites/default/files/CodeIntegritySolutions_Whitepaper_Klocwork.pdf" target="_blank">whitepaper</a>. They include a Top 10 list of what they call &#8220;The Well Traveled Path to Success&#8221;. Below is their (somewhat paraphrased in spots) list.</p>
<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2011/05/TOP-1022.jpg"><img class="alignleft size-medium wp-image-1327" title="TOP-102" src="http://www.klocwork.com/blog/wp-content/uploads/2011/05/TOP-1022-250x300.jpg" alt="Static Analysis Top 10" width="250" height="300" /></a>1. Determine who cares. Who has a vested interest that bugs actually get fixed. How much do they care?</p>
<p>2. Get an expert to tune the solution for your codebase. <a title="Static Analysis Tuning" href="http://developer.klocwork.com/browse/tuning-your-cc-and-java-analysis" target="_blank">Static analysis tuning</a> will maximize defect finding while minimizing false positives. <br />
 3. If possible, pilot with a small group to gain early successes.<br />
 4. Appoint the proper roles, particularly management sponsor, administrator, defect triagers, fixers and verifiers. <br />
 5. Set up the proper process, incentives and consequences. Integrate the SCA tool into your environment. Automate and simplify as much as possible.<br />
 6. Get a team to handpick good, high-priority defects for the team rather than have them sift through potential false positives. <br />
 7. Set up a central resource website that includes simplified documentation, policies, procedures, roles, reports, etc.<br />
 8. Set up various reports like the daily dashboard, top ten list and the “wall of shame”. Make it public. Do a little bit of marketing.<br />
 9. Train and mentor the team providing guidance, support and discipline. Either in-person or <a title="Static Analysis E-Learning" href="http://developer.klocwork.com/members/cbt" target="_parent">static analysis e-learning</a> courses work.<br />
 10. Determine success criteria and measure it. Provide status updates often, work on a <a title="Source Code Analysis ROI" href="http://www.klocwork.com/solutions/roi-calculator/" target="_blank">source code analysis ROI model</a> that works for your organization.</p>
<p>I agree with the general thrust of most of these, but some might be  overkill depending on the size of your deployment. My other quibble is  that many of the recommendations presume a  centralized defect triage  model where you&#8217;d have a central group of code  reviewers sifting though  bug reports.</p>
<p>That&#8217;s a common deployment model,  but we&#8217;re seeing more people  choose to just provide the tool to their  developers via desktop static  analysis. With the possible exception of  your backlog, this will  eliminate (or greatly reduce) the need for a central code review team  that stares at bugs all day long. Regardless, they&#8217;re all good  considerations to at least, well&#8230; consider.</p>
<p>With the launch of the <a title="Klocwork Developer Network" href="http://developer.klocwork.com" target="_blank">Klocwork Developer Network</a>, we&#8217;re making a  deliberate and concerted effort to make many of these kinds of  deployment resources freely available to our customers. I&#8217;ve included  links where appropriate.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2011/05/top-10-list-well-traveled-path-to-source-code-analysis-success/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss><!-- Dynamic page generated in 0.500 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-05-22 13:25:18 --><!-- Compression = gzip -->

