Re: [PATCH/WIP v3 01/31] wrapper: implement xopen()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 25, 2015 at 2:39 AM, Johannes Schindelin
<johannes.schindelin@xxxxxx> wrote:
> IMO the varargs make the code more cumbersome to read (and even fragile, because you can easily call `xopen(path, O_WRITE | O_CREATE)` and would not even get so much as a compiler warning!)

I think that since xopen() is a wrapper around open(), it is best to
follow its interface (as defined by the POSIX spec) as much as
possible. It's important to note that the POSIX spec explicitly
defines that open() takes a variable number of arguments, and that the
`mode` argument is only used if O_CREAT is set. This means that if we
cement xopen() to take 3 arguments, and the third is a mode_t (or an
int), then we may not be able to keep up with changes in the POSIX
spec which e.g. in the future may specify that open() takes 4
arguments if certain flags are set.

> and the error message does carry value: it helps you resolve the issue (it is completely unnecessary to check write permissions of the directory when a file could not be opened for reading, for example, yet if the error message does not say that and you suspect that the file could not be opened for *writing* that is exactly what you would waste your time checking).

Good point, I agree with this. I'll look into putting the error messages back.

Thanks,
Paul
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]