Re: TOCTOU bug in make(1)

David Holland <[email protected]>
Newsgroups gmane.os.netbsd.devel.toolchain
Message-ID <Y0ev/[email protected]>
On Sun, Oct 09, 2022 at 11:02:58PM +0200, Roland Illig wrote:
 > > On Fri, Oct 07, 2022 at 12:46:06AM +0300, Valery Ushakov wrote:
 > >   > It also, unnecessarily, IMHO, decided to change the return type to
 > >   > a more "modern" bool thus further obscuring the fact that the
 > >   > function was a simple wrapper around unlink(2).
 > > 
 > > Can we revert that? Using bool for success/failure is ambiguous (does
 > > true mean it succeeded or failed? both are reasonable) whereas 0/-1 or
 > > zero/nonzero is a clearly established and well understood idiom.
 > 
 > Can you show me a function in the NetBSD source tree that has return
 > type 'bool' (not 'int') and returns 'true' to indicate failure?

I don't know about in NetBSD as such, but in general I would say that

	failed = do_some_things();
	if (failed) {
	        ...
	}

is if anything more common than

	ok = do_some_things();
	if (!ok) {
	        ...
	}

because it preserves the common idiom (and widely held expectation)
that nonzero means failure.

But in any event, system calls and wrappers around them shouldn't be
returning bool.

-- 
David A. Holland
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.