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.
This commit is contained in:
rillig 2022-10-10 21:17:25 +00:00
parent 5ac7ebbd37
commit a0a05d5e84
4 changed files with 14 additions and 14 deletions

View File

@ -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 @@ CompatDeleteTarget(GNode *gn)
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);
}
}

View File

@ -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 @@ JobDeleteTarget(GNode *gn)
return;
file = GNode_Path(gn);
if (unlink_file(file))
if (unlink_file(file) == 0)
Error("*** %s removed", file);
}

View File

@ -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 @@ Finish(int errs)
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 @@ unlink_file(const char *file)
* a directory unless [...]".
*/
errno = EISDIR;
return false;
return -1;
}
return unlink(file) == 0;
return unlink(file);
}
static void

View File

@ -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 Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
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;