January 26, 2006

Lint traps bugs at compile time

Is your syntactically correct code not behaving? Lint is still a champ at detecting errors

The lint utility, which is shipped with some versions of Unix, traces its roots back to the days when compiling even modest programs took a long time. The utility was designed to check code for obvious errors and typos and remove them (as one would remove lint from clothing -- hence the name), so that an entire compilation cycle would not be wasted due to a spurious comma or semicolon.

As systems became faster, the cost of lost compilations decreased and developers used compilations as a way of performing syntax checking. In addition, compilers became better at identifying and warning about suspect constructions. Eventually, most developers stopped using lint and relied entirely on the compilers to do all checking. So much so that, several years ago, the GNU toolchain dropped lint entirely. Today, it does not ship on Linux platforms.

It's clear from the need for the tools in this review, that lint should have been improved rather than dropped. Fortunately, one great version of lint is still available today for all platforms. That is PC-Lint from Gimpel Software. The Unix version is called FlexeLint. At $239 per seat, PC-Lint is the best bargain in software development tools this side of open source. It catches just about every suspicious aspect possible. After you've configured it to fit your style, it delivers jewels.

For this review, I prepared a small C file with obvious bugs in it and asked each vendor to run it at the most sensitive bug-sniffing levels. Coverity, due to its detection philosophy, found zero; Klocwork found five. PC-Lint generated 15 warnings. Here, however, is the critical difference: Only PC-Lint correctly identified a miscoded function call. All vendors agreed this call could generate a null-pointer exception, which is a showstopper in C and C++ and a specific target of the reviewed suites.

Lint is particularly useful for locating a bug in code that compiles correctly -- syntactically correct code that does not behave as expected almost always has an error that lint will catch. What lint does not do is walk every possible execution path across a large code base to find cross-functional errors. However, if you're looking at static code analysis tools for the first time, start with PC-Lint.

Ultimately, if you use either Coverity Prevent or Klocwork K7, keep running lint on your code base. It will catch important details these tools and your compiler will miss.

Andrew Binstock is senior contributing editor of the InfoWorld Test Center.
Close

On Twitter now

Application development

Powered by Twitter

White Paper

D2D Virtual Tape Library Replication Primer

This whitepaper explains the terminology and concepts behind Data Replication technologies and establishes some sizing rules through worked examples. Learn the new paradigm in disaster tolerance—protect data anywhere.

Download now »

White Paper

An Alternative to Virtualization for Datacenter Cost Savings

Server virtualization is a popular option for dealing with mounting datacenter costs. Another equally promising approach is the use of an Application Delivery Controller. Citrix NetScaler provides a low-cost way for organizations to reduce their server count and accrue cost savings from a reduction in space, cooling, power and personnel.

Download now »

White Paper

Why Your Firewall, VPN, and IEEE 802.11i Aren't Enough to Protect Your Network

The emergence of WLANs has created a new breed of security threats to enterprise networks.

Included in HP ProCurve WLAN solutions is security technology that alleviates threats from WLANs through:
* Monitoring wireless activity inside and out of the enterprise
* Classifying WLAN transmissions into harmful and harmless
* Preventing transmissions that pose a security threat to the enterprise network
* Locating participating devices for physical remediation

Download now »

White Paper

Bringing the Edge to the Data Center

Effectively address data protection challenges, implementing solutions that help store and protect business–critical data while cutting costs and improving efficiency and reliability.

Download now »

Sign up to receive InfoWorld Resource Alerts

Subscribe to the Developer World Newsletter

Receive a weekly roundup about the art and science of software development.

©1994-2009 Infoworld, Inc.