| Issue 9: | should use S_ISLNK and S_ISDIR | |
| 2 people starred this issue and may be notified of changes. | Back to list |
it's not necessarily correct to test (mode & S_IFLNK) == S_IFLNK or (mode & S_IFDIR) == S_IFDIR; you want to test all the S_IFMT bits. easiest to use the provided S_ISLNK and S_ISDIR macros... |
|
,
Jun 30, 2008
Why is it not correct? If you expand out the S_ISDIR macro, it basically does the same thing. |
|
,
Jun 30, 2008
no; expand out the S_ISDIR macro, and you'll see the difference between the broken code in distcc and the S_ISDIR macro is exactly what i said above: you need to use (m & S_IFMT). taking the example of S_IFDIR... good code: ((m & S_IFMT) == S_IFDIR) distcc: ((m & S_IFDIR) == S_IFDIR) if you're saying you don't understand why they're not equivalent, try substituting in S_IFSOCK for m. but, like i said, best of all is to use S_ISLNK and S_ISDIR because someone else worries about whether they're correct, and they're more intention-revealing anyway. |
|
,
Jul 01, 2008
Ok, the results will be different, but only if stat() reports the file is both a
directory and a {fifo, char device, etc...}. The chances of that happening are very
rare, and if that ever happens, you probably have more serious problems to worry about.
I agree using the macros makes the code more readable. Please send the patch to:
distcc-patches at googlegroups.com. I don't know if patches get picked up from here.
See: http://lists.samba.org/archive/distcc/2008q2/003670.html
|
|
,
Jul 29, 2008
I've applied the patch.
Status: Fixed
|
|
|
|