Patch #2 to Pcomm v1.1
William E. Davidsen Jr
davidsen at steinmetz.ge.com
Wed Sep 28 03:21:55 AEST 1988
In article <25069 at teknowledge-vaxc.ARPA> mkhaw at 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 at ge-crd.arpa)
{uunet | philabs}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me
More information about the Comp.sources.bugs
mailing list