|
Programming C, bash, Python, Perl, PHP, Java, you name it. |
|
Thread Tools | Display Modes |
|
|||
C programming - Lint
How many of you c programmers use lint? I've only recently discovered it and my work doesn't and REALLY needs to use it .... our code is horrible haha
For those who don't know what it is, check it out here lint(1) |
|
|||
I used it back in the day, in the early 1990s. It was very helpful (though rather verbose) -- it was always used in one window, vi in another, and an "unassigned" shell in a third.
|
|
|||
This isn't so much an indictment on your place of employment as it is testament of the industry as a whole. Most places where you will go will have questionable code to some degree or another. Some places will be better than others for quality, readability, & maintainability as each means different things to different people, & recognize that making schedules usually is much more important. I have also been part of companies who try to legislate every possible aspect of the development cycle, & it is a wonder that anything ever got done. So realize that everything has to be balanced.
Inserting use of static analysis tools into the development process only makes sense if they are integrated early in initial development. I have been part of companies who appeased some vice-president by forcing development staffs to enforce that all code pass through lint(1) without warnings long after the code had been deployed in the field. This meant that portions of the staff had to allocated just to go back through the code correcting thousands of C casts & initializations for months. Given that the code had been in the field at that point for years, the benefit of such activity had negligible value. In fact, it required more hours to be spent by a larger portion of the staff checking through trivial syntax changes to ensure that code correctness wasn't introducing more bugs. Was this place particularly bad? No, not at all. In fact, the code coming from my group was pretty good from the beginning. Quality practices have to balanced with the value they provide. Recognize that lint(1) merely checks code for questionable syntax errors & vagaries. A better static analysis tool is Coverity which goes deeper into semantic use: http://www.coverity.com/ Urban legend has it that a number of Open Source projects ran their code bases through Coverity a few years back & found all kinds of nasty things going on internally. Last edited by ocicat; 8th May 2008 at 03:15 AM. |
|
|||
no the code IS really bad .... now i have proof of how bad :P
btw .. you and scottro are more and more alike every day with your essay posts. I have a VERY short attention span and i wish you would consider this next time you make a post! |
|
||||
Quote:
I usually feed code though lint with various switches (and note the changes in output) on both my FreeBSD and OpenBSD systems as well as compiling with the desired warning levels and testing the program on both. Ever since I had a program that was executing normal on one BSD but segfaulting on the other due to a coding oversight on my part -- I've tested on both, less it happen again ;-) lint's feedback should be taken with a grain of salt: people know better then programs, otherwise UNIX would've been a precursor to automated PacMan. Depending on your implementation of lint and how much of current standards you're allowed to use, it can produce some 'interesting' outputs. And it really does help to have a human being figure it whats valid shouting and whats just background noise.
__________________
My Journal Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''. Last edited by TerryP; 8th May 2008 at 06:51 PM. |
|
|||
Hello,
Quote:
Is it available for NetBSD? Linux? Quote:
I like to read the essays - not so much to write them.
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14) |
|
|||
Yes & yes. lint has been around from the beginnings of C & Unix.
Quote:
|
|
|||
Right. My 1978-copyrighted (!) version of K&R describes lint as "This program is called lint, apparently because it picks bits of fluff from one's programs... It detects type mismatches, inconsistent argument usage, unused or apparently uninitialized variables, potential portability difficulties, and the like."
|
|
||||
lint is at least installed as part of the FreeBSD and OpenBSD (although I always opt into installing development tools/compilers).
The versions in FreeBSD and OpenBSD are slightly different and there is also splint available in ports (formally lclint I think) which I'd guess is what most Linux distros would ship with. My shells rc file usually adds system specific aliases for the installed gcc and lint. Typically defining lint and gcc with the most switches I always use that are also common to all of my systems. Along with lint_all, lint_ansi, and lint_traditional, gcc_debug, gcc_wall, and gcc_optimize with their obvious meanings but tuned to the local lint/gcc setup. from my ~/.zshrc on FreeBSD: Code:
alias gcc='gcc -Wall -W -Wpointer-arith -Wbad-function-cast -std=c99 ' alias gcc_wall='gcc -Wall -Wpointer-arith -Wcast-qual -Wcast-align \ -Wconversion -Waggregate-return -Wstrict-prototypes \ -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \ -Winline -Wnested-externs -std=c99 -march=i686 -pipe' alias gcc_optimize=' -fforce-mem -fforce-addr -finline-functions \ -fstrength-reduce -floop-optimize -O3' alias gcc_debug='gcc -ggdb3' alias lint='lint -cehzs' alias lint_all='lint -aaabcehHz' alias lint_ansi='lint -aaabcehHzs' alias lint_traditional='lint -aaabcehHzt' I usually look these up when I write makefiles.
__________________
My Journal Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''. |
|
|||
Hello,
I do see that lint is included in the base installation of NetBSD - my oversight. I still haven't found lint for Slackware yet (either in a package or as source).
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14) |
|
||||
try splint: http://www.splint.org/
__________________
My Journal Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''. |
|
|||
Quote:
lint saves lives, use it... but, remember 1 thing, you're the developer.. don't comment out crucial code to make lint..(*cough* or valgrind *cough*) happy. |
Tags |
lint |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
php programming in openbsd. | bsdnewbie999 | OpenBSD General | 5 | 15th June 2009 03:03 AM |
Java and AI-programming | idefix | Programming | 4 | 7th February 2009 01:41 PM |
c programming - Modules | corey_james | Programming | 3 | 6th November 2008 08:49 PM |
Learning Programming | Crypt | Programming | 35 | 27th October 2008 04:54 PM |
GUI Programming | bsdnewbie999 | Programming | 6 | 17th August 2008 12:19 AM |