DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 8th May 2008
corey_james corey_james is offline
Uber Geek
 
Join Date: Apr 2008
Location: Brisbane, Australia
Posts: 238
Default 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)
Reply With Quote
  #2   (View Single Post)  
Old 8th May 2008
DrJ DrJ is offline
ISO Quartermaster
 
Join Date: Apr 2008
Location: Gold Country, CA
Posts: 507
Default

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.
Reply With Quote
  #3   (View Single Post)  
Old 8th May 2008
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by corey_james View Post
our code is horrible haha
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.
Reply With Quote
  #4   (View Single Post)  
Old 8th May 2008
corey_james corey_james is offline
Uber Geek
 
Join Date: Apr 2008
Location: Brisbane, Australia
Posts: 238
Default

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!
Reply With Quote
  #5   (View Single Post)  
Old 8th May 2008
hydra's Avatar
hydra hydra is offline
Port Guard
 
Join Date: May 2008
Location: Slovakia (Europe)
Posts: 41
Default

However, I do enjoy reading the essays
Reply With Quote
  #6   (View Single Post)  
Old 8th May 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Default

cj, ADD ?

Last edited by ephemera; 8th May 2008 at 09:54 PM.
Reply With Quote
  #7   (View Single Post)  
Old 8th May 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Default

all caps not allowed, wtf?
Reply With Quote
  #8   (View Single Post)  
Old 8th May 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

Quote:
Originally Posted by corey_james View Post
I have a VERY short attention span and i wish you would consider this next time you make a post!
Short attention span and programming in C? Oh boy is that a strange mixture of dangling pointers ;-)




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.
Reply With Quote
  #9   (View Single Post)  
Old 8th May 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default

Hello,

Quote:
Originally Posted by corey_james View Post
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)
Is lint still available? I saw it online several months back and thought - wow! that would be a nice tool to have - but I couldn't find any reference to it being used since the 90's and couldn't find any source code or a binary for it.

Is it available for NetBSD? Linux?



Quote:
Originally Posted by ocicat View Post
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.
Is Coverity an Open Source project itself?



Quote:
Originally Posted by corey_james View Post
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!
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)
Reply With Quote
Old 9th May 2008
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by JMJ_coder View Post
Is it available for NetBSD? Linux?
Yes & yes. lint has been around from the beginnings of C & Unix.
Quote:
Is Coverity an Open Source project itself?
No, but it is damned good.
Reply With Quote
Old 9th May 2008
DrJ DrJ is offline
ISO Quartermaster
 
Join Date: Apr 2008
Location: Gold Country, CA
Posts: 507
Default

Quote:
Originally Posted by ocicat View Post
lint has been around from the beginnings of C & Unix.
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."
Reply With Quote
Old 10th May 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

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''.
Reply With Quote
Old 16th May 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default

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)
Reply With Quote
Old 16th May 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

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''.
Reply With Quote
Old 16th May 2008
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

Quote:
Originally Posted by linty
ribo-funk.c:5326: warning: function magical_axis expects to return value
Uh Oh, I'm returning from a procedure that was destined to return a signed 32bit integer!

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.
Reply With Quote
Reply

Tags
lint

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 09:16 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick