Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make: change return type of unlink_file back to...



details:   https://anonhg.NetBSD.org/src/rev/1d950d87731f
branches:  trunk
changeset: 371787:1d950d87731f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Oct 10 21:17:25 2022 +0000

description:
make: change return type of unlink_file back to int

As unlink_file is a wrapper around unlink, use the same encoding for the
possible return values as in the wrapped function.  This consistency is
more important than expressing all possible return values in the return
type 'bool'.

https://mail-index.netbsd.org/tech-toolchain/2022/10/06/msg004155.html

No functional change.

diffstat:

 usr.bin/make/compat.c |   6 +++---
 usr.bin/make/job.c    |   6 +++---
 usr.bin/make/main.c   |  12 ++++++------
 usr.bin/make/make.h   |   4 ++--
 4 files changed, 14 insertions(+), 14 deletions(-)

diffs (118 lines):

diff -r 3f9610e47ac6 -r 1d950d87731f usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Mon Oct 10 18:30:28 2022 +0000
+++ b/usr.bin/make/compat.c     Mon Oct 10 21:17:25 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.241 2022/08/17 20:10:29 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.242 2022/10/10 21:17:25 rillig Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "pathnames.h"
 
 /*     "@(#)compat.c   8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.241 2022/08/17 20:10:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.242 2022/10/10 21:17:25 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -107,7 +107,7 @@
        if (gn != NULL && !GNode_IsPrecious(gn)) {
                const char *file = GNode_VarTarget(gn);
 
-               if (!opts.noExecute && unlink_file(file)) {
+               if (!opts.noExecute && unlink_file(file) == 0) {
                        Error("*** %s removed", file);
                }
        }
diff -r 3f9610e47ac6 -r 1d950d87731f usr.bin/make/job.c
--- a/usr.bin/make/job.c        Mon Oct 10 18:30:28 2022 +0000
+++ b/usr.bin/make/job.c        Mon Oct 10 21:17:25 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.455 2022/09/03 08:41:07 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.456 2022/10/10 21:17:25 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.455 2022/09/03 08:41:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.456 2022/10/10 21:17:25 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -512,7 +512,7 @@
                return;
 
        file = GNode_Path(gn);
-       if (unlink_file(file))
+       if (unlink_file(file) == 0)
                Error("*** %s removed", file);
 }
 
diff -r 3f9610e47ac6 -r 1d950d87731f usr.bin/make/main.c
--- a/usr.bin/make/main.c       Mon Oct 10 18:30:28 2022 +0000
+++ b/usr.bin/make/main.c       Mon Oct 10 21:17:25 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.584 2022/10/10 17:33:35 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.585 2022/10/10 21:17:25 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.584 2022/10/10 17:33:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.585 2022/10/10 21:17:25 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -1881,13 +1881,13 @@
        Fatal("%d error%s", errs, errs == 1 ? "" : "s");
 }
 
-bool
+int
 unlink_file(const char *file)
 {
        struct stat st;
 
        if (lstat(file, &st) == -1)
-               return false;
+               return -1;
 
        if (S_ISDIR(st.st_mode)) {
                /*
@@ -1895,9 +1895,9 @@
                 * a directory unless [...]".
                 */
                errno = EISDIR;
-               return false;
+               return -1;
        }
-       return unlink(file) == 0;
+       return unlink(file);
 }
 
 static void
diff -r 3f9610e47ac6 -r 1d950d87731f usr.bin/make/make.h
--- a/usr.bin/make/make.h       Mon Oct 10 18:30:28 2022 +0000
+++ b/usr.bin/make/make.h       Mon Oct 10 21:17:25 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.307 2022/09/24 16:13:48 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.308 2022/10/10 21:17:25 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -842,7 +842,7 @@
 void Punt(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
 void DieHorribly(void) MAKE_ATTR_DEAD;
 void Finish(int) MAKE_ATTR_DEAD;
-bool unlink_file(const char *) MAKE_ATTR_USE;
+int unlink_file(const char *) MAKE_ATTR_USE;
 void execDie(const char *, const char *);
 char *getTmpdir(void) MAKE_ATTR_USE;
 bool ParseBoolean(const char *, bool) MAKE_ATTR_USE;



Home | Main Index | Thread Index | Old Index