Module Name: src
Committed By: rillig
Date: Mon Oct 5 19:56:08 UTC 2020
Modified Files:
src/usr.bin/make: cond.c
Log Message:
make(1): make cond.c ready for WARNS=6
To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 src/usr.bin/make/cond.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.160 src/usr.bin/make/cond.c:1.161
--- src/usr.bin/make/cond.c:1.160 Mon Oct 5 19:27:47 2020
+++ src/usr.bin/make/cond.c Mon Oct 5 19:56:08 2020
@@ -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 @@ CondParser_SkipWhitespace(CondParser *pa
* 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 @@ ParseFuncArg(const char **pp, Boolean do
/* 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 @@ CondFindStrMatch(const void *string, con
/* 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 @@ FuncExists(int argLen MAKE_ATTR_UNUSED,
/* 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 @@ FuncTarget(int argLen MAKE_ATTR_UNUSED,
/* 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 @@ static const struct If {
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 @@ done:
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 @@ ParseEmptyArg(const char **linePtr, Bool
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 @@ ParseEmptyArg(const char **linePtr, Bool
}
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 @@ CondParser_Func(CondParser *par, Boolean
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 @@ CondParser_Func(CondParser *par, Boolean
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 @@ CondParser_Func(CondParser *par, Boolean
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);