Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!rochester!cornell!batcomputer!itsgw!steinmetz!davidsen From: davidsen@steinmetz.ge.com (William E. Davidsen Jr) Newsgroups: comp.sources.bugs Subject: Re: Patch #2 to Pcomm v1.1 Message-ID: <12246@steinmetz.ge.com> Date: 27 Sep 88 17:21:55 GMT References: <7782@bcsaic.UUCP> <25069@teknowledge-vaxc.ARPA> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: General Electric CRD, Schenectady, NY Lines: 26 In article <25069@teknowledge-vaxc.ARPA> mkhaw@teknowledge-vaxc.ARPA (Mike Khaw) writes: | 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. Bear in mind that NULL is not always zero, but rather that zero cast to a pointer type is always NULL. Comparing NULL with data types other than pointers may (a) produce slow code or (b) produce code which doesn't work correctly. I would suggest that: if (lock_path != NULL && *lock_path != '\0') is easier to read and will avoid having the char->int->pointer conversion done at runtime. -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me