Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!rochester!ritcv!cci632!ccicpg!nick From: nick@ccicpg.UUCP (Nick Crossley) Newsgroups: comp.lang.c Subject: Re: = vs ==, and do 10 i = 1.3 Message-ID: <8971@ccicpg.UUCP> Date: 11 Jan 88 23:28:26 GMT References: <4668@pyr.gatech.EDU> <495@xyzzy.UUCP> <9930@mimsy.UUCP> <609@PT.CS.CMU.EDU> <10109@mimsy.UUCP> Reply-To: @ccicpg.UUCP (Nick Crossley) Organization: CCI CPG, Irvine CA Lines: 39 Keywords: C, lint, checking Summary: program for checking = in C I too have often made the error of writing if (a = b) rather than if (a == b), and was in the position of having to check a lot of my own code and that of several co-workers on a large project. So I wrote a program 'check' which checked the things lint did not, based on the errors I saw in our code. 'check' will produce a warning for :- = in any conditional context potentially ambiguous else if with neither then nor else The first checks for = not only in if, but while, for, &&, ||, etc. The second warns about :- if (a) if (b) stat1; else stat2; but not about :- if (a) { if (b) stat1; else stat2; } which I believe to be better (and since I wrote the program, I made it think as I do :-)) The third warns about :- if (a); stat1; which is legal, but dubious, and which one of my co-workers wrote, and which took me a good day of debugging to notice the extra semicolon!! 'check' is by no means complete; there are many additional features I will get round to adding one day, including software metrics. However, it works fine as it stands, so if anyone is interested I can post it. Nick Crossley ...!uunet!ccicpg!nick CCI, 9801 Muirlands, Irvine 92718