Patch #2 to Pcomm v1.1
    Mike Khaw 
    mkhaw at teknowledge-vaxc.ARPA
       
    Thu Sep 22 03:53:44 AEST 1988
    
    
  
In article <7782 at bcsaic.UUCP> paula at bcsaic.UUCP (Paul Allen) writes:
>>
>>>! 	if (*lock_path != NULL && lock_path != NULL) {
>>
>>This only tests whether lock_path is legal *after* trying to use it!
> 
> I've now seen a couple postings about this bug, but nobody has got it
> right yet!  What has been missed is that C makes no guarantee about the <--
> order of expression evaluation.  The only safe way to perform this test <--
> is using two nested if statements.					  <--
from page 19 of K&R (1978 ed.)
	Expressions connected by && or || are evaluated
	left to right
	^^^^^^^^^^^^^
furthermore, "!=" has higher precedence than "&&" so
	if (lock_path != NULL && *lock_path != NULL)
is correct.
Mike Khaw
-- 
internet: mkhaw at teknowledge.arpa
uucp:	  {uunet|sun|ucbvax|decwrl|uw-beaver}!mkhaw%teknowledge.arpa
hardcopy: Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA 94303
    
    
More information about the Comp.sources.bugs
mailing list