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(1): make cond.c ready for WARNS=6
details: https://anonhg.NetBSD.org/src/rev/60d94b05ed4c
branches: trunk
changeset: 940204:60d94b05ed4c
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Oct 05 19:56:08 2020 +0000
description:
make(1): make cond.c ready for WARNS=6
diffstat:
usr.bin/make/cond.c | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diffs (146 lines):
diff -r 326260c23862 -r 60d94b05ed4c usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Mon Oct 05 19:39:30 2020 +0000
+++ b/usr.bin/make/cond.c Mon Oct 05 19:56:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.160 2020/10/05 19:27:47 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.161 2020/10/05 19:56:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.160 2020/10/05 19:27:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.161 2020/10/05 19:56:08 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -201,7 +201,7 @@
* whether the parsed argument is passed to the default function.
*
* Return the length of the argument. */
-static int
+static size_t
ParseFuncArg(const char **pp, Boolean doEval, const char *func,
char **out_arg) {
const char *p = *pp;
@@ -280,7 +280,7 @@
/* Test whether the given variable is defined. */
static Boolean
-FuncDefined(int argLen MAKE_ATTR_UNUSED, const char *arg)
+FuncDefined(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
{
char *freeIt;
Boolean result = Var_Value(arg, VAR_CMD, &freeIt) != NULL;
@@ -297,14 +297,14 @@
/* See if the given target is being made. */
static Boolean
-FuncMake(int argLen MAKE_ATTR_UNUSED, const char *arg)
+FuncMake(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
{
return Lst_Find(create, CondFindStrMatch, arg) != NULL;
}
/* See if the given file exists. */
static Boolean
-FuncExists(int argLen MAKE_ATTR_UNUSED, const char *arg)
+FuncExists(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
{
Boolean result;
char *path;
@@ -322,7 +322,7 @@
/* See if the given node exists and is an actual target. */
static Boolean
-FuncTarget(int argLen MAKE_ATTR_UNUSED, const char *arg)
+FuncTarget(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
{
GNode *gn = Targ_FindNode(arg);
return gn != NULL && !OP_NOP(gn->type);
@@ -331,7 +331,7 @@
/* See if the given node exists and is an actual target with commands
* associated with it. */
static Boolean
-FuncCommands(int argLen MAKE_ATTR_UNUSED, const char *arg)
+FuncCommands(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
{
GNode *gn = Targ_FindNode(arg);
return gn != NULL && !OP_NOP(gn->type) && !Lst_IsEmpty(gn->commands);
@@ -507,7 +507,7 @@
const char *form; /* Form of if */
size_t formlen; /* Length of form */
Boolean doNot; /* TRUE if default function should be negated */
- Boolean (*defProc)(int, const char *); /* Default function to apply */
+ Boolean (*defProc)(size_t, const char *); /* Default function to apply */
} ifs[] = {
{ "def", 3, FALSE, FuncDefined },
{ "ndef", 4, TRUE, FuncDefined },
@@ -673,13 +673,13 @@
return t;
}
-static int
+static size_t
ParseEmptyArg(const char **linePtr, Boolean doEval,
const char *func MAKE_ATTR_UNUSED, char **argPtr)
{
void *val_freeIt;
const char *val;
- int magic_res;
+ size_t magic_res;
/* We do all the work here and return the result as the length */
*argPtr = NULL;
@@ -692,7 +692,7 @@
if (val == var_Error) {
free(val_freeIt);
- return -1;
+ return (size_t)-1;
}
/* A variable is empty when it just contains spaces... 4/15/92, christos */
@@ -708,7 +708,7 @@
}
static Boolean
-FuncEmpty(int arglen, const char *arg MAKE_ATTR_UNUSED)
+FuncEmpty(size_t arglen, const char *arg MAKE_ATTR_UNUSED)
{
/* Magic values ahead, see ParseEmptyArg. */
return arglen == 1;
@@ -720,8 +720,8 @@
static const struct fn_def {
const char *fn_name;
size_t fn_name_len;
- int (*fn_parse)(const char **, Boolean, const char *, char **);
- Boolean (*fn_eval)(int, const char *);
+ size_t (*fn_parse)(const char **, Boolean, const char *, char **);
+ Boolean (*fn_eval)(size_t, const char *);
} fn_defs[] = {
{ "defined", 7, ParseFuncArg, FuncDefined },
{ "make", 4, ParseFuncArg, FuncMake },
@@ -734,7 +734,7 @@
const struct fn_def *fn_def;
Token t;
char *arg = NULL;
- int arglen;
+ size_t arglen;
const char *cp = par->p;
const char *cp1;
@@ -748,9 +748,9 @@
break;
arglen = fn_def->fn_parse(&cp, doEval, fn_def->fn_name, &arg);
- if (arglen <= 0) {
+ if (arglen == 0 || arglen == (size_t)-1) {
par->p = cp;
- return arglen < 0 ? TOK_ERROR : TOK_FALSE;
+ return arglen == 0 ? TOK_FALSE : TOK_ERROR;
}
/* Evaluate the argument using the required function. */
t = !doEval || fn_def->fn_eval(arglen, arg);
Home |
Main Index |
Thread Index |
Old Index