On Tue, Mar 3, 2020 at 6:47 PM Bruno Haible <[email protected]> wrote: > Dan Gohman wrote: > > > if (flags & (O_CREAT | O_WRONLY | O_RDWR)) > > > > However, this can erroneously return true on systems where O_RDWR shares > > bits with R_RDONLY. > > Would > if (flags & ((O_CREAT | O_WRONLY | O_RDWR) & ~O_RDONLY)) > be correct? >
That would fix the problem for systems that define O_RDONLY as Hurd does, while not breaking any known systems. It wouldn't be correct on a hypothetical system which defines the constants like this: #define O_WRONLY 0 #define O_RDONLY 1 #define O_RDWR 2 though I don't know of any platforms which do this. Dan
