Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!munnari.oz.au!metro!wolfen!hls0!george From: george@hls0.hls.oz (George Turczynski) Newsgroups: comp.lang.c Subject: Re: Assignment in test: OK? Summary: Be precise. Message-ID: <928@hls0.hls.oz> Date: 9 Sep 90 23:07:18 GMT References: <1990Sep5.185451.25532@DRD.Com> Lines: 55 In article <1990Sep5.185451.25532@DRD.Com> mark@DRD.Com (Mark Lawrence) writes: > > I have a proclivity to code like the following: > > if( (status = FuncCall(foo, bar, gex)) < SomeValue) > GripeAboutIt(); > > or variations thereof. When I run saber on such code, it babbles a > warning about the assignment in the test. Being the gullible naif I am, > ... Oh, it babbles does it ? What does it babble ? In future it would be more useful to know what the warning is about, rather than have someone tell you what their `opinion' of your code is. Opinions mean very little. I might "guess" that perhaps Saber complains because the variable type of `status' and the return type of `FuncCall()' are different. In that case you may have omitted a vital header file or not performed a necessary CAST. Who knows ? Now ... In article , burley@world.std.com (James C Burley) writes: > Your code is fine IMHO. But suppose you had written the following > accidentally: > > if (foo = 0) > > This is a common mistake. (typing mistake ?) This is only a mistake if you don't know what you're doing (or you have a typo, in which case it's only a mistake for a short while). It is, in fact, perfectly legal C, but isn't what people sometimes want it to mean. > ...... is just trying to get you to look at ifs containing assignments, just > in case you meant to say "if (foo == 0)". In your particular example, I'd Does Saber warn you that you might have mispelt a variable name ? I doubt it. It should only bother you with DEFINITE problems or things that it is unsure about. Lint is for finding out more detailed, obscure and discrete problems. > BTW, if I ever write a new C-like language, ":=" will be the assignment > operator, "==" the comparison operator, and "=" totally invalid! Although I will be very cautious of such a language. -- | George P. J. Turczynski. |---------------------------------------------------- | Computer Systems Engineer. | ACSnet: george@highland.oz | I can't speak for the | | Highland Logic Pty. Ltd. | Phone: +61 48 683490 | company, I can barely | | Suite 1, 348-354 Argyle St | Fax: +61 48 683474 | speak for myself... | | Moss Vale. NSW. Australia. 2577 |----------------------------------------------------