nbctfmerge handling of outfile

Valery Ushakov <[email protected]>
Newsgroups gmane.os.netbsd.devel.toolchain
Message-ID <[email protected]>
Native ctfmerge on netbsd doesn't delete its output on failure.  Cf.
src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c - the ifdef in
terminate_cleanup.

However that ifdef doesn't kick in for tools build on non-netbsd
hosts, that makes nbctfmerge behave differently from the native one.

Any objections to the following patch?  Do I miss anything?

--- ctfmerge.c.~1.18.~	2023-07-16 04:03:58.022071999 +0300
+++ ctfmerge.c	2023-12-26 21:37:04.371052514 +0300
@@ -682,7 +682,7 @@ terminate_cleanup(void)
 	if (outfile == NULL)
 		return;
 
-#if !defined (__FreeBSD__) && !defined(__NetBSD__)
+#if !defined (__FreeBSD__) && !(defined(__NetBSD__) || HAVE_NBTOOL_CONFIG_H)
 	if (dounlink) {
 		fprintf(stderr, "Removing %s\n", outfile);
 		unlink(outfile);

PS: While here, shouldn't the outfile test just above be inside the
ifdef as well?  It's dead code otherwise and gcc optimizes it away
anyway.

-uwe
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.