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.

Read more about software development in InfoWorld's Developer World Channel.

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

On Twitter now

Application development

Powered by Twitter
additional resources
White Paper - How to Improve Delivery of Advanced Web Applications

White Paper

Virtual Workforce: The Key to Expanding The Business While Cutting Costs

Get the independent advice and expertise you need to support a virtual workforce.

Go inside:
The three-step approach to making a virtual workforce a reality.
The four flavors of client virtualization technologies.
The three key initiatives that solve IT challenges.
Download now »
White Paper: Successfully Secure Your Wireless LAN With Wi-Fi firewalls.

White Paper

Addressing Linux Threats Leveraging Fewer Resources

The increase in Linux popularity has increased the frequency and sophistication of malware attacks. Read this 2 page white paper now to learn how you can protect your Linux environment with real-time protection that is certified by all major Linux vendors.

Download now »
White Paper - The 2009 Handbook of Application Delivery

White Paper

The 2009 Handbook of Application Delivery

Ensuring acceptable application delivery will become even more difficult over the next few years. As a result, IT organizations need to ensure that the approach that they take to resolving the current application delivery challenges can scale to support the emerging challenges. This handbook elaborates on the key tasks associated with planning, optimization, management and control and provides decision criteria to help IT organizations choose appropriate solutions.

Download now »
White Paper - Is Your Backup System Outdated?

White Paper

Mid-range Storage Considerations

A common misconception is that mid-range storage requirements are dramatically different than that of a larger enterprise. Mid-range storage users may require less capacity, but they have similar functionality and management requirements. This ESG paper examines mid-range storage needs and reviews a new solution that adjusts size while retaining value, performance and functionality.

Download now »

Developer World Newsletter

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

©1994-2010 Infoworld, Inc.