- use pid_t/size_t as appropriate instead of int.

- use %ld to print pids.
- fix a bit of lint.
- WARNS=4
This commit is contained in:
christos 2008-02-14 22:11:20 +00:00
parent 377f098ab0
commit 2b28370627
24 changed files with 362 additions and 314 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.42 2007/09/25 21:28:26 uwe Exp $
# $NetBSD: Makefile,v 1.43 2008/02/14 22:11:20 christos Exp $
# @(#)Makefile 5.2 (Berkeley) 12/28/90
PROG= make
@ -12,7 +12,7 @@ SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \
SRCS += lstPrev.c
.PATH: ${.CURDIR}/lst.lib
WARNS=3
WARNS=4
.if make(install)
SUBDIR= PSD.doc
.endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: arch.c,v 1.53 2006/10/27 21:00:18 dsl Exp $ */
/* $NetBSD: arch.c,v 1.54 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: arch.c,v 1.53 2006/10/27 21:00:18 dsl Exp $";
static char rcsid[] = "$NetBSD: arch.c,v 1.54 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: arch.c,v 1.53 2006/10/27 21:00:18 dsl Exp $");
__RCSID("$NetBSD: arch.c,v 1.54 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -257,7 +257,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
* Variable spec, so call the Var module to parse the puppy
* so we can safely advance beyond it...
*/
int length;
size_t length;
void *freeIt;
char *result;
@ -298,7 +298,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
* Variable spec, so call the Var module to parse the puppy
* so we can safely advance beyond it...
*/
int length;
size_t length;
void *freeIt;
char *result;
@ -526,7 +526,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
{
#define AR_MAX_NAME_LEN (sizeof(arh.ar_name)-1)
FILE * arch; /* Stream to archive */
int size; /* Size of archive member */
size_t size; /* Size of archive member */
char *cp; /* Useful character pointer */
char magic[SARMAG];
LstNode ln; /* Lst member containing archive descriptor */
@ -617,7 +617,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
Hash_InitTable(&ar->members, -1);
memName[AR_MAX_NAME_LEN] = '\0';
while (fread((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) {
while (fread(&arh, sizeof(struct ar_hdr), 1, arch) == 1) {
if (strncmp( arh.ar_fmag, ARFMAG, sizeof(arh.ar_fmag)) != 0) {
/*
* The header is bogus, so the archive is bad
@ -632,7 +632,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
* 'size' field of the header and round it up during the seek.
*/
arh.ar_size[sizeof(arh.ar_size)-1] = '\0';
size = (int)strtol(arh.ar_size, NULL, 10);
size = (size_t)strtol(arh.ar_size, NULL, 10);
(void)strncpy(memName, arh.ar_name, sizeof(arh.ar_name));
for (cp = &memName[AR_MAX_NAME_LEN]; *cp == ' '; cp--) {
@ -671,11 +671,11 @@ ArchStatMember(char *archive, char *member, Boolean hash)
if (strncmp(memName, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 &&
isdigit((unsigned char)memName[sizeof(AR_EFMT1) - 1])) {
unsigned int elen = atoi(&memName[sizeof(AR_EFMT1)-1]);
long elen = atol(&memName[sizeof(AR_EFMT1)-1]);
if (elen > MAXPATHLEN)
goto badarch;
if (fread(memName, elen, 1, arch) != 1)
if (fread(memName, (size_t)elen, (size_t)1, arch) != 1)
goto badarch;
memName[elen] = '\0';
fseek(arch, -elen, SEEK_CUR);
@ -689,7 +689,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
Hash_SetValue(he, emalloc(sizeof(struct ar_hdr)));
memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr));
}
fseek(arch, (size + 1) & ~1, SEEK_CUR);
fseek(arch, (long)((size + 1) & ~1), SEEK_CUR);
}
fclose(arch);
@ -883,7 +883,7 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
tlen = sizeof(arhPtr->ar_name);
}
while (fread((char *)arhPtr, sizeof(struct ar_hdr), 1, arch) == 1) {
while (fread(arhPtr, sizeof(struct ar_hdr), 1, arch) == 1) {
if (strncmp(arhPtr->ar_fmag, ARFMAG, sizeof(arhPtr->ar_fmag) ) != 0) {
/*
* The header is bogus, so the archive is bad
@ -909,7 +909,7 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
* the file at the actual member, rather than its header, but
* not here...
*/
fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR);
fseek(arch, -(long)sizeof(struct ar_hdr), SEEK_CUR);
return (arch);
}
} else
@ -922,27 +922,29 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
sizeof(AR_EFMT1) - 1) == 0 &&
isdigit((unsigned char)arhPtr->ar_name[sizeof(AR_EFMT1) - 1])) {
unsigned int elen = atoi(&arhPtr->ar_name[sizeof(AR_EFMT1)-1]);
long elen = atol(&arhPtr->ar_name[sizeof(AR_EFMT1)-1]);
char ename[MAXPATHLEN + 1];
if (elen > MAXPATHLEN) {
fclose(arch);
return NULL;
}
if (fread(ename, elen, 1, arch) != 1) {
if (fread(ename, (size_t)elen, (size_t)1, arch) != 1) {
fclose(arch);
return NULL;
}
ename[elen] = '\0';
if (DEBUG(ARCH) || DEBUG(MAKE)) {
fprintf(debug_file, "ArchFind: Extended format entry for %s\n", ename);
(void)fprintf(debug_file,
"ArchFind: Extended format entry for %s\n", ename);
}
if (strncmp(ename, member, len) == 0) {
/* Found as extended name */
fseek(arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR);
(void)fseek(arch, (long)(-sizeof(struct ar_hdr) - elen),
SEEK_CUR);
return (arch);
}
fseek(arch, -elen, SEEK_CUR);
(void)fseek(arch, -elen, SEEK_CUR);
goto skip;
} else
#endif
@ -956,8 +958,8 @@ skip:
* header and round it up during the seek.
*/
arhPtr->ar_size[sizeof(arhPtr->ar_size)-1] = '\0';
size = (int)strtol(arhPtr->ar_size, NULL, 10);
fseek(arch, (size + 1) & ~1, SEEK_CUR);
size = (size_t)strtol(arhPtr->ar_size, NULL, 10);
(void)fseek(arch, (long)((size + 1) & ~1), SEEK_CUR);
}
}
@ -1001,11 +1003,11 @@ Arch_Touch(GNode *gn)
free(p1);
if (p2)
free(p2);
snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
(void)snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
if (arch != NULL) {
(void)fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch);
fclose(arch);
(void)fwrite(&arh, sizeof(struct ar_hdr), 1, arch);
(void)fclose(arch);
}
}
@ -1029,6 +1031,7 @@ Arch_Touch(GNode *gn)
*/
void
#if !defined(RANLIBMAG)
/*ARGSUSED*/
Arch_TouchLib(GNode *gn __unused)
#else
Arch_TouchLib(GNode *gn)
@ -1135,8 +1138,9 @@ Arch_MemMTime(GNode *gn)
nameEnd = strchr(nameStart, ')');
if ((pgn->flags & REMAKE) &&
strncmp(nameStart, gn->name, nameEnd - nameStart) == 0) {
gn->mtime = Arch_MTime(pgn);
strncmp(nameStart, gn->name,
(size_t)(nameEnd - nameStart)) == 0) {
gn->mtime = Arch_MTime(pgn);
}
} else if (pgn->flags & REMAKE) {
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: buf.c,v 1.19 2005/08/08 16:42:54 christos Exp $ */
/* $NetBSD: buf.c,v 1.20 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: buf.c,v 1.19 2005/08/08 16:42:54 christos Exp $";
static char rcsid[] = "$NetBSD: buf.c,v 1.20 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: buf.c,v 1.19 2005/08/08 16:42:54 christos Exp $");
__RCSID("$NetBSD: buf.c,v 1.20 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -104,7 +104,7 @@ __RCSID("$NetBSD: buf.c,v 1.19 2005/08/08 16:42:54 christos Exp $");
*/
#define BufExpand(bp,nb) \
while (bp->left < (nb)+1) {\
int newSize = (bp)->size * 2; \
size_t newSize = (bp)->size * 2; \
Byte *newBuf = (Byte *)erealloc((bp)->buffer, newSize); \
\
(bp)->inPtr = newBuf + ((bp)->inPtr - (bp)->buffer); \
@ -132,7 +132,7 @@ __RCSID("$NetBSD: buf.c,v 1.19 2005/08/08 16:42:54 christos Exp $");
void
Buf_OvAddByte(Buffer bp, int byte)
{
int nbytes = 1;
size_t nbytes = 1;
bp->left = 0;
BufExpand(bp, nbytes);
@ -159,12 +159,12 @@ Buf_OvAddByte(Buffer bp, int byte)
*-----------------------------------------------------------------------
*/
void
Buf_AddBytes(Buffer bp, int numBytes, const Byte *bytesPtr)
Buf_AddBytes(Buffer bp, size_t numBytes, const Byte *bytesPtr)
{
BufExpand(bp, numBytes);
memcpy(bp->inPtr, bytesPtr, numBytes);
(void)memcpy(bp->inPtr, bytesPtr, numBytes);
bp->inPtr += numBytes;
bp->left -= numBytes;
@ -188,7 +188,7 @@ Buf_AddBytes(Buffer bp, int numBytes, const Byte *bytesPtr)
*-----------------------------------------------------------------------
*/
Byte *
Buf_GetAll(Buffer bp, int *numBytesPtr)
Buf_GetAll(Buffer bp, size_t *numBytesPtr)
{
if (numBytesPtr != NULL) {
@ -212,7 +212,7 @@ Buf_GetAll(Buffer bp, int *numBytesPtr)
*-----------------------------------------------------------------------
*/
void
Buf_Discard(Buffer bp, int numBytes)
Buf_Discard(Buffer bp, size_t numBytes)
{
if (bp->inPtr - bp->outPtr <= numBytes) {
@ -238,10 +238,10 @@ Buf_Discard(Buffer bp, int numBytes)
*
*-----------------------------------------------------------------------
*/
int
size_t
Buf_Size(Buffer buf)
{
return (buf->inPtr - buf->outPtr);
return (size_t)(buf->inPtr - buf->outPtr);
}
/*-
@ -263,13 +263,13 @@ Buf_Size(Buffer buf)
*-----------------------------------------------------------------------
*/
Buffer
Buf_Init(int size)
Buf_Init(size_t size)
{
Buffer bp; /* New Buffer */
bp = emalloc(sizeof(*bp));
if (size <= 0) {
if (size == 0) {
size = BUF_DEF_SIZE;
}
bp->left = bp->size = size;
@ -307,6 +307,7 @@ Buf_Destroy(Buffer buf, Boolean freeData)
free(buf);
}
#ifdef notdef
/*-
*-----------------------------------------------------------------------
* Buf_ReplaceLastByte --
@ -333,3 +334,4 @@ Buf_ReplaceLastByte(Buffer buf, int byte)
else
*(buf->inPtr - 1) = byte;
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: buf.h,v 1.10 2003/08/07 11:14:48 agc Exp $ */
/* $NetBSD: buf.h,v 1.11 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -85,8 +85,8 @@
typedef char Byte;
typedef struct Buffer {
int size; /* Current size of the buffer */
int left; /* Space left (== size - (inPtr - buffer)) */
size_t size; /* Current size of the buffer */
size_t left; /* Space left (== size - (inPtr - buffer)) */
Byte *buffer; /* The buffer itself */
Byte *inPtr; /* Place to write to */
Byte *outPtr; /* Place to read from */
@ -94,18 +94,21 @@ typedef struct Buffer {
/* Buf_AddByte adds a single byte to a buffer. */
#define Buf_AddByte(bp, byte) \
(void) (--(bp)->left <= 0 ? Buf_OvAddByte(bp, byte), 1 : \
/*LINTED*/ \
(void)(--(bp)->left == 0 ? Buf_OvAddByte(bp, byte), 1 : \
(*(bp)->inPtr++ = (byte), *(bp)->inPtr = 0), 1)
#define BUF_ERROR 256
void Buf_OvAddByte(Buffer, int);
void Buf_AddBytes(Buffer, int, const Byte *);
Byte *Buf_GetAll(Buffer, int *);
void Buf_Discard(Buffer, int);
int Buf_Size(Buffer);
Buffer Buf_Init(int);
void Buf_AddBytes(Buffer, size_t, const Byte *);
Byte *Buf_GetAll(Buffer, size_t *);
void Buf_Discard(Buffer, size_t);
size_t Buf_Size(Buffer);
Buffer Buf_Init(size_t);
void Buf_Destroy(Buffer, Boolean);
#ifdef notdef
void Buf_ReplaceLastByte(Buffer, int);
#endif
#endif /* _BUF_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.69 2008/01/19 06:52:13 sjg Exp $ */
/* $NetBSD: compat.c,v 1.70 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: compat.c,v 1.69 2008/01/19 06:52:13 sjg Exp $";
static char rcsid[] = "$NetBSD: compat.c,v 1.70 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: compat.c,v 1.69 2008/01/19 06:52:13 sjg Exp $");
__RCSID("$NetBSD: compat.c,v 1.70 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -211,12 +211,12 @@ CompatRunCommand(ClientData cmdp, ClientData gnp)
volatile Boolean errCheck; /* Check errors */
int reason; /* Reason for child's death */
int status; /* Description of child's death */
int cpid; /* Child actually found */
ReturnStatus retstat; /* Status of fork */
pid_t cpid; /* Child actually found */
pid_t retstat; /* Status of fork */
LstNode cmdNode; /* Node where current command is located */
const char ** volatile av; /* Argument vector for thing to exec */
char ** volatile mav;/* Copy of the argument vector for freeing */
int argc; /* Number of arguments in av or 0 if not
size_t argc; /* Number of arguments in av or 0 if not
* dynamically allocated */
Boolean local; /* TRUE if command should be executed
* locally */
@ -371,7 +371,7 @@ CompatRunCommand(ClientData cmdp, ClientData gnp)
/*
* The child is off and running. Now all we can do is wait...
*/
while (1) {
for (;;) {
while ((retstat = wait(&reason)) != cpid) {
if (retstat == -1 && errno != EINTR) {
@ -545,7 +545,7 @@ Compat_Make(ClientData gnp, ClientData pgnp)
Lst_ForEach(gn->commands, CompatRunCommand, gn);
curTarg = NILGNODE;
} else {
Job_Touch(gn, gn->type & OP_SILENT);
Job_Touch(gn, (gn->type & OP_SILENT) != 0);
}
} else {
gn->made = ERROR;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cond.c,v 1.39 2008/02/07 00:49:38 joerg Exp $ */
/* $NetBSD: cond.c,v 1.40 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: cond.c,v 1.39 2008/02/07 00:49:38 joerg Exp $";
static char rcsid[] = "$NetBSD: cond.c,v 1.40 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: cond.c,v 1.39 2008/02/07 00:49:38 joerg Exp $");
__RCSID("$NetBSD: cond.c,v 1.40 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -154,7 +154,7 @@ static Token CondE(Boolean);
static const struct If {
const char *form; /* Form of if */
int formlen; /* Length of form */
size_t formlen; /* Length of form */
Boolean doNot; /* TRUE if default function should be negated */
Boolean (*defProc)(int, char *); /* Default function to apply */
} ifs[] = {
@ -225,7 +225,7 @@ static int
CondGetArg(char **linePtr, char **argPtr, const char *func, Boolean parens)
{
char *cp;
int argLen;
size_t argLen;
Buffer buf;
cp = *linePtr;
@ -268,7 +268,7 @@ CondGetArg(char **linePtr, char **argPtr, const char *func, Boolean parens)
* though perhaps we should...
*/
char *cp2;
int len;
size_t len;
void *freeIt;
cp2 = Var_Parse(cp, VAR_CMD, TRUE, &len, &freeIt);
@ -554,7 +554,7 @@ CondGetString(Boolean doEval, Boolean *quoted, void **freeIt)
Buffer buf;
char *cp;
char *str;
int len;
size_t len;
int qt;
char *start;
@ -903,7 +903,8 @@ error:
* Use Var_Parse to parse the spec in parens and return
* True if the resulting string is empty.
*/
int did_warn, length;
int did_warn;
size_t length;
void *freeIt;
char *val;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.53 2007/01/01 21:31:51 dsl Exp $ */
/* $NetBSD: dir.c,v 1.54 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: dir.c,v 1.53 2007/01/01 21:31:51 dsl Exp $";
static char rcsid[] = "$NetBSD: dir.c,v 1.54 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: dir.c,v 1.53 2007/01/01 21:31:51 dsl Exp $");
__RCSID("$NetBSD: dir.c,v 1.54 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -296,7 +296,7 @@ Dir_InitCur(const char *cdname)
* Our build directory is not the same as our source directory.
* Keep this one around too.
*/
if ((p = Dir_AddDir(NULL, cdname))) {
if ((p = Dir_AddDir(NULL, cdname)) != NULL) {
p->refCount += 1;
if (cur && cur != p) {
/*
@ -592,7 +592,7 @@ DirExpandCurly(const char *word, const char *brace, Lst path, Lst expansions)
* right brace when this is 0, we've hit the
* end of the clause. */
char *file; /* Current expansion */
int otherLen; /* The length of the other pieces of the
size_t otherLen; /* The length of the other pieces of the
* expansion (chars before and after the
* clause in 'word') */
char *cp2; /* Pointer for checking for wildcards in
@ -635,14 +635,14 @@ DirExpandCurly(const char *word, const char *brace, Lst path, Lst expansions)
/*
* Allocate room for the combination and install the three pieces.
*/
file = emalloc(otherLen + cp - start + 1);
file = emalloc((size_t)(otherLen + cp - start + 1));
if (brace != word) {
strncpy(file, word, brace-word);
(void)strncpy(file, word, (size_t)(brace-word));
}
if (cp != start) {
strncpy(&file[brace-word], start, cp-start);
strncpy(&file[brace-word], start, (size_t)(cp-start));
}
strcpy(&file[(brace-word)+(cp-start)], end);
(void)strcpy(&file[(brace-word)+(cp-start)], end);
/*
* See if the result has any wildcards in it. If we find one, call
@ -860,6 +860,7 @@ Dir_Expand(const char *word, Lst path, Lst expansions)
*-----------------------------------------------------------------------
*/
static char *
/*ARGSUSED*/
DirLookup(Path *p, const char *name __unused, const char *cp,
Boolean hasSlash __unused)
{
@ -1002,6 +1003,7 @@ DirLookupAbs(Path *p, const char *name, const char *cp)
*-----------------------------------------------------------------------
*/
static char *
/*ARGSUSED*/
DirFindDot(Boolean hasSlash __unused, const char *name, const char *cp)
{
@ -1338,7 +1340,7 @@ Dir_FindFile(const char *name, Lst path)
*-----------------------------------------------------------------------
*/
int
Dir_FindHereOrAbove(char *here, char *search_path, char *result, int rlen) {
Dir_FindHereOrAbove(char *here, char *search_path, char *result, size_t rlen) {
struct stat st;
char dirbase[MAXPATHLEN + 1], *db_end;
@ -1349,10 +1351,10 @@ Dir_FindHereOrAbove(char *here, char *search_path, char *result, int rlen) {
db_end = dirbase + strlen(dirbase);
/* loop until we determine a result */
while (1) {
for (;;) {
/* try and stat(2) it ... */
snprintf(try, sizeof(try), "%s/%s", dirbase, search_path);
(void)snprintf(try, sizeof(try), "%s/%s", dirbase, search_path);
if (stat(try, &st) != -1) {
/*
* success! if we found a file, chop off

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.h,v 1.11 2004/02/03 19:25:29 chuck Exp $ */
/* $NetBSD: dir.h,v 1.12 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -94,7 +94,7 @@ void Dir_SetPATH(void);
Boolean Dir_HasWildcards(char *);
void Dir_Expand(const char *, Lst, Lst);
char *Dir_FindFile(const char *, Lst);
int Dir_FindHereOrAbove(char *, char *, char *, int);
int Dir_FindHereOrAbove(char *, char *, char *, size_t);
int Dir_MTime(GNode *);
Path *Dir_AddDir(Lst, const char *);
char *Dir_MakeFlags(const char *, Lst);

View File

@ -1,4 +1,4 @@
/* $NetBSD: for.c,v 1.26 2007/01/01 21:31:51 dsl Exp $ */
/* $NetBSD: for.c,v 1.27 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@ -30,14 +30,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: for.c,v 1.26 2007/01/01 21:31:51 dsl Exp $";
static char rcsid[] = "$NetBSD: for.c,v 1.27 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: for.c,v 1.26 2007/01/01 21:31:51 dsl Exp $");
__RCSID("$NetBSD: for.c,v 1.27 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -110,7 +110,7 @@ static void
ForAddVar(const char *data, size_t len)
{
Buffer buf;
int varlen;
size_t varlen;
buf = Buf_Init(0);
Buf_AddBytes(buf, len, (Byte *)UNCONST(data));
@ -154,7 +154,7 @@ For_Eval(char *line)
if (forLevel == 0) {
Buffer buf;
int varlen;
size_t varlen;
static const char instr[] = "in";
for (ptr++; *ptr && isspace((unsigned char) *ptr); ptr++)
@ -197,7 +197,7 @@ For_Eval(char *line)
wrd = ptr;
while (*ptr && !isspace((unsigned char) *ptr))
ptr++;
ForAddVar(wrd, ptr - wrd);
ForAddVar(wrd, (size_t)(ptr - wrd));
while (*ptr && isspace((unsigned char) *ptr))
ptr++;
}
@ -226,10 +226,10 @@ For_Eval(char *line)
sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE);
#define ADDWORD() \
Buf_AddBytes(buf, ptr - wrd, (Byte *)wrd), \
(void)(Buf_AddBytes(buf, (size_t)(ptr - wrd), (Byte *)wrd), \
Buf_AddByte(buf, (Byte)'\0'), \
Lst_AtFront(accumFor.lst, Buf_GetAll(buf, &varlen)), \
Buf_Destroy(buf, FALSE)
Buf_Destroy(buf, FALSE))
for (ptr = sub; *ptr && isspace((unsigned char) *ptr); ptr++)
continue;
@ -310,7 +310,8 @@ For_Run(int lineno)
For arg;
LstNode ln;
char **values;
int i, done = 0, len;
int i, done = 0;
size_t len;
char *guy, *orig_guy, *old_guy;
if (accumFor.buf == NULL || accumFor.vars == NULL || accumFor.lst == NULL)

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.135 2008/01/19 06:52:14 sjg Exp $ */
/* $NetBSD: job.c,v 1.136 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: job.c,v 1.135 2008/01/19 06:52:14 sjg Exp $";
static char rcsid[] = "$NetBSD: job.c,v 1.136 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: job.c,v 1.135 2008/01/19 06:52:14 sjg Exp $");
__RCSID("$NetBSD: job.c,v 1.136 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -171,13 +171,12 @@ static int aborting = 0; /* why is the make aborting? */
* this tracks the number of tokens currently "out" to build jobs.
*/
int jobTokensRunning = 0;
int not_parallel = 0; /* set if .NOT_PARALLEL */
/*
* XXX: Avoid SunOS bug... FILENO() is fp->_file, and file
* is a char! So when we go above 127 we turn negative!
*/
#define FILENO(a) ((unsigned) fileno(a))
#define FILENO(a) ((int)(unsigned)fileno(a))
/*
* post-make command processing. The node postCommands is really just the
@ -314,7 +313,7 @@ static int make_suspended = 0; /* non-zero if we've seen a SIGTSTP (etc) */
*/
static struct pollfd *fds = NULL;
static Job **jobfds = NULL;
static int nfds = 0;
static size_t nfds = 0;
static void watchfd(Job *);
static void clearfd(Job *);
static int readyfd(Job *);
@ -361,17 +360,20 @@ static void JobSigLock(sigset_t *);
static void JobSigUnlock(sigset_t *);
static void JobSigReset(void);
const char *malloc_options="A";
#ifdef notdef
const char *_malloc_options = "A";
#endif
static void
job_table_dump(const char *where)
{
Job *job;
fprintf(debug_file, "job table @ %s\n", where);
(void)fprintf(debug_file, "job table @ %s\n", where);
for (job = job_table; job < job_table_end; job++) {
fprintf(debug_file, "job %d, status %d, flags %d, pid %d\n",
(int)(job - job_table), job->job_state, job->flags, job->pid);
(void)fprintf(debug_file, "job %d, status %d, flags %d, pid %ld\n",
(int)(job - job_table), job->job_state, job->flags,
(long)job->pid);
}
}
@ -452,8 +454,8 @@ JobCondPassSig(int signo)
continue;
if (DEBUG(JOB)) {
(void)fprintf(debug_file,
"JobCondPassSig passing signal %d to child %d.\n",
signo, job->pid);
"JobCondPassSig passing signal %d to child %ld.\n",
signo, (long)job->pid);
}
KILLPG(job->pid, signo);
}
@ -477,6 +479,7 @@ JobCondPassSig(int signo)
*-----------------------------------------------------------------------
*/
static void
/*ARGSUSED*/
JobChildSig(int signo __unused)
{
write(childExitJob.outPipe, CHILD_EXIT, 1);
@ -500,6 +503,7 @@ JobChildSig(int signo __unused)
*-----------------------------------------------------------------------
*/
static void
/*ARGSUSED*/
JobContinueSig(int signo __unused)
{
/*
@ -616,7 +620,7 @@ JobPassSig_suspend(int signo)
*-----------------------------------------------------------------------
*/
static Job *
JobFindPid(int pid, int status)
JobFindPid(pid_t pid, int status)
{
Job *job;
@ -960,8 +964,8 @@ JobFinish(Job *job, int status)
Boolean done, return_job_token;
if (DEBUG(JOB)) {
fprintf(debug_file, "Jobfinish: %d [%s], status %d\n",
job->pid, job->node->name, status);
(void)fprintf(debug_file, "Jobfinish: %ld [%s], status %d\n",
(long)job->pid, job->node->name, status);
}
if ((WIFEXITED(status) &&
@ -1008,8 +1012,8 @@ JobFinish(Job *job, int status)
if (done) {
if (WIFEXITED(status)) {
if (DEBUG(JOB)) {
(void)fprintf(debug_file, "Process %d [%s] exited.\n",
job->pid, job->node->name);
(void)fprintf(debug_file, "Process %ld [%s] exited.\n",
(long)job->pid, job->node->name);
}
if (WEXITSTATUS(status) != 0) {
if (job->node != lastNode) {
@ -1223,7 +1227,7 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
static const char msg[] = ": don't know how to make";
if (gn->flags & FROM_DEPEND) {
fprintf(stdout, "%s: ignoring stale .depend for %s\n",
(void)fprintf(stdout, "%s: ignoring stale .depend for %s\n",
progname, gn->name);
return TRUE;
}
@ -1266,7 +1270,7 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
static void
JobExec(Job *job, char **argv)
{
int cpid; /* ID of new child */
pid_t cpid; /* ID of new child */
sigset_t mask;
job->flags &= ~JOB_TRACED;
@ -1397,8 +1401,8 @@ JobExec(Job *job, char **argv)
* Now the job is actually running, add it to the table.
*/
if (DEBUG(JOB)) {
fprintf(debug_file, "JobExec(%s): pid %d added to jobs table\n",
job->node->name, job->pid);
(void)fprintf(debug_file, "JobExec(%s): pid %ld added to jobs table\n",
job->node->name, (long)job->pid);
job_table_dump("job started");
}
JobSigUnlock(&mask);
@ -1747,9 +1751,9 @@ JobDoOutput(Job *job, Boolean finish)
Boolean gotNL = FALSE; /* true if got a newline */
Boolean fbuf; /* true if our buffer filled up */
int nr; /* number of bytes read */
int i; /* auxiliary index into outBuf */
int max; /* limit for i (end of current data) */
int nRead; /* (Temporary) number of bytes read */
size_t i; /* auxiliary index into outBuf */
size_t max; /* limit for i (end of current data) */
ssize_t nRead; /* (Temporary) number of bytes read */
/*
* Read as many bytes as will fit in the buffer.
@ -1759,7 +1763,7 @@ end_loop:
fbuf = FALSE;
nRead = read(job->inPipe, &job->outBuf[job->curPos],
JOB_BUFSIZE - job->curPos);
(size_t)(JOB_BUFSIZE - job->curPos));
if (nRead < 0) {
if (errno == EAGAIN)
return;
@ -1922,9 +1926,9 @@ JobRun(GNode *targ)
void
Job_CatchChildren(void)
{
int pid; /* pid of dead child */
pid_t pid; /* pid of dead child */
Job *job; /* job descriptor for dead child */
int status; /* Exit/termination status */
int status; /* Exit/termination status */
/*
* Don't even bother if we know there's no one around.
@ -1934,20 +1938,21 @@ Job_CatchChildren(void)
while ((pid = waitpid((pid_t) -1, &status, WNOHANG | WUNTRACED)) > 0) {
if (DEBUG(JOB)) {
(void)fprintf(debug_file, "Process %d exited/stopped status %x.\n", pid,
status);
(void)fprintf(debug_file, "Process %ld exited/stopped status %x.\n",
(long)pid, status);
}
job = JobFindPid(pid, JOB_ST_RUNNING);
if (job == NULL) {
if (!lurking_children)
Error("Child (%d) status %x not in table?", pid, status);
Error("Child (%ld) status %x not in table?", (long)pid,
status);
continue;
}
if (WIFSTOPPED(status)) {
if (DEBUG(JOB)) {
(void)fprintf(debug_file, "Process %d (%s) stopped.\n",
job->pid, job->node->name);
(void)fprintf(debug_file, "Process %ld (%s) stopped.\n",
(long)job->pid, job->node->name);
}
if (!make_suspended) {
switch (WSTOPSIG(status)) {
@ -2311,7 +2316,7 @@ Job_ParseShell(char *line)
{
char **words;
char **argv;
int argc;
size_t argc;
char *path;
Shell newShell;
Boolean fullSpec = FALSE;
@ -2494,8 +2499,8 @@ JobInterrupt(int runINTERRUPT, int signo)
if (job->pid) {
if (DEBUG(JOB)) {
(void)fprintf(debug_file,
"JobInterrupt passing signal %d to child %d.\n",
signo, job->pid);
"JobInterrupt passing signal %d to child %ld.\n",
signo, (long)job->pid);
}
KILLPG(job->pid, signo);
}
@ -2651,8 +2656,8 @@ JobRestartJobs(void)
if (job->job_state == JOB_ST_RUNNING &&
(make_suspended || job->job_suspended)) {
if (DEBUG(JOB)) {
(void)fprintf(debug_file, "Restarting stopped job pid %d.\n",
job->pid);
(void)fprintf(debug_file, "Restarting stopped job pid %ld.\n",
(long)job->pid);
}
if (job->job_suspended) {
(void)printf("*** [%s] Continued\n", job->node->name);
@ -2660,7 +2665,8 @@ JobRestartJobs(void)
}
job->job_suspended = 0;
if (KILLPG(job->pid, SIGCONT) != 0 && DEBUG(JOB)) {
fprintf(debug_file, "Failed to send SIGCONT to %d\n", job->pid);
(void)fprintf(debug_file, "Failed to send SIGCONT to %ld\n",
(long)job->pid);
}
}
if (job->job_state == JOB_ST_FINISHED)
@ -2732,8 +2738,8 @@ JobTokenAdd(void)
continue;
if (DEBUG(JOB))
fprintf(debug_file, "(%d) aborting %d, deposit token %c\n",
getpid(), aborting, JOB_TOKENS[aborting]);
(void)fprintf(debug_file, "(%ld) aborting %d, deposit token %c\n",
(long)getpid(), aborting, JOB_TOKENS[aborting]);
write(tokenWaitJob.outPipe, &tok, 1);
}
@ -2821,8 +2827,9 @@ Job_TokenWithdraw(void)
wantToken = 0;
if (DEBUG(JOB))
fprintf(debug_file, "Job_TokenWithdraw(%d): aborting %d, running %d\n",
getpid(), aborting, jobTokensRunning);
(void)fprintf(debug_file,
"Job_TokenWithdraw(%ld): aborting %d, running %d\n",
(long)getpid(), aborting, jobTokensRunning);
if (aborting || (jobTokensRunning >= maxJobs))
return FALSE;
@ -2835,7 +2842,8 @@ Job_TokenWithdraw(void)
Fatal("job pipe read: %s", strerror(errno));
}
if (DEBUG(JOB))
fprintf(debug_file, "(%d) blocked for token\n", getpid());
(void)fprintf(debug_file, "(%ld) blocked for token\n",
(long)getpid());
wantToken = 1;
return FALSE;
}
@ -2843,7 +2851,8 @@ Job_TokenWithdraw(void)
if (count == 1 && tok != '+') {
/* make being abvorted - remove any other job tokens */
if (DEBUG(JOB))
fprintf(debug_file, "(%d) aborted by token %c\n", getpid(), tok);
(void)fprintf(debug_file, "(%ld) aborted by token %c\n",
(long)getpid(), tok);
while (read(tokenWaitJob.inPipe, &tok1, 1) == 1)
continue;
/* And put the stopper back */
@ -2857,7 +2866,7 @@ Job_TokenWithdraw(void)
jobTokensRunning++;
if (DEBUG(JOB))
fprintf(debug_file, "(%d) withdrew token\n", getpid());
(void)fprintf(debug_file, "(%ld) withdrew token\n", (long)getpid());
return TRUE;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.h,v 1.34 2007/10/01 22:14:09 sjg Exp $ */
/* $NetBSD: job.h,v 1.35 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -137,7 +137,7 @@ struct pollfd;
#define JOB_BUFSIZE 1024
typedef struct Job {
int pid; /* The child's process ID */
pid_t pid; /* The child's process ID */
GNode *node; /* The target the child is making */
LstNode tailCmds; /* The node of the first command to be
* saved when the job has been run */
@ -164,7 +164,7 @@ typedef struct Job {
char outBuf[JOB_BUFSIZE + 1];
/* Buffer for storing the output of the
* job, line by line */
int curPos; /* Current position in op_outBuf */
size_t curPos; /* Current position in op_outBuf */
} Job;
#define inPipe jobPipe[0]

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstForEachFrom.c,v 1.13 2006/11/11 21:23:36 dsl Exp $ */
/* $NetBSD: lstForEachFrom.c,v 1.14 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.13 2006/11/11 21:23:36 dsl Exp $";
static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.14 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstForEachFrom.c,v 1.13 2006/11/11 21:23:36 dsl Exp $");
__RCSID("$NetBSD: lstForEachFrom.c,v 1.14 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -115,7 +115,7 @@ Lst_ForEachFrom(Lst l, LstNode ln, int (*proc)(ClientData, ClientData),
}
if (tln->flags & LN_DELETED) {
free((char *)tln);
free(tln);
}
tln = next;
} while (!result && !LstIsEmpty(list) && !done);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstIsAtEnd.c,v 1.11 2006/10/27 21:37:25 dsl Exp $ */
/* $NetBSD: lstIsAtEnd.c,v 1.12 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstIsAtEnd.c,v 1.11 2006/10/27 21:37:25 dsl Exp $";
static char rcsid[] = "$NetBSD: lstIsAtEnd.c,v 1.12 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstIsAtEnd.c,v 1.11 2006/10/27 21:37:25 dsl Exp $");
__RCSID("$NetBSD: lstIsAtEnd.c,v 1.12 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -76,6 +76,7 @@ __RCSID("$NetBSD: lstIsAtEnd.c,v 1.11 2006/10/27 21:37:25 dsl Exp $");
*
*-----------------------------------------------------------------------
*/
#ifdef notdef
Boolean
Lst_IsAtEnd(Lst l)
{
@ -84,4 +85,4 @@ Lst_IsAtEnd(Lst l)
return (!LstValid (l) || !list->isOpen ||
(list->atEnd == Head) || (list->atEnd == Tail));
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.146 2008/01/19 06:52:14 sjg Exp $ */
/* $NetBSD: main.c,v 1.147 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: main.c,v 1.146 2008/01/19 06:52:14 sjg Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.147 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: main.c,v 1.146 2008/01/19 06:52:14 sjg Exp $");
__RCSID("$NetBSD: main.c,v 1.147 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -175,8 +175,8 @@ Boolean varNoExportEnv; /* -X flag */
Boolean doing_depend; /* Set while reading .depend */
static Boolean jobsRunning; /* TRUE if the jobs might be running */
static const char * tracefile;
static char * Check_Cwd_av(int, char **, int);
static void MainParseArgs(int, char **);
static char * Check_Cwd_av(size_t, char **, int);
static void MainParseArgs(size_t, char **);
static int ReadMakefile(ClientData, ClientData);
static void usage(void);
@ -194,7 +194,7 @@ parse_debug_options(const char *argvalue)
const char *modules;
const char *mode;
char *fname;
int len;
size_t len;
for (modules = argvalue; *modules; ++modules) {
switch (*modules) {
@ -278,7 +278,8 @@ parse_debug_options(const char *argvalue)
memcpy(fname, modules, len + 1);
/* Let the filename be modified by the pid */
if (strcmp(fname + len - 3, ".%d") == 0)
snprintf(fname + len - 2, 20, "%d", getpid());
snprintf(fname + len - 2, 20, "%ld",
(long)getpid());
debug_file = fopen(fname, mode);
if (!debug_file) {
fprintf(stderr, "Cannot open debug file %s\n",
@ -313,7 +314,7 @@ parse_debug_options(const char *argvalue)
* given
*/
static void
MainParseArgs(int argc, char **argv)
MainParseArgs(size_t argc, char **argv)
{
char *p;
int c = '?';
@ -575,7 +576,7 @@ void
Main_ParseArgLine(char *line)
{
char **argv; /* Manufactured argument vector */
int argc; /* Number of arguments in argv */
size_t argc; /* Number of arguments in argv */
char *args; /* Space used by the args */
char *buf, *p1;
char *argv0 = Var_Value(".MAKE", VAR_GLOBAL, &p1);
@ -698,7 +699,7 @@ main(int argc, char **argv)
* on each program execution.
*/
gettimeofday(&rightnow, NULL);
srandom(rightnow.tv_sec + rightnow.tv_usec);
srandom((unsigned long)rightnow.tv_sec + rightnow.tv_usec);
if ((progname = strrchr(argv[0], '/')) != NULL)
progname++;
@ -875,9 +876,9 @@ main(int argc, char **argv)
{
char tmp[64];
snprintf(tmp, sizeof(tmp), "%u", getpid());
snprintf(tmp, sizeof(tmp), "%ld", (long)getpid());
Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
snprintf(tmp, sizeof(tmp), "%u", getppid());
snprintf(tmp, sizeof(tmp), "%ld", (long)getppid());
Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0);
}
Job_SetPrefix();
@ -893,7 +894,7 @@ main(int argc, char **argv)
Main_ParseArgLine(getenv("MAKE"));
#endif
MainParseArgs(argc, argv);
MainParseArgs((size_t)argc, argv);
/*
* Be compatible if user did not specify -j and did not explicitly
@ -1154,6 +1155,7 @@ main(int argc, char **argv)
* lots
*/
static int
/*ARGSUSED*/
ReadMakefile(ClientData p, ClientData q __unused)
{
char *fname = p; /* makefile to read */
@ -1246,7 +1248,7 @@ found:
static int Check_Cwd_Off = 0;
static char *
Check_Cwd_av(int ac, char **av, int copy)
Check_Cwd_av(size_t ac, char **av, int copy)
{
static char *make[4];
static char *cur_dir = NULL;
@ -1357,7 +1359,7 @@ Check_Cwd_Cmd(const char *cmd)
{
char *cp, *bp;
char **av;
int ac;
size_t ac;
if (Check_Cwd_Off)
return NULL;
@ -1385,7 +1387,7 @@ void
Check_Cwd(const char **argv)
{
char *cp;
int ac;
size_t ac;
if (Check_Cwd_Off)
return;
@ -1419,13 +1421,14 @@ Cmd_Exec(const char *cmd, const char **errnum)
{
const char *args[4]; /* Args for invoking the shell */
int fds[2]; /* Pipe streams */
int cpid; /* Child PID */
int pid; /* PID from wait() */
pid_t cpid; /* Child PID */
pid_t pid; /* PID from wait() */
char *res; /* result */
int status; /* command exit status */
Buffer buf; /* buffer to store the result */
char *cp;
int cc;
ssize_t cc;
size_t len;
*errnum = NULL;
@ -1488,7 +1491,7 @@ Cmd_Exec(const char *cmd, const char **errnum)
char result[BUFSIZ];
cc = read(fds[0], result, sizeof(result));
if (cc > 0)
Buf_AddBytes(buf, cc, (Byte *)result);
Buf_AddBytes(buf, (size_t)cc, (Byte *)result);
}
while (cc > 0 || (cc == -1 && errno == EINTR));
@ -1503,10 +1506,10 @@ Cmd_Exec(const char *cmd, const char **errnum)
while(((pid = waitpid(cpid, &status, 0)) != cpid) && (pid >= 0))
continue;
res = (char *)Buf_GetAll(buf, &cc);
res = (char *)Buf_GetAll(buf, &len);
Buf_Destroy(buf, FALSE);
if (cc == 0)
if (len == 0)
*errnum = "Couldn't read shell's output for \"%s\"";
if (status)
@ -1799,13 +1802,14 @@ usage(void)
}
#ifdef notdef
int
PrintAddr(ClientData a, ClientData b)
{
printf("%lx ", (unsigned long) a);
return b ? 0 : 0;
}
#endif
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.c,v 1.74 2007/01/01 21:42:42 dsl Exp $ */
/* $NetBSD: make.c,v 1.75 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: make.c,v 1.74 2007/01/01 21:42:42 dsl Exp $";
static char rcsid[] = "$NetBSD: make.c,v 1.75 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: make.c,v 1.74 2007/01/01 21:42:42 dsl Exp $");
__RCSID("$NetBSD: make.c,v 1.75 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -860,6 +860,7 @@ Make_Update(GNode *cgn)
*-----------------------------------------------------------------------
*/
static int
/*ARGSUSED*/
MakeUnmark(ClientData cgnp, ClientData pgnp __unused)
{
GNode *cgn = (GNode *)cgnp;
@ -994,6 +995,7 @@ Make_DoAllVar(GNode *gn)
*/
static int
/*ARGSUSED*/
MakeCheckOrder(ClientData v_bn, ClientData ignore __unused)
{
GNode *bn = v_bn;

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.72 2008/01/19 06:52:15 sjg Exp $ */
/* $NetBSD: make.h,v 1.73 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -154,7 +154,7 @@ typedef struct GNode {
char *name; /* The target's name */
char *uname; /* The unexpanded name of a .USE node */
char *path; /* The full pathname of the file */
int type; /* Its type (see the OP flags, below) */
unsigned int type; /* Its type (see the OP flags, below) */
int flags;
#define REMAKE 0x1 /* this target needs to be (re)made */
@ -210,7 +210,7 @@ typedef struct GNode {
* Suff_FindDeps and opaque to everyone
* but the Suff module) */
const char *fname; /* filename where the GNode got defined */
int lineno; /* line number where the GNode got defined */
size_t lineno; /* line number where the GNode got defined */
} GNode;
/*
@ -460,7 +460,7 @@ Boolean Main_SetObjdir(const char *);
} __d; \
__d.__cp = ptr, __d.__p; })
#else
#define UNCONST(ptr) (void *)(ptr)
#define UNCONST(ptr) (void *)(intptr_t)(ptr)
#endif
#ifndef MIN

View File

@ -1,4 +1,4 @@
/* $NetBSD: nonints.h,v 1.46 2007/10/15 01:07:34 sjg Exp $ */
/* $NetBSD: nonints.h,v 1.47 2008/02/14 22:11:20 christos Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@ -144,11 +144,11 @@ Lst Parse_MainName(void);
/* str.c */
char *str_concat(const char *, const char *, int);
char **brk_string(const char *, int *, Boolean, char **);
char **brk_string(const char *, size_t *, Boolean, char **);
char *Str_FindSubstring(const char *, const char *);
int Str_Match(const char *, const char *);
char *Str_SYSVMatch(const char *, const char *, int *len);
void Str_SYSVSubst(Buffer, char *, char *, int);
char *Str_SYSVMatch(const char *, const char *, size_t *);
void Str_SYSVSubst(Buffer, char *, char *, size_t);
/* suff.c */
void Suff_ClearSuffixes(void);
@ -181,7 +181,7 @@ void Targ_SetMain(GNode *);
int Targ_PrintCmd(ClientData, ClientData);
int Targ_PrintNode(ClientData, ClientData);
char *Targ_FmtTime(time_t);
void Targ_PrintType(int);
void Targ_PrintType(unsigned int);
void Targ_PrintGraph(int);
void Targ_Propagate(void);
void Targ_Propagate_Wait(void);
@ -192,7 +192,7 @@ void Var_Set(const char *, const char *, GNode *, int);
void Var_Append(const char *, const char *, GNode *);
Boolean Var_Exists(const char *, GNode *);
char *Var_Value(const char *, GNode *, char **);
char *Var_Parse(const char *, GNode *, Boolean, int *, void **);
char *Var_Parse(const char *, GNode *, Boolean, size_t *, void **);
char *Var_Subst(const char *, const char *, GNode *, Boolean);
char *Var_GetTail(const char *);
char *Var_GetHead(const char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.143 2008/01/03 22:14:53 dsl Exp $ */
/* $NetBSD: parse.c,v 1.144 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: parse.c,v 1.143 2008/01/03 22:14:53 dsl Exp $";
static char rcsid[] = "$NetBSD: parse.c,v 1.144 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: parse.c,v 1.143 2008/01/03 22:14:53 dsl Exp $");
__RCSID("$NetBSD: parse.c,v 1.144 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -156,13 +156,13 @@ static GNode *mainNode; /* The main target to create. This is the
* line in the first makefile */
typedef struct IFile {
const char *fname; /* name of file */
int lineno; /* line number in file */
size_t lineno; /* line number in file */
int fd; /* the open file */
int cond_depth; /* 'if' nesting when file opened */
size_t cond_depth; /* 'if' nesting when file opened */
char *P_str; /* point to base of string buffer */
char *P_ptr; /* point to next char of string buffer */
char *P_end; /* point to the end of string buffer */
int P_buflen; /* current size of file buffer */
size_t P_buflen; /* current size of file buffer */
} IFile;
#define IFILE_BUFLEN 0x8000
@ -867,11 +867,10 @@ ParseDoDependency(char *line)
* no errors in this, as they would have been discovered
* in the initial Var_Subst and we wouldn't be here.
*/
int length;
size_t length;
void *freeIt;
char *result;
result = Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt);
Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt);
if (freeIt)
free(freeIt);
cp += length-1;
@ -1795,7 +1794,7 @@ Parse_include_file(char *file, Boolean isSystem, int silent)
char *suff;
Lst suffPath = NILLST;
if ((suff = strrchr(file, '.'))) {
if ((suff = strrchr(file, '.')) != NULL) {
suffPath = Suff_GetPath(suff);
if (suffPath != NILLST) {
fullname = Dir_FindFile(file, suffPath);
@ -1909,7 +1908,7 @@ ParseSetParseFile(const char *filename)
{
char *slash;
char *dirname;
int len;
size_t len;
slash = strrchr(filename, '/');
if (slash == NULL) {
@ -1918,7 +1917,7 @@ ParseSetParseFile(const char *filename)
} else {
len = slash - filename;
dirname = emalloc(len + 1);
memcpy(dirname, filename, len);
(void)memcpy(dirname, filename, len);
dirname[len] = 0;
Var_Set(".PARSEDIR", dirname, VAR_GLOBAL, 0);
Var_Set(".PARSEFILE", slash+1, VAR_GLOBAL, 0);
@ -2129,7 +2128,7 @@ ParseEOF(void)
}
if (DEBUG(PARSE))
fprintf(debug_file, "ParseEOF: returning to file %s, line %d, fd %d\n",
fprintf(debug_file, "ParseEOF: returning to file %s, line %zu, fd %d\n",
curFile->fname, curFile->lineno, curFile->fd);
/* Restore the PARSEDIR/PARSEFILE variables */
@ -2151,7 +2150,8 @@ ParseGetLine(int flags, int *length)
char *escaped;
char *comment;
char *tp;
int len, dist;
ssize_t len;
int dist;
/* Loop through blank lines and comment lines */
for (;;) {
@ -2175,7 +2175,7 @@ ParseGetLine(int flags, int *length)
/* Move existing data to (near) start of file buffer */
len = cf->P_end - cf->P_ptr;
tp = cf->P_str + 32;
memmove(tp, cf->P_ptr, len);
(void)memmove(tp, cf->P_ptr, (size_t)len);
dist = cf->P_ptr - tp;
/* Update all pointers to reflect moved data */
ptr -= dist;
@ -2206,7 +2206,7 @@ ParseGetLine(int flags, int *length)
len += IFILE_BUFLEN;
cf->P_buflen += IFILE_BUFLEN;
}
len = read(cf->fd, tp, len);
len = read(cf->fd, tp, (size_t)len);
if (len <= 0) {
if (len < 0) {
Parse_Error(PARSE_FATAL, "Makefile read error: %s",
@ -2456,8 +2456,8 @@ Parse_File(const char *name, int fd)
do {
for (; (line = ParseReadLine()) != NULL; ) {
if (DEBUG(PARSE))
fprintf(debug_file, "ParseReadLine (%d): '%s'\n",
curFile->lineno, line);
(void)fprintf(debug_file, "ParseReadLine (%zu): '%s'\n",
curFile->lineno, line);
if (*line == '.') {
/*
* Lines that begin with the special character are either

View File

@ -1,4 +1,4 @@
/* $NetBSD: str.c,v 1.26 2006/12/22 20:28:31 erh Exp $ */
/* $NetBSD: str.c,v 1.27 2008/02/14 22:11:20 christos Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: str.c,v 1.26 2006/12/22 20:28:31 erh Exp $";
static char rcsid[] = "$NetBSD: str.c,v 1.27 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
#else
__RCSID("$NetBSD: str.c,v 1.26 2006/12/22 20:28:31 erh Exp $");
__RCSID("$NetBSD: str.c,v 1.27 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -94,7 +94,7 @@ __RCSID("$NetBSD: str.c,v 1.26 2006/12/22 20:28:31 erh Exp $");
char *
str_concat(const char *s1, const char *s2, int flags)
{
int len1, len2;
size_t len1, len2;
char *result;
/* get the length of both strings */
@ -102,10 +102,10 @@ str_concat(const char *s1, const char *s2, int flags)
len2 = strlen(s2);
/* allocate length plus separator plus EOS */
result = emalloc((u_int)(len1 + len2 + 2));
result = emalloc(len1 + len2 + 2);
/* copy first string into place */
memcpy(result, s1, len1);
(void)memcpy(result, s1, len1);
/* add separator character */
if (flags & STR_ADDSPACE) {
@ -117,7 +117,7 @@ str_concat(const char *s1, const char *s2, int flags)
}
/* copy second string plus EOS into place */
memcpy(result + len1, s2, len2 + 1);
(void)memcpy(result + len1, s2, len2 + 1);
return(result);
}
@ -138,13 +138,13 @@ str_concat(const char *s1, const char *s2, int flags)
* Number of words in *store_argc.
*/
char **
brk_string(const char *str, int *store_argc, Boolean expand, char **buffer)
brk_string(const char *str, size_t *store_argc, Boolean expand, char **buffer)
{
int argc, ch;
char inquote, *start, *t;
const char *p;
int len;
int argmax = 50, curlen = 0;
size_t len, curlen = 0;
size_t argmax = 50;
char **argv = emalloc((argmax + 1) * sizeof(char *));
/* skip leading space chars. */
@ -419,7 +419,7 @@ thisCharOK: ++pattern;
*-----------------------------------------------------------------------
*/
char *
Str_SYSVMatch(const char *word, const char *pattern, int *len)
Str_SYSVMatch(const char *word, const char *pattern, size_t *len)
{
const char *p = pattern;
const char *w = word;
@ -476,13 +476,13 @@ Str_SYSVMatch(const char *word, const char *pattern, int *len)
*-----------------------------------------------------------------------
*/
void
Str_SYSVSubst(Buffer buf, char *pat, char *src, int len)
Str_SYSVSubst(Buffer buf, char *pat, char *src, size_t len)
{
char *m;
if ((m = strchr(pat, '%')) != NULL) {
/* Copy the prefix */
Buf_AddBytes(buf, m - pat, (Byte *)pat);
Buf_AddBytes(buf, (size_t)(m - pat), (Byte *)pat);
/* skip the % */
pat = m + 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.61 2006/11/17 22:07:39 dsl Exp $ */
/* $NetBSD: suff.c,v 1.62 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: suff.c,v 1.61 2006/11/17 22:07:39 dsl Exp $";
static char rcsid[] = "$NetBSD: suff.c,v 1.62 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
__RCSID("$NetBSD: suff.c,v 1.61 2006/11/17 22:07:39 dsl Exp $");
__RCSID("$NetBSD: suff.c,v 1.62 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -1412,7 +1412,7 @@ SuffFindCmds(Src *targ, Lst slst)
LstNode ln; /* General-purpose list node */
GNode *t, /* Target GNode */
*s; /* Source GNode */
int prefLen;/* The length of the defined prefix */
size_t prefLen;/* The length of the defined prefix */
Suff *suff; /* Suffix on matching beastie */
Src *ret; /* Return value */
char *cp;
@ -1594,7 +1594,7 @@ SuffExpandChildren(LstNode cln, GNode *pgn)
* to find the end so we can skip over it.
*/
char *junk;
int len;
size_t len;
void *freeIt;
junk = Var_Parse(cp, pgn, TRUE, &len, &freeIt);
@ -2067,7 +2067,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
ln = Lst_FindFrom(sufflist, ln, &sd, SuffSuffIsSuffixP);
if (ln != NILLNODE) {
int prefLen; /* Length of the prefix */
size_t prefLen; /* Length of the prefix */
/*
* Allocate a Src structure to which things can be transformed
@ -2089,7 +2089,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
*/
prefLen = (eoname - targ->suff->nameLen) - sopref;
targ->pref = emalloc(prefLen + 1);
memcpy(targ->pref, sopref, prefLen);
(void)memcpy(targ->pref, sopref, prefLen);
targ->pref[prefLen] = '\0';
/*
@ -2576,7 +2576,7 @@ Suff_End(void)
static int SuffPrintName(ClientData s, ClientData dummy)
{
fprintf(debug_file, "%s ", ((Suff *)s)->name);
(void)fprintf(debug_file, "%s ", ((Suff *)s)->name);
return (dummy ? 0 : 0);
}
@ -2587,38 +2587,38 @@ SuffPrintSuff(ClientData sp, ClientData dummy)
int flags;
int flag;
fprintf(debug_file, "# `%s' [%d] ", s->name, s->refCount);
(void)fprintf(debug_file, "# `%s' [%d] ", s->name, s->refCount);
flags = s->flags;
if (flags) {
fputs(" (", debug_file);
(void)fputs(" (", debug_file);
while (flags) {
flag = 1 << (ffs(flags) - 1);
flags &= ~flag;
switch (flag) {
case SUFF_NULL:
fprintf(debug_file, "NULL");
(void)fprintf(debug_file, "NULL");
break;
case SUFF_INCLUDE:
fprintf(debug_file, "INCLUDE");
(void)fprintf(debug_file, "INCLUDE");
break;
case SUFF_LIBRARY:
fprintf(debug_file, "LIBRARY");
(void)fprintf(debug_file, "LIBRARY");
break;
}
fputc(flags ? '|' : ')', debug_file);
(void)fputc(flags ? '|' : ')', debug_file);
}
}
fputc('\n', debug_file);
fprintf(debug_file, "#\tTo: ");
(void)fputc('\n', debug_file);
(void)fprintf(debug_file, "#\tTo: ");
Lst_ForEach(s->parents, SuffPrintName, NULL);
fputc('\n', debug_file);
fprintf(debug_file, "#\tFrom: ");
(void)fputc('\n', debug_file);
(void)fprintf(debug_file, "#\tFrom: ");
Lst_ForEach(s->children, SuffPrintName, NULL);
fputc('\n', debug_file);
fprintf(debug_file, "#\tSearch Path: ");
(void)fputc('\n', debug_file);
(void)fprintf(debug_file, "#\tSearch Path: ");
Dir_PrintPath(s->searchPath);
fputc('\n', debug_file);
(void)fputc('\n', debug_file);
return (dummy ? 0 : 0);
}
@ -2627,20 +2627,20 @@ SuffPrintTrans(ClientData tp, ClientData dummy)
{
GNode *t = (GNode *)tp;
fprintf(debug_file, "%-16s: ", t->name);
(void)fprintf(debug_file, "%-16s: ", t->name);
Targ_PrintType(t->type);
fputc('\n', debug_file);
(void)fputc('\n', debug_file);
Lst_ForEach(t->commands, Targ_PrintCmd, NULL);
fputc('\n', debug_file);
(void)fputc('\n', debug_file);
return(dummy ? 0 : 0);
}
void
Suff_PrintAll(void)
{
fprintf(debug_file, "#*** Suffixes:\n");
(void)fprintf(debug_file, "#*** Suffixes:\n");
Lst_ForEach(sufflist, SuffPrintSuff, NULL);
fprintf(debug_file, "#*** Transformations:\n");
(void)fprintf(debug_file, "#*** Transformations:\n");
Lst_ForEach(transforms, SuffPrintTrans, NULL);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: targ.c,v 1.50 2007/12/21 20:32:24 dsl Exp $ */
/* $NetBSD: targ.c,v 1.51 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: targ.c,v 1.50 2007/12/21 20:32:24 dsl Exp $";
static char rcsid[] = "$NetBSD: targ.c,v 1.51 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: targ.c,v 1.50 2007/12/21 20:32:24 dsl Exp $");
__RCSID("$NetBSD: targ.c,v 1.51 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -511,6 +511,7 @@ Targ_SetMain(GNode *gn)
}
static int
/*ARGSUSED*/
TargPrintName(ClientData gnp, ClientData pflags __unused)
{
GNode *gn = (GNode *)gnp;
@ -566,7 +567,7 @@ Targ_FmtTime(time_t tm)
*-----------------------------------------------------------------------
*/
void
Targ_PrintType(int type)
Targ_PrintType(unsigned int type)
{
int tbit;
@ -576,7 +577,7 @@ Targ_PrintType(int type)
type &= ~OP_OPMASK;
while (type) {
tbit = 1 << (ffs(type) - 1);
tbit = 1 << (ffs((int)type) - 1);
type &= ~tbit;
switch(tbit) {
@ -716,6 +717,7 @@ Targ_PrintNode(ClientData gnp, ClientData passp)
*-----------------------------------------------------------------------
*/
static int
/*ARGSUSED*/
TargPrintOnlySrc(ClientData gnp, ClientData dummy __unused)
{
GNode *gn = (GNode *)gnp;
@ -789,6 +791,7 @@ Targ_PrintGraph(int pass)
*-----------------------------------------------------------------------
*/
static int
/*ARGSUSED*/
TargPropagateNode(ClientData gnp, ClientData junk __unused)
{
GNode *gn = (GNode *)gnp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: trace.c,v 1.7 2006/01/04 21:35:44 dsl Exp $ */
/* $NetBSD: trace.c,v 1.8 2008/02/14 22:11:20 christos Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -38,11 +38,11 @@
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: trace.c,v 1.7 2006/01/04 21:35:44 dsl Exp $";
static char rcsid[] = "$NetBSD: trace.c,v 1.8 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: trace.c,v 1.7 2006/01/04 21:35:44 dsl Exp $");
__RCSID("$NetBSD: trace.c,v 1.8 2008/02/14 22:11:20 christos Exp $");
#endif /* not lint */
#endif
@ -101,23 +101,23 @@ Trace_Log(TrEvent event, Job *job)
if (trfile == NULL)
return;
gettimeofday(&rightnow, NULL);
(void)gettimeofday(&rightnow, NULL);
fprintf(trfile, "%ld.%06d %d %s %d %s",
(void)fprintf(trfile, "%ld.%06d %d %s %d %s",
rightnow.tv_sec, (int)rightnow.tv_usec,
jobTokensRunning,
evname[event], trpid, trwd);
if (job != NULL) {
fprintf(trfile, " %s %d %x %x", job->node->name,
job->pid, job->flags, job->node->type);
(void)fprintf(trfile, " %s %ld %x %x", job->node->name,
(long)job->pid, job->flags, job->node->type);
}
fputc('\n', trfile);
fflush(trfile);
(void)fputc('\n', trfile);
(void)fflush(trfile);
}
void
Trace_End(void)
{
if (trfile != NULL)
fclose(trfile);
(void)fclose(trfile);
}

View File

@ -1,15 +1,15 @@
/* $NetBSD: util.c,v 1.42 2007/10/15 01:07:36 sjg Exp $ */
/* $NetBSD: util.c,v 1.43 2008/02/14 22:11:20 christos Exp $ */
/*
* Missing stuff from OS's
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: util.c,v 1.42 2007/10/15 01:07:36 sjg Exp $";
static char rcsid[] = "$NetBSD: util.c,v 1.43 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: util.c,v 1.42 2007/10/15 01:07:36 sjg Exp $");
__RCSID("$NetBSD: util.c,v 1.43 2008/02/14 22:11:20 christos Exp $");
#endif
#endif
@ -181,7 +181,7 @@ char *sys_siglist[] = {
#include <unistd.h>
int
killpg(int pid, int sig)
killpg(pid_t pid, int sig)
{
return kill(-pid, sig);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.123 2007/10/13 19:59:52 apb Exp $ */
/* $NetBSD: var.c,v 1.124 2008/02/14 22:11:20 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: var.c,v 1.123 2007/10/13 19:59:52 apb Exp $";
static char rcsid[] = "$NetBSD: var.c,v 1.124 2008/02/14 22:11:20 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: var.c,v 1.123 2007/10/13 19:59:52 apb Exp $");
__RCSID("$NetBSD: var.c,v 1.124 2008/02/14 22:11:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -235,9 +235,9 @@ typedef struct {
* to VarSYSVMatch() for ":lhs=rhs". */
typedef struct {
const char *lhs; /* String to match */
int leftLen; /* Length of string */
size_t leftLen; /* Length of string */
const char *rhs; /* Replacement string (w/ &'s removed) */
int rightLen; /* Length of replacement */
size_t rightLen; /* Length of replacement */
int flags;
} VarPattern;
@ -245,9 +245,9 @@ typedef struct {
typedef struct {
GNode *ctxt; /* variable context */
char *tvar; /* name of temp var */
int tvarLen;
size_t tvarLen;
char *str; /* string to expand */
int strLen;
size_t strLen;
int errnum; /* errnum for not defined */
} VarLoop_t;
@ -255,7 +255,7 @@ typedef struct {
/* struct passed as ClientData to VarRESubstitute() for ":C///" */
typedef struct {
regex_t re;
int nsub;
size_t nsub;
regmatch_t *matches;
char *replace;
int flags;
@ -296,7 +296,7 @@ static Boolean VarSubstitute(GNode *, Var_Parse_State *,
static Boolean VarLoopExpand(GNode *, Var_Parse_State *,
char *, Boolean, Buffer, ClientData);
static char *VarGetPattern(GNode *, Var_Parse_State *,
int, const char **, int, int *, int *,
int, const char **, int, int *, size_t *,
VarPattern *);
static char *VarQuote(char *);
static char *VarChangeCase(char *, int);
@ -396,7 +396,7 @@ VarFind(const char *name, GNode *ctxt, int flags)
char *env;
if ((env = getenv(name)) != NULL) {
int len;
size_t len;
v = emalloc(sizeof(Var));
v->name = estrdup(name);
@ -477,7 +477,7 @@ static void
VarAdd(const char *name, const char *val, GNode *ctxt)
{
Var *v;
int len;
size_t len;
Hash_Entry *h;
v = emalloc(sizeof(Var));
@ -639,7 +639,7 @@ Var_ExportVars(void)
if (n < sizeof(tmp)) {
char **av;
char *as;
int ac;
size_t ac;
int i;
val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
@ -665,7 +665,7 @@ Var_Export(char *str, int isExport)
char *val;
char **av;
char *as;
int ac;
size_t ac;
int i;
if (isExport && (!str || !str[0])) {
@ -742,7 +742,7 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags)
* here will override anything in a lower context, so there's not much
* point in searching them all just to save a bit of memory...
*/
if ((name = strchr(cp, '$'))) {
if ((name = strchr(cp, '$')) != NULL) {
name = Var_Subst(NULL, cp, ctxt, 0);
} else
name = cp;
@ -817,7 +817,7 @@ Var_Append(const char *name, const char *val, GNode *ctxt)
Hash_Entry *h;
const char *cp = name;
if ((name = strchr(cp, '$'))) {
if ((name = strchr(cp, '$')) != NULL) {
name = Var_Subst(NULL, cp, ctxt, 0);
} else
name = cp;
@ -938,6 +938,7 @@ Var_Value(const char *name, GNode *ctxt, char **frp)
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarHead(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData dummy)
@ -986,6 +987,7 @@ VarHead(GNode *ctx __unused, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarTail(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData dummy)
@ -1028,6 +1030,7 @@ VarTail(GNode *ctx __unused, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarSuffix(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData dummy)
@ -1069,6 +1072,7 @@ VarSuffix(GNode *ctx __unused, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarRoot(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData dummy)
@ -1113,6 +1117,7 @@ VarRoot(GNode *ctx __unused, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarMatch(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData pattern)
@ -1156,7 +1161,7 @@ VarSYSVMatch(GNode *ctx, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData patp)
{
int len;
size_t len;
char *ptr;
VarPattern *pat = (VarPattern *)patp;
char *varexp;
@ -1202,6 +1207,7 @@ VarSYSVMatch(GNode *ctx, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarNoMatch(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData pattern)
@ -1239,6 +1245,7 @@ VarNoMatch(GNode *ctx __unused, Var_Parse_State *vpstate,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarSubstitute(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer buf,
ClientData patternp)
@ -1353,14 +1360,15 @@ VarSubstitute(GNode *ctx __unused, Var_Parse_State *vpstate,
while (!done) {
cp = Str_FindSubstring(word, pattern->lhs);
if (cp != NULL) {
if (addSpace && (((cp - word) + pattern->rightLen) != 0)){
size_t sp = (size_t)(cp - word);
if (addSpace && ((sp + pattern->rightLen) != 0)){
Buf_AddByte(buf, vpstate->varSpace);
addSpace = FALSE;
}
Buf_AddBytes(buf, cp-word, (const Byte *)word);
Buf_AddBytes(buf, sp, (const Byte *)word);
Buf_AddBytes(buf, pattern->rightLen,
(const Byte *)pattern->rhs);
wordLen -= (cp - word) + pattern->leftLen;
wordLen -= sp + pattern->leftLen;
word = cp + pattern->leftLen;
if (wordLen == 0) {
done = TRUE;
@ -1414,7 +1422,7 @@ static void
VarREError(int errnum, regex_t *pat, const char *str)
{
char *errbuf;
int errlen;
size_t errlen;
errlen = regerror(errnum, pat, 0, 0);
errbuf = emalloc(errlen);
@ -1439,6 +1447,7 @@ VarREError(int errnum, regex_t *pat, const char *str)
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
char *word, Boolean addSpace, Buffer buf,
ClientData patternp)
@ -1472,13 +1481,13 @@ VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
pat->flags |= VAR_SUB_MATCHED;
if (pat->matches[0].rm_so > 0) {
MAYBE_ADD_SPACE();
Buf_AddBytes(buf, pat->matches[0].rm_so, wp);
Buf_AddBytes(buf, (size_t)pat->matches[0].rm_so, wp);
}
for (rp = pat->replace; *rp; rp++) {
if ((*rp == '\\') && ((rp[1] == '&') || (rp[1] == '\\'))) {
MAYBE_ADD_SPACE();
Buf_AddByte(buf,rp[1]);
Buf_AddByte(buf, rp[1]);
rp++;
}
else if ((*rp == '&') ||
@ -1510,8 +1519,9 @@ VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
subbuf = "";
sublen = 0;
} else {
subbuf = wp + pat->matches[n].rm_so;
sublen = pat->matches[n].rm_eo - pat->matches[n].rm_so;
subbuf = wp + (size_t)pat->matches[n].rm_so;
sublen = (size_t)
(pat->matches[n].rm_eo - pat->matches[n].rm_so);
}
if (sublen > 0) {
@ -1523,7 +1533,7 @@ VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
Buf_AddByte(buf, *rp);
}
}
wp += pat->matches[0].rm_eo;
wp += (size_t)pat->matches[0].rm_eo;
if (pat->flags & VAR_SUB_GLOBAL) {
flags |= REG_NOTBOL;
if (pat->matches[0].rm_so == 0 && pat->matches[0].rm_eo == 0) {
@ -1542,15 +1552,15 @@ VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
break;
default:
VarREError(xrv, &pat->re, "Unexpected regex error");
/* fall through */
/* FALLTHROUGH */
case REG_NOMATCH:
if (*wp) {
MAYBE_ADD_SPACE();
Buf_AddBytes(buf,strlen(wp),wp);
Buf_AddBytes(buf, strlen(wp), wp);
}
break;
}
return(addSpace||added);
return addSpace || added;
}
#endif
@ -1579,6 +1589,7 @@ VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
*-----------------------------------------------------------------------
*/
static Boolean
/*ARGSUSED*/
VarLoopExpand(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
char *word, Boolean addSpace, Buffer buf,
ClientData loopp)
@ -1622,6 +1633,7 @@ VarLoopExpand(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
*-----------------------------------------------------------------------
*/
static char *
/*ARGSUSED*/
VarSelectWords(GNode *ctx __unused, Var_Parse_State *vpstate,
const char *str, VarSelectWords_t *seldata)
{
@ -1631,7 +1643,8 @@ VarSelectWords(GNode *ctx __unused, Var_Parse_State *vpstate,
* word */
char **av; /* word list */
char *as; /* word list memory */
int ac, i;
size_t ac;
int i;
int start, end, step;
buf = Buf_Init(0);
@ -1725,7 +1738,7 @@ VarModify(GNode *ctx, Var_Parse_State *vpstate,
* word */
char **av; /* word list */
char *as; /* word list memory */
int ac, i;
size_t ac, i;
buf = Buf_Init(0);
addSpace = FALSE;
@ -1785,7 +1798,7 @@ VarOrder(const char *str, const char otype)
Buffer buf; /* Buffer for the new string */
char **av; /* word list [first word does not count] */
char *as; /* word list memory */
int ac, i;
size_t ac, i;
buf = Buf_Init(0);
@ -1856,7 +1869,7 @@ VarUniq(const char *str)
Buffer buf; /* Buffer for new string */
char **av; /* List of words to affect */
char *as; /* Word list memory */
int ac, i, j;
size_t ac, i, j;
buf = Buf_Init(0);
av = brk_string(str, &ac, FALSE, &as);
@ -1907,13 +1920,14 @@ VarUniq(const char *str)
*-----------------------------------------------------------------------
*/
static char *
/*ARGSUSED*/
VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
int errnum, const char **tstr, int delim, int *flags,
int *length, VarPattern *pattern)
size_t *length, VarPattern *pattern)
{
const char *cp;
Buffer buf = Buf_Init(0);
int junk;
size_t junk;
if (length == NULL)
length = &junk;
@ -1944,7 +1958,7 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
} else {
if (flags == NULL || (*flags & VAR_NOSUBST) == 0) {
char *cp2;
int len;
size_t len;
void *freeIt;
/*
@ -1978,7 +1992,7 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
--depth;
}
}
Buf_AddBytes(buf, cp2 - cp, (const Byte *)cp);
Buf_AddBytes(buf, (size_t)(cp2 - cp), (const Byte *)cp);
cp = --cp2;
} else
Buf_AddByte(buf, (Byte)*cp);
@ -2171,7 +2185,7 @@ static char *
ApplyModifiers(char *nstr, const char *tstr,
int startc, int endc,
Var *v, GNode *ctxt, Boolean errnum,
int *lengthPtr, void **freePtr)
size_t *lengthPtr, void **freePtr)
{
const char *start;
const char *cp; /* Secondary pointer into str (place marker
@ -2198,19 +2212,19 @@ ApplyModifiers(char *nstr, const char *tstr,
*/
void *freeIt;
char *rval;
int rlen;
size_t rlen;
rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
if (DEBUG(VAR)) {
fprintf(debug_file, "Got '%s' from '%.*s'%.*s\n",
rval, rlen, tstr, rlen, tstr + rlen);
rval, (int)rlen, tstr, (int)rlen, tstr + rlen);
}
tstr += rlen;
if (rval != NULL && *rval) {
int used;
size_t used;
nstr = ApplyModifiers(nstr, rval,
0, 0,
@ -2386,7 +2400,7 @@ ApplyModifiers(char *nstr, const char *tstr,
* variable substitution and recurse.
*/
char *cp2;
int len;
size_t len;
void *freeIt;
cp2 = Var_Parse(cp, ctxt, errnum, &len, &freeIt);
@ -2512,21 +2526,21 @@ ApplyModifiers(char *nstr, const char *tstr,
* (which should never be needed) and a '\0'
* string terminator.
*/
int newStrSize =
size_t newStrSize =
(sizeof(int) * CHAR_BIT + 2) / 3 + 2;
newStr = emalloc(newStrSize);
if (parsestate.oneBigWord) {
strncpy(newStr, "1", newStrSize);
(void)strncpy(newStr, "1", newStrSize);
} else {
/* XXX: brk_string() is a rather expensive
* way of counting words. */
char **av;
char *as;
int ac;
size_t ac;
av = brk_string(nstr, &ac, FALSE, &as);
snprintf(newStr, newStrSize, "%d", ac);
(void)snprintf(newStr, newStrSize, "%zu", ac);
free(as);
free(av);
}
@ -2646,7 +2660,7 @@ ApplyModifiers(char *nstr, const char *tstr,
if (isdigit((unsigned char)tstr[3])) {
char *ep;
parsestate.varSpace =
parsestate.varSpace = (Byte)
strtoul(&tstr[3], &ep, 0);
if (*ep != ':' && *ep != endc)
goto bad_modifier;
@ -2761,7 +2775,7 @@ ApplyModifiers(char *nstr, const char *tstr,
* cp - tstr takes the null byte into account) and
* compress the pattern into the space.
*/
pattern = emalloc(cp - tstr);
pattern = emalloc((size_t)(cp - tstr));
for (cp2 = pattern, cp = tstr + 1;
cp < endpat;
cp++, cp2++)
@ -2779,7 +2793,7 @@ ApplyModifiers(char *nstr, const char *tstr,
* Either Var_Subst or VarModify will need a
* nul-terminated string soon, so construct one now.
*/
pattern = estrndup(tstr+1, endpat - (tstr + 1));
pattern = estrndup(tstr + 1, (size_t)(endpat - (tstr + 1)));
copy = TRUE;
}
if (strchr(pattern, '$') != NULL) {
@ -3215,7 +3229,7 @@ ApplyModifiers(char *nstr, const char *tstr,
*/
/* coverity[+alloc : arg-*4] */
char *
Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
Var_Parse(const char *str, GNode *ctxt, Boolean errnum, size_t *lengthPtr,
void **freePtr)
{
const char *tstr; /* Pointer into str */
@ -3306,7 +3320,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
* A variable inside a variable, expand
*/
if (*tstr == '$') {
int rlen;
size_t rlen;
void *freeIt;
char *rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
if (rval != NULL) {
@ -3431,7 +3445,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
isupper((unsigned char) str[1]) &&
((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)))
{
int len;
size_t len;
len = vlen - 1;
if ((strncmp(str, ".TARGET", len) == 0) ||
@ -3497,7 +3511,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
v->flags &= ~VAR_IN_USE;
if ((nstr != NULL) && haveModifier) {
int used;
size_t used;
/*
* Skip initial colon.
*/
@ -3577,7 +3591,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
{
Buffer buf; /* Buffer for forming things */
char *val; /* Value to substitute for a variable */
int length; /* Length of the variable invocation */
size_t length; /* Length of the variable invocation */
Boolean trailingBslash; /* variable ends in \ */
void *freeIt = NULL; /* Set if it should be freed */
static Boolean errorReported; /* Set true if an error has already
@ -3609,7 +3623,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
for (cp = str++; *str != '$' && *str != '\0'; str++)
continue;
Buf_AddBytes(buf, str - cp, (const Byte *)cp);
Buf_AddBytes(buf, (size_t)(str - cp), (const Byte *)cp);
} else {
if (var != NULL) {
int expand;
@ -3645,12 +3659,13 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
* the nested one
*/
if (*p == '$') {
Buf_AddBytes(buf, p - str, (const Byte *)str);
Buf_AddBytes(buf, (size_t)(p - str),
(const Byte *)str);
str = p;
continue;
}
if (strncmp(var, str + 2, p - str - 2) != 0 ||
if (strncmp(var, str + 2, (size_t)(p - str - 2)) != 0 ||
var[p - str - 2] != '\0') {
/*
* Not the variable we want to expand, scan
@ -3658,7 +3673,8 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
*/
for (;*p != '$' && *p != '\0'; p++)
continue;
Buf_AddBytes(buf, p - str, (const Byte *)str);
Buf_AddBytes(buf, (size_t)(p - str),
(const Byte *)str);
str = p;
expand = FALSE;
}
@ -3696,7 +3712,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
*/
if (!errorReported) {
Parse_Error(PARSE_FATAL,
"Undefined variable \"%.*s\"",length,str);
"Undefined variable \"%.*s\"", (int)length, str);
}
str += length;
errorReported = TRUE;