From 9a4c88c2704005a2ca4555a000825752beb89ad6 Mon Sep 17 00:00:00 2001 From: Max Okumoto Date: Thu, 16 Dec 2004 00:17:05 +0000 Subject: [PATCH] Style: remove a lot of unnecessary casts, add some and spell the null pointer constant as NULL. Checked by: diff -r on the object files before and after Taken-from: FreeBSD Author: harti --- usr.bin/make/arch.c | 39 +++--- usr.bin/make/buf.c | 31 ++--- usr.bin/make/compat.c | 28 ++-- usr.bin/make/cond.c | 20 +-- usr.bin/make/dir.c | 93 ++++++------- usr.bin/make/for.c | 11 +- usr.bin/make/hash.c | 23 ++-- usr.bin/make/hash.h | 4 +- usr.bin/make/job.c | 87 ++++++------- usr.bin/make/main.c | 22 ++-- usr.bin/make/make.c | 60 ++++----- usr.bin/make/parse.c | 167 ++++++++++++------------ usr.bin/make/str.c | 14 +- usr.bin/make/suff.c | 265 +++++++++++++++++++------------------- usr.bin/make/targ.c | 40 +++--- usr.bin/make/var.c | 98 +++++++------- usr.bin/make/var_modify.c | 32 ++--- 17 files changed, 512 insertions(+), 522 deletions(-) diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c index 888be7948a..22a9b47bfb 100644 --- a/usr.bin/make/arch.c +++ b/usr.bin/make/arch.c @@ -37,7 +37,7 @@ * * @(#)arch.c 8.2 (Berkeley) 1/2/94 * $FreeBSD: src/usr.bin/make/arch.c,v 1.15.2.1 2001/02/13 03:13:57 will Exp $ - * $DragonFly: src/usr.bin/make/arch.c,v 1.14 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/arch.c,v 1.15 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -137,7 +137,7 @@ static int ArchSVR4Entry(Arch *, char *, size_t, FILE *); static void ArchFree(void *ap) { - Arch *a = (Arch *)ap; + Arch *a = ap; Hash_Search search; Hash_Entry *entry; @@ -342,7 +342,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt) Dir_Expand(memName, dirSearchPath, members); while (!Lst_IsEmpty(members)) { - member = (char *)Lst_DeQueue(members); + member = Lst_DeQueue(members); nsz = strlen(libName) + strlen(member) + 3; /* 3 = ()+\0 */ if (sz < nsz) { sz = nsz * 2; @@ -385,7 +385,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt) * provided list. */ gn->type |= OP_ARCHV; - Lst_AtEnd(nodeLst, (void *)gn); + Lst_AtEnd(nodeLst, gn); } } if (doSubst) { @@ -479,9 +479,9 @@ ArchStatMember(char *archive, char *member, Boolean hash) if ((cp != NULL) && (strcmp(member, RANLIBMAG) != 0)) member = cp + 1; - ln = Lst_Find(archives, (void *)archive, ArchFindArchive); + ln = Lst_Find(archives, archive, ArchFindArchive); if (ln != NULL) { - ar = (Arch *)Lst_Datum(ln); + ar = Lst_Datum(ln); he = Hash_FindEntry(&ar->members, member); @@ -498,7 +498,7 @@ ArchStatMember(char *archive, char *member, Boolean hash) copy[AR_MAX_NAME_LEN] = '\0'; } if ((he = Hash_FindEntry(&ar->members, copy)) != NULL) - return ((struct ar_hdr *)Hash_GetValue(he)); + return (Hash_GetValue(he)); return (NULL); } } @@ -542,14 +542,14 @@ ArchStatMember(char *archive, char *member, Boolean hash) return (NULL); } - ar = (Arch *)emalloc(sizeof(Arch)); + ar = emalloc(sizeof(Arch)); ar->name = estrdup(archive); ar->fnametab = NULL; ar->fnamesize = 0; 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 @@ -621,16 +621,15 @@ ArchStatMember(char *archive, char *member, Boolean hash) #endif he = Hash_CreateEntry(&ar->members, memName, NULL); - Hash_SetValue(he, (void *)emalloc (sizeof(struct ar_hdr))); - memcpy(Hash_GetValue(he), &arh, - sizeof(struct ar_hdr)); + Hash_SetValue(he, emalloc(sizeof(struct ar_hdr))); + memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr)); } fseek(arch, (size + 1) & ~1, SEEK_CUR); } fclose(arch); - Lst_AtEnd(archives, (void *)ar); + Lst_AtEnd(archives, ar); /* * Now that the archive has been read and cached, we can look into @@ -639,7 +638,7 @@ ArchStatMember(char *archive, char *member, Boolean hash) he = Hash_FindEntry(&ar->members, member); if (he != NULL) { - return ((struct ar_hdr *)Hash_GetValue (he)); + return (Hash_GetValue (he)); } else { return (NULL); } @@ -798,7 +797,7 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr, char *mode) 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 @@ -917,7 +916,7 @@ Arch_Touch(GNode *gn) snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long)now); if (arch != NULL) { - fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch); + fwrite(&arh, sizeof(struct ar_hdr), 1, arch); fclose(arch); } } @@ -949,7 +948,7 @@ Arch_TouchLib(GNode *gn) snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now); if (arch != NULL) { - fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch); + fwrite(&arh, sizeof(struct ar_hdr), 1, arch); fclose(arch); times.actime = times.modtime = now; @@ -1023,7 +1022,7 @@ Arch_MemMTime(GNode *gn) return (0); } while ((ln = Lst_Next(gn->parents)) != NULL) { - pgn = (GNode *)Lst_Datum(ln); + pgn = Lst_Datum(ln); if (pgn->type & OP_ARCHV) { /* @@ -1082,7 +1081,7 @@ Arch_FindLib(GNode *gn, Lst path) size_t sz; sz = strlen(gn->name) + 4; - libName = (char *)emalloc(sz); + libName = emalloc(sz); snprintf(libName, sz, "lib%s.a", &gn->name[2]); gn->path = Dir_FindFile(libName, path); @@ -1189,6 +1188,7 @@ Arch_LibOODate(GNode *gn) void Arch_Init(void) { + archives = Lst_Init(FALSE); } @@ -1208,5 +1208,6 @@ Arch_Init(void) void Arch_End(void) { + Lst_Destroy(archives, ArchFree); } diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c index b4c214e545..df9a296795 100644 --- a/usr.bin/make/buf.c +++ b/usr.bin/make/buf.c @@ -38,7 +38,7 @@ * * @(#)buf.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.bin/make/buf.c,v 1.11 1999/09/11 13:08:01 hoek Exp $ - * $DragonFly: src/usr.bin/make/buf.c,v 1.7 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/buf.c,v 1.8 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -64,7 +64,7 @@ #define BufExpand(bp,nb) \ if (bp->left < (nb)+1) {\ int newSize = (bp)->size + max((nb) + 1, BUF_ADD_INC); \ - Byte *newBuf = (Byte *)erealloc((bp)->buffer, newSize); \ + Byte *newBuf = erealloc((bp)->buffer, newSize); \ \ (bp)->inPtr = newBuf + ((bp)->inPtr - (bp)->buffer); \ (bp)->outPtr = newBuf + ((bp)->outPtr - (bp)->buffer);\ @@ -93,6 +93,7 @@ void Buf_OvAddByte(Buffer bp, int byte) { + bp->left = 0; BufExpand(bp, 1); @@ -169,12 +170,11 @@ Buf_UngetByte(Buffer bp, int byte) int numBytes = bp->inPtr - bp->outPtr; Byte *newBuf; - newBuf = (Byte *)emalloc(bp->size + BUF_UNGET_INC); - memcpy((char *)(newBuf+BUF_UNGET_INC), (char *)bp->outPtr, - numBytes + 1); + newBuf = emalloc(bp->size + BUF_UNGET_INC); + memcpy(newBuf + BUF_UNGET_INC, bp->outPtr, numBytes + 1); bp->outPtr = newBuf + BUF_UNGET_INC; bp->inPtr = bp->outPtr + numBytes; - free((char *)bp->buffer); + free(bp->buffer); bp->buffer = newBuf; bp->size += BUF_UNGET_INC; bp->left = bp->size - (bp->inPtr - bp->buffer); @@ -210,16 +210,16 @@ Buf_UngetBytes(Buffer bp, int numBytes, Byte *bytesPtr) Byte *newBuf; int newBytes = max(numBytes,BUF_UNGET_INC); - newBuf = (Byte *)emalloc (bp->size + newBytes); - memcpy((char *)(newBuf+newBytes), (char *)bp->outPtr, curNumBytes + 1); + newBuf = emalloc(bp->size + newBytes); + memcpy(newBuf + newBytes, bp->outPtr, curNumBytes + 1); bp->outPtr = newBuf + newBytes; bp->inPtr = bp->outPtr + curNumBytes; - free((char *)bp->buffer); + free(bp->buffer); bp->buffer = newBuf; bp->size += newBytes; bp->left = bp->size - (bp->inPtr - bp->buffer); bp->outPtr -= numBytes; - memcpy((char *)bp->outPtr, (char *)bytesPtr, numBytes); + memcpy(bp->outPtr, bytesPtr, numBytes); } } @@ -305,7 +305,7 @@ Byte * Buf_GetAll(Buffer bp, int *numBytesPtr) { - if (numBytesPtr != (int *)NULL) { + if (numBytesPtr != NULL) { *numBytesPtr = bp->inPtr - bp->outPtr; } @@ -355,6 +355,7 @@ Buf_Discard(Buffer bp, int numBytes) int Buf_Size(Buffer buf) { + return (buf->inPtr - buf->outPtr); } @@ -378,13 +379,13 @@ Buf_Init(int size) { Buffer bp; /* New Buffer */ - bp = (Buffer)emalloc(sizeof(*bp)); + bp = emalloc(sizeof(*bp)); if (size <= 0) { size = BUF_DEF_SIZE; } bp->left = bp->size = size; - bp->buffer = (Byte *)emalloc(size); + bp->buffer = emalloc(size); bp->inPtr = bp->outPtr = bp->buffer; *bp->inPtr = 0; @@ -409,9 +410,9 @@ Buf_Destroy(Buffer buf, Boolean freeData) { if (freeData) { - free((char *)buf->buffer); + free(buf->buffer); } - free((char *)buf); + free(buf); } /*- diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index 28354aab07..5dcb5f7179 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -38,7 +38,7 @@ * * @(#)compat.c 8.2 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/compat.c,v 1.16.2.2 2000/07/01 12:24:21 ps Exp $ - * $DragonFly: src/usr.bin/make/Attic/compat.c,v 1.16 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/Attic/compat.c,v 1.17 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -229,8 +229,8 @@ Compat_RunCommand(void *cmdp, void *gnp) int argc; /* Number of arguments in av or 0 if not * dynamically allocated */ int internal; /* Various values.. */ - char *cmd = (char *)cmdp; - GNode *gn = (GNode *)gnp; + char *cmd = cmdp; + GNode *gn = gnp; /* * Avoid clobbered variable warnings by forcing the compiler @@ -244,7 +244,7 @@ Compat_RunCommand(void *cmdp, void *gnp) errCheck = !(gn->type & OP_IGNORE); doit = FALSE; - cmdNode = Lst_Member(gn->commands, (void *)cmd); + cmdNode = Lst_Member(gn->commands, cmd); cmdStart = Var_Subst(NULL, cmd, gn, FALSE); /* @@ -261,10 +261,10 @@ Compat_RunCommand(void *cmdp, void *gnp) } else { cmd = cmdStart; } - Lst_Replace (cmdNode, (void *)cmdStart); + Lst_Replace (cmdNode, cmdStart); if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) { - Lst_AtEnd(ENDNode->commands, (void *)cmdStart); + Lst_AtEnd(ENDNode->commands, cmdStart); return (0); } else if (strcmp(cmdStart, "...") == 0) { gn->type |= OP_SAVE_CMDS; @@ -332,7 +332,7 @@ Compat_RunCommand(void *cmdp, void *gnp) shargv[0] = shellPath; shargv[1] = (errCheck ? "-ec" : "-c"); shargv[2] = cmd; - shargv[3] = (char *)NULL; + shargv[3] = NULL; av = shargv; argc = 0; } else if ((internal = shellneed(cmd))) { @@ -350,7 +350,7 @@ Compat_RunCommand(void *cmdp, void *gnp) shargv[0] = shellPath; shargv[1] = (errCheck ? "-ec" : "-c"); shargv[2] = cmd; - shargv[3] = (char *)NULL; + shargv[3] = NULL; av = shargv; argc = 0; } else { @@ -463,8 +463,8 @@ Compat_RunCommand(void *cmdp, void *gnp) static int CompatMake(void *gnp, void *pgnp) { - GNode *gn = (GNode *)gnp; - GNode *pgn = (GNode *)pgnp; + GNode *gn = gnp; + GNode *pgn = pgnp; if (gn->type & OP_USE) { Make_HandleUse(gn, pgn); @@ -480,7 +480,7 @@ CompatMake(void *gnp, void *pgnp) gn->make = TRUE; gn->made = BEINGMADE; Suff_FindDeps(gn); - Lst_ForEach(gn->children, CompatMake, (void *)gn); + Lst_ForEach(gn->children, CompatMake, gn); if (!gn->make) { gn->made = ABORTED; pgn->make = FALSE; @@ -707,7 +707,7 @@ Compat_Run(Lst targs) if (!queryFlag) { gn = Targ_FindNode(".BEGIN", TARG_NOCREATE); if (gn != NULL) { - Lst_ForEach(gn->commands, Compat_RunCommand, (void *)gn); + Lst_ForEach(gn->commands, Compat_RunCommand, gn); if (gn->made == ERROR) { printf("\n\nStop.\n"); exit(1); @@ -727,7 +727,7 @@ Compat_Run(Lst targs) */ errors = 0; while (!Lst_IsEmpty(targs)) { - gn = (GNode *)Lst_DeQueue(targs); + gn = Lst_DeQueue(targs); CompatMake(gn, gn); if (gn->made == UPTODATE) { @@ -742,6 +742,6 @@ Compat_Run(Lst targs) * If the user has defined a .END target, run its commands. */ if (errors == 0) { - Lst_ForEach(ENDNode->commands, Compat_RunCommand, (void *)gn); + Lst_ForEach(ENDNode->commands, Compat_RunCommand, gn); } } diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c index 55588d133a..1d1ec64f7e 100644 --- a/usr.bin/make/cond.c +++ b/usr.bin/make/cond.c @@ -38,7 +38,7 @@ * * @(#)cond.c 8.2 (Berkeley) 1/2/94 * $FreeBSD: src/usr.bin/make/cond.c,v 1.12.2.1 2003/07/22 08:03:13 ru Exp $ - * $DragonFly: src/usr.bin/make/cond.c,v 1.13 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/cond.c,v 1.14 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -156,6 +156,7 @@ static Boolean skipLine = FALSE; /* Whether the parse module is skipping static void CondPushBack(Token t) { + condPushBack = t; } @@ -212,7 +213,7 @@ CondGetArg(char **linePtr, char **argPtr, char *func, Boolean parens) */ buf = Buf_Init(16); - while ((strchr(" \t)&|", *cp) == (char *)NULL) && (*cp != '\0')) { + while ((strchr(" \t)&|", *cp) == NULL) && (*cp != '\0')) { if (*cp == '$') { /* * Parse the variable spec and install it as part of the argument @@ -280,7 +281,7 @@ CondDoDefined(int argLen, char *arg) Boolean result; arg[argLen] = '\0'; - if (Var_Value(arg, VAR_CMD, &p1) != (char *)NULL) { + if (Var_Value(arg, VAR_CMD, &p1) != NULL) { result = TRUE; } else { result = FALSE; @@ -307,6 +308,7 @@ CondDoDefined(int argLen, char *arg) static int CondStrMatch(void *string, void *pattern) { + return (!Str_Match((char *)string, (char *)pattern)); } @@ -330,7 +332,7 @@ CondDoMake(int argLen, char *arg) Boolean result; arg[argLen] = '\0'; - if (Lst_Find(create, (void *)arg, CondStrMatch) == NULL) { + if (Lst_Find(create, arg, CondStrMatch) == NULL) { result = FALSE; } else { result = TRUE; @@ -361,7 +363,7 @@ CondDoExists(int argLen, char *arg) arg[argLen] = '\0'; path = Dir_FindFile(arg, dirSearchPath); - if (path != (char *)NULL) { + if (path != NULL) { result = TRUE; free(path); } else { @@ -435,7 +437,7 @@ CondCvtArg(char *str, double *value) x = 10 + *str - isupper((unsigned char)*str) ? 'A' : 'a'; else { *value = (double)i; - return str; + return (str); } i = (i << 4) + x; } @@ -638,7 +640,7 @@ do_string_compare: Buf_AddByte(buf, (Byte)0); - string = (char *)Buf_GetAll(buf, (int *)0); + string = (char *)Buf_GetAll(buf, (int *)NULL); Buf_Destroy(buf, FALSE); DEBUGF(COND, ("lhs = \"%s\", rhs = \"%s\", op = %.2s\n", @@ -1094,13 +1096,13 @@ Cond_Eval(char *line) * Figure out what sort of conditional it is -- what its default * function is, etc. -- by looking in the table of valid "ifs" */ - for (ifp = ifs; ifp->form != (char *)0; ifp++) { + for (ifp = ifs; ifp->form != NULL; ifp++) { if (strncmp(ifp->form, line, ifp->formlen) == 0) { break; } } - if (ifp->form == (char *)0) { + if (ifp->form == NULL) { /* * Nothing fit. If the first word on the line is actually * "else", it's a valid conditional whose value is the inverse diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index f1822979c4..3bfd869b98 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -38,7 +38,7 @@ * * @(#)dir.c 8.2 (Berkeley) 1/2/94 * $$FreeBSD: src/usr.bin/make/dir.c,v 1.10.2.2 2003/10/08 08:14:22 ru Exp $ - * $DragonFly: src/usr.bin/make/dir.c,v 1.17 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/dir.c,v 1.18 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -262,7 +262,7 @@ Dir_End(void) { dot->refCount -= 1; - Dir_Destroy((void *) dot); + Dir_Destroy(dot); Dir_ClearPath(dirSearchPath); Lst_Destroy(dirSearchPath, NOFREE); Dir_ClearPath(openDirectories); @@ -287,6 +287,7 @@ Dir_End(void) static int DirFindName(void *p, void *dname) { + return (strcmp(((Path *)p)->name, (char *)dname)); } @@ -362,7 +363,7 @@ DirMatchFiles(char *pattern, Path *p, Lst expansions) isDot = (*p->name == '.' && p->name[1] == '\0'); for (entry = Hash_EnumFirst(&p->files, &search); - entry != (Hash_Entry *)NULL; + entry != NULL; entry = Hash_EnumNext(&search)) { /* @@ -521,7 +522,7 @@ DirExpandInt(char *word, Lst path, Lst expansions) if (Lst_Open(path) == SUCCESS) { while ((ln = Lst_Next(path)) != NULL) { - p = (Path *)Lst_Datum(ln); + p = Lst_Datum(ln); DirMatchFiles(word, p, expansions); } Lst_Close(path); @@ -619,7 +620,7 @@ Dir_Expand(char *word, Lst path, Lst expansions) * looking for Etc, it won't be found. Ah well. * Probably not important. */ - if (dirpath != (char *)NULL) { + if (dirpath != NULL) { char *dp = &dirpath[strlen(dirpath) - 1]; if (*dp == '/') *dp = '\0'; @@ -653,7 +654,7 @@ Dir_Expand(char *word, Lst path, Lst expansions) } } if (DEBUG(DIR)) { - Lst_ForEach(expansions, DirPrintWord, (void *) 0); + Lst_ForEach(expansions, DirPrintWord, (void *)NULL); DEBUGF(DIR, ("\n")); } } @@ -710,7 +711,7 @@ Dir_FindFile(char *name, Lst path) * (fish.c) and what pmake finds (./fish.c). */ if ((!hasSlash || (cp - name == 2 && *name == '.')) && - (Hash_FindEntry(&dot->files, cp) != (Hash_Entry *)NULL)) { + (Hash_FindEntry(&dot->files, cp) != NULL)) { DEBUGF(DIR, ("in '.'\n")); hits += 1; dot->hits += 1; @@ -720,7 +721,7 @@ Dir_FindFile(char *name, Lst path) if (Lst_Open(path) == FAILURE) { DEBUGF(DIR, ("couldn't open path, file not found\n")); misses += 1; - return ((char *)NULL); + return (NULL); } /* @@ -732,9 +733,9 @@ Dir_FindFile(char *name, Lst path) * we go on to phase two... */ while ((ln = Lst_Next(path)) != NULL) { - p = (Path *)Lst_Datum (ln); + p = Lst_Datum (ln); DEBUGF(DIR, ("%s...", p->name)); - if (Hash_FindEntry(&p->files, cp) != (Hash_Entry *)NULL) { + if (Hash_FindEntry(&p->files, cp) != NULL) { DEBUGF(DIR, ("here...")); if (hasSlash) { /* @@ -777,7 +778,7 @@ Dir_FindFile(char *name, Lst path) return (estrdup(name)); } else { DEBUGF(DIR, ("must be here but isn't -- returning NULL\n")); - return ((char *)NULL); + return (NULL); } } } @@ -798,16 +799,16 @@ Dir_FindFile(char *name, Lst path) if (!hasSlash) { DEBUGF(DIR, ("failed.\n")); misses += 1; - return ((char *)NULL); + return (NULL); } if (*name != '/') { Boolean checkedDot = FALSE; DEBUGF(DIR, ("failed. Trying subdirectories...")); - Lst_Open(path); + Lst_Open(path); while ((ln = Lst_Next(path)) != NULL) { - p = (Path *)Lst_Datum(ln); + p = Lst_Datum(ln); if (p != dot) { file = str_concat(p->name, name, STR_ADDSLASH); } else { @@ -844,9 +845,8 @@ Dir_FindFile(char *name, Lst path) * to fetch it again. */ DEBUGF(DIR, ("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), file)); - entry = Hash_CreateEntry(&mtimes, (char *)file, - (Boolean *)NULL); - Hash_SetValue(entry, (long)stb.st_mtime); + entry = Hash_CreateEntry(&mtimes, file, (Boolean *)NULL); + Hash_SetValue(entry, (void *)(long)stb.st_mtime); nearmisses += 1; return (file); } else { @@ -892,32 +892,32 @@ Dir_FindFile(char *name, Lst path) bigmisses += 1; ln = Lst_Last(path); if (ln == NULL) { - return ((char *)NULL); + return (NULL); } else { - p = (Path *)Lst_Datum (ln); + p = Lst_Datum(ln); } - if (Hash_FindEntry(&p->files, cp) != (Hash_Entry *)NULL) { + if (Hash_FindEntry(&p->files, cp) != NULL) { return (estrdup(name)); } else { - return ((char *)NULL); + return (NULL); } #else /* !notdef */ DEBUGF(DIR, ("Looking for \"%s\"...", name)); bigmisses += 1; entry = Hash_FindEntry(&mtimes, name); - if (entry != (Hash_Entry *)NULL) { + if (entry != NULL) { DEBUGF(DIR, ("got it (in mtime cache)\n")); return (estrdup(name)); } else if (stat (name, &stb) == 0) { entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL); DEBUGF(DIR, ("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), name)); - Hash_SetValue(entry, (long)stb.st_mtime); + Hash_SetValue(entry, (void *)(long)stb.st_mtime); return (estrdup(name)); } else { DEBUGF(DIR, ("failed. Returning NULL\n")); - return ((char *)NULL); + return (NULL); } #endif /* notdef */ } @@ -946,18 +946,18 @@ Dir_MTime(GNode *gn) if (gn->type & OP_ARCHV) { return (Arch_MTime(gn)); - } else if (gn->path == (char *)NULL) { + } else if (gn->path == NULL) { fullName = Dir_FindFile(gn->name, dirSearchPath); } else { fullName = gn->path; } - if (fullName == (char *)NULL) { + if (fullName == NULL) { fullName = estrdup(gn->name); } entry = Hash_FindEntry(&mtimes, fullName); - if (entry != (Hash_Entry *)NULL) { + if (entry != NULL) { /* * Only do this once -- the second time folks are checking to * see if the file was actually updated, so we need to actually go @@ -1007,24 +1007,24 @@ Dir_AddDir(Lst path, char *name) DIR *d; /* for reading directory */ struct dirent *dp; /* entry in directory */ - ln = Lst_Find(openDirectories, (void *)name, DirFindName); + ln = Lst_Find(openDirectories, name, DirFindName); if (ln != NULL) { - p = (Path *)Lst_Datum(ln); - if (Lst_Member(path, (void *)p) == NULL) { + p = Lst_Datum(ln); + if (Lst_Member(path, p) == NULL) { p->refCount += 1; - Lst_AtEnd(path, (void *)p); + Lst_AtEnd(path, p); } } else { DEBUGF(DIR, ("Caching %s...", name)); if ((d = opendir(name)) != (DIR *)NULL) { - p = (Path *) emalloc(sizeof(Path)); + p = emalloc(sizeof(Path)); p->name = estrdup(name); p->hits = 0; p->refCount = 1; Hash_InitTable(&p->files, -1); - while ((dp = readdir(d)) != (struct dirent *)NULL) { + while ((dp = readdir(d)) != NULL) { #if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */ /* * The sun directory library doesn't check for a 0 inode @@ -1049,9 +1049,9 @@ Dir_AddDir(Lst path, char *name) Hash_CreateEntry(&p->files, dp->d_name, (Boolean *)NULL); } closedir(d); - Lst_AtEnd(openDirectories, (void *)p); + Lst_AtEnd(openDirectories, p); if (path != openDirectories) - Lst_AtEnd(path, (void *)p); + Lst_AtEnd(path, p); } DEBUGF(DIR, ("done\n")); } @@ -1077,7 +1077,7 @@ Dir_CopyDir(void *p) ((Path *)p)->refCount += 1; - return ((void *)p); + return (p); } /*- @@ -1110,7 +1110,7 @@ Dir_MakeFlags(char *flag, Lst path) if (Lst_Open(path) == SUCCESS) { while ((ln = Lst_Next(path)) != NULL) { - p = (Path *)Lst_Datum(ln); + p = Lst_Datum(ln); tstr = str_concat(flag, p->name, 0); nstr = str_concat(str, tstr, STR_ADDSPACE); free(str); @@ -1141,13 +1141,14 @@ Dir_MakeFlags(char *flag, Lst path) void Dir_Destroy(void *pp) { - Path *p = (Path *)pp; + Path *p = pp; + p->refCount -= 1; if (p->refCount == 0) { LstNode ln; - ln = Lst_Member(openDirectories, (void *)p); + ln = Lst_Member(openDirectories, p); Lst_Remove(openDirectories, ln); Hash_DeleteTable(&p->files); @@ -1176,8 +1177,8 @@ Dir_ClearPath(Lst path) Path *p; while (!Lst_IsEmpty(path)) { - p = (Path *)Lst_DeQueue(path); - Dir_Destroy((void *) p); + p = Lst_DeQueue(path); + Dir_Destroy(p); } } @@ -1203,10 +1204,10 @@ Dir_Concat(Lst path1, Lst path2) Path *p; for (ln = Lst_First(path2); ln != NULL; ln = Lst_Succ(ln)) { - p = (Path *)Lst_Datum(ln); - if (Lst_Member(path1, (void *)p) == NULL) { + p = Lst_Datum(ln); + if (Lst_Member(path1, p) == NULL) { p->refCount += 1; - Lst_AtEnd(path1, (void *)p); + Lst_AtEnd(path1, p); } } } @@ -1226,7 +1227,7 @@ Dir_PrintDirectories(void) printf("# %-20s referenced\thits\n", "directory"); if (Lst_Open(openDirectories) == SUCCESS) { while ((ln = Lst_Next(openDirectories)) != NULL) { - p = (Path *)Lst_Datum(ln); + p = Lst_Datum(ln); printf("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits); } Lst_Close(openDirectories); @@ -1246,5 +1247,5 @@ void Dir_PrintPath(Lst path) { - Lst_ForEach(path, DirPrintDir, (void *)0); + Lst_ForEach(path, DirPrintDir, (void *)NULL); } diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index 0417d950b1..25129cfd7d 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -35,7 +35,7 @@ * * @(#)for.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.bin/make/for.c,v 1.10 1999/09/11 13:08:01 hoek Exp $ - * $DragonFly: src/usr.bin/make/for.c,v 1.11 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/for.c,v 1.12 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -174,7 +174,7 @@ For_Eval(char *line) #define ADDWORD() \ Buf_AddBytes(buf, ptr - wrd, (Byte *)wrd), \ Buf_AddByte(buf, (Byte)'\0'), \ - Lst_AtFront(forLst, (void *)Buf_GetAll(buf, &varlen)), \ + Lst_AtFront(forLst, Buf_GetAll(buf, &varlen)), \ Buf_Destroy(buf, FALSE) for (ptr = sub; *ptr && isspace((unsigned char)*ptr); ptr++) @@ -245,9 +245,10 @@ For_Eval(char *line) static int ForExec(void *namep, void *argp) { - char *name = (char *) namep; - For *arg = (For *) argp; + char *name = namep; + For *arg = argp; int len; + Var_Set(arg->var, name, VAR_GLOBAL); DEBUGF(FOR, ("--- %s = %s\n", arg->var, name)); Parse_FromString(Var_Subst(arg->var, (char *)Buf_GetAll(arg->buf, &len), @@ -285,7 +286,7 @@ For_Run(int lineno) forBuf = NULL; forLst = NULL; - Lst_ForEach(arg.lst, ForExec, (void *)&arg); + Lst_ForEach(arg.lst, ForExec, &arg); free(arg.var); Lst_Destroy(arg.lst, free); diff --git a/usr.bin/make/hash.c b/usr.bin/make/hash.c index 2dfaae909f..3dbba14956 100644 --- a/usr.bin/make/hash.c +++ b/usr.bin/make/hash.c @@ -38,7 +38,7 @@ * * @(#)hash.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.bin/make/hash.c,v 1.9 1999/09/11 13:08:01 hoek Exp $ - * $DragonFly: src/usr.bin/make/hash.c,v 1.9 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/hash.c,v 1.10 2004/12/16 00:17:05 okumoto Exp $ */ /* hash.c -- @@ -104,7 +104,7 @@ Hash_InitTable(Hash_Table *t, int numBuckets) t->numEntries = 0; t->size = i; t->mask = i - 1; - t->bucketPtr = hp = (struct Hash_Entry **)emalloc(sizeof(*hp) * i); + t->bucketPtr = hp = emalloc(sizeof(*hp) * i); while (--i >= 0) *hp++ = NULL; } @@ -126,7 +126,6 @@ Hash_InitTable(Hash_Table *t, int numBuckets) * *--------------------------------------------------------- */ - void Hash_DeleteTable(Hash_Table *t) { @@ -136,10 +135,10 @@ Hash_DeleteTable(Hash_Table *t) for (hp = t->bucketPtr, i = t->size; --i >= 0;) { for (h = *hp++; h != NULL; h = nexth) { nexth = h->next; - free((char *)h); + free(h); } } - free((char *)t->bucketPtr); + free(t->bucketPtr); /* * Set up the hash table to cause memory faults on any future access @@ -165,7 +164,6 @@ Hash_DeleteTable(Hash_Table *t) * *--------------------------------------------------------- */ - Hash_Entry * Hash_FindEntry(Hash_Table *t, char *key) { @@ -200,7 +198,6 @@ Hash_FindEntry(Hash_Table *t, char *key) * Memory may be allocated, and the hash buckets may be modified. *--------------------------------------------------------- */ - Hash_Entry * Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr) { @@ -233,7 +230,7 @@ Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr) */ if (t->numEntries >= rebuildLimit * t->size) RebuildTable(t); - e = (Hash_Entry *)emalloc(sizeof(*e) + keylen); + e = emalloc(sizeof(*e) + keylen); hp = &t->bucketPtr[h & t->mask]; e->next = *hp; *hp = e; @@ -263,7 +260,6 @@ Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr) * *--------------------------------------------------------- */ - void Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e) { @@ -275,7 +271,7 @@ Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e) (p = *hp) != NULL; hp = &p->next) { if (p == e) { *hp = p->next; - free((char *)p); + free(p); t->numEntries--; return; } @@ -302,7 +298,6 @@ Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e) * *--------------------------------------------------------- */ - Hash_Entry * Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr) { @@ -330,7 +325,6 @@ Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr) * *--------------------------------------------------------- */ - Hash_Entry * Hash_EnumNext(Hash_Search *searchPtr) { @@ -374,7 +368,6 @@ Hash_EnumNext(Hash_Search *searchPtr) * *--------------------------------------------------------- */ - static void RebuildTable(Hash_Table *t) { @@ -388,7 +381,7 @@ RebuildTable(Hash_Table *t) i <<= 1; t->size = i; t->mask = mask = i - 1; - t->bucketPtr = hp = (struct Hash_Entry **)emalloc(sizeof(*hp) * i); + t->bucketPtr = hp = emalloc(sizeof(*hp) * i); while (--i >= 0) *hp++ = NULL; for (hp = oldhp, i = oldsize; --i >= 0;) { @@ -399,5 +392,5 @@ RebuildTable(Hash_Table *t) *xp = e; } } - free((char *)oldhp); + free(oldhp); } diff --git a/usr.bin/make/hash.h b/usr.bin/make/hash.h index 22d89393c4..f01c2760a0 100644 --- a/usr.bin/make/hash.h +++ b/usr.bin/make/hash.h @@ -38,7 +38,7 @@ * * from: @(#)hash.h 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.bin/make/hash.h,v 1.8 1999/08/28 01:03:30 peter Exp $ - * $DragonFly: src/usr.bin/make/hash.h,v 1.7 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/hash.h,v 1.8 2004/12/16 00:17:05 okumoto Exp $ */ /* hash.h -- @@ -100,7 +100,7 @@ typedef struct Hash_Search { * char *val; */ -#define Hash_SetValue(h, val) ((h)->clientData = (void *)(val)) +#define Hash_SetValue(h, val) ((h)->clientData = (val)) /* * Hash_Size(n) returns the number of words in an object of n bytes diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index 7b6507d7e4..b290a23e99 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -38,7 +38,7 @@ * * @(#)job.c 8.2 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/job.c,v 1.17.2.2 2001/02/13 03:13:57 will Exp $ - * $DragonFly: src/usr.bin/make/job.c,v 1.26 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/job.c,v 1.27 2004/12/16 00:17:05 okumoto Exp $ */ #ifndef OLD_JOKE @@ -327,7 +327,7 @@ JobCatchSig(int signo) static int JobCondPassSig(void *jobp, void *signop) { - Job *job = (Job *)jobp; + Job *job = jobp; int signo = *(int *)signop; DEBUGF(JOB, ("JobCondPassSig passing signal %d to child %d.\n", @@ -361,7 +361,7 @@ JobPassSig(int signo) sigprocmask(SIG_SETMASK, &nmask, &omask); DEBUGF(JOB, ("JobPassSig(%d) called.\n", signo)); - Lst_ForEach(jobs, JobCondPassSig, (void *)&signo); + Lst_ForEach(jobs, JobCondPassSig, &signo); /* * Deal with proper cleanup based on the signal received. We only run @@ -400,7 +400,7 @@ JobPassSig(int signo) KILL(getpid(), signo); signo = SIGCONT; - Lst_ForEach(jobs, JobCondPassSig, (void *)&signo); + Lst_ForEach(jobs, JobCondPassSig, &signo); sigprocmask(SIG_SETMASK, &omask, NULL); sigprocmask(SIG_SETMASK, &omask, NULL); @@ -425,6 +425,7 @@ JobPassSig(int signo) static int JobCmpPid(void *job, void *pid) { + return (*(int *)pid - ((Job *)job)->pid); } @@ -470,16 +471,15 @@ JobPrintCommand(void *cmdp, void *jobp) * command */ char *cmdStart; /* Start of expanded command */ LstNode cmdNode; /* Node for replacing the command */ - char *cmd = (char *)cmdp; - Job *job = (Job *)jobp; + char *cmd = cmdp; + Job *job = jobp; noSpecials = (noExecute && !(job->node->type & OP_MAKE)); if (strcmp(cmd, "...") == 0) { job->node->type |= OP_SAVE_CMDS; if ((job->flags & JOB_IGNDOTS) == 0) { - job->tailCmds = Lst_Succ(Lst_Member(job->node->commands, - (void *)cmd)); + job->tailCmds = Lst_Succ(Lst_Member(job->node->commands, cmd)); return (1); } return (0); @@ -496,9 +496,9 @@ JobPrintCommand(void *cmdp, void *jobp) * For debugging, we replace each command with the result of expanding * the variables in the command. */ - cmdNode = Lst_Member(job->node->commands, (void *)cmd); + cmdNode = Lst_Member(job->node->commands, cmd); cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE); - Lst_Replace(cmdNode, (void *)cmdStart); + Lst_Replace(cmdNode, cmdStart); cmdTemplate = "%s\n"; @@ -603,7 +603,7 @@ JobPrintCommand(void *cmdp, void *jobp) * echoOff command. Otherwise we issue it and pretend it was on * for the whole command... */ - if (!shutUp && !(job->flags & JOB_SILENT) && commandShell->hasEchoCtl){ + if (!shutUp && !(job->flags & JOB_SILENT) && commandShell->hasEchoCtl) { DBPRINTF("%s\n", commandShell->echoOff); shutUp = TRUE; } @@ -633,7 +633,7 @@ static int JobSaveCommand(void *cmd, void *gn) { - cmd = (void *)Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE); + cmd = Var_Subst(NULL, cmd, gn, FALSE); Lst_AtEnd(postCommands->commands, cmd); return (0); } @@ -790,7 +790,7 @@ JobFinish(Job *job, int *status) fprintf(out, "*** Stopped -- signal %d\n", WSTOPSIG(*status)); job->flags |= JOB_RESUME; - Lst_AtEnd(stoppedJobs, (void *)job); + Lst_AtEnd(stoppedJobs, job); fflush(out); return; } else if (WTERMSIG(*status) == SIGCONT) { @@ -819,7 +819,7 @@ JobFinish(Job *job, int *status) #endif } job->flags &= ~JOB_CONTINUING; - Lst_AtEnd(jobs, (void *)job); + Lst_AtEnd(jobs, job); nJobs += 1; DEBUGF(JOB, ("Process %d is continuing locally.\n", job->pid)); if (nJobs == maxJobs) { @@ -885,8 +885,7 @@ JobFinish(Job *job, int *status) */ if (job->tailCmds != NULL) { Lst_ForEachFrom(job->node->commands, job->tailCmds, - JobSaveCommand, - (void *)job->node); + JobSaveCommand, job->node); } job->node->made = MADE; Make_Update(job->node); @@ -937,7 +936,7 @@ Job_Touch(GNode *gn, Boolean silent) int streamID; /* ID of stream opened to do the touch */ struct utimbuf times; /* Times for utime() call */ - if (gn->type & (OP_JOIN|OP_USE|OP_EXEC|OP_OPTIONAL)) { + if (gn->type & (OP_JOIN | OP_USE | OP_EXEC | OP_OPTIONAL)) { /* * .JOIN, .USE, .ZEROTIME and .OPTIONAL targets are "virtual" targets * and, as such, shouldn't really be created. @@ -1196,7 +1195,7 @@ JobExec(Job *job, char **argv) * Now the job is actually running, add it to the table. */ nJobs += 1; - Lst_AtEnd(jobs, (void *)job); + Lst_AtEnd(jobs, job); if (nJobs == maxJobs) { jobFull = TRUE; } @@ -1387,7 +1386,7 @@ JobStart(GNode *gn, int flags, Job *previous) previous->flags &= ~(JOB_FIRST|JOB_IGNERR|JOB_SILENT); job = previous; } else { - job = (Job *)emalloc(sizeof(Job)); + job = emalloc(sizeof(Job)); flags |= JOB_FIRST; } @@ -1468,8 +1467,7 @@ JobStart(GNode *gn, int flags, Job *previous) LstNode ln = Lst_Next(gn->commands); if ((ln == NULL) || - JobPrintCommand((void *)Lst_Datum(ln), - (void *)job)) + JobPrintCommand(Lst_Datum(ln), job)) { noExec = TRUE; Lst_Close(gn->commands); @@ -1494,7 +1492,7 @@ JobStart(GNode *gn, int flags, Job *previous) * We can do all the commands at once. hooray for sanity */ numCommands = 0; - Lst_ForEach(gn->commands, JobPrintCommand, (void *)job); + Lst_ForEach(gn->commands, JobPrintCommand, job); /* * If we didn't print out any commands to the shell script, @@ -1520,7 +1518,7 @@ JobStart(GNode *gn, int flags, Job *previous) * doesn't do any harm in this case and may do some good. */ if (cmdsOK) { - Lst_ForEach(gn->commands, JobPrintCommand, (void *)job); + Lst_ForEach(gn->commands, JobPrintCommand, job); } /* * Don't execute the shell, thank you. @@ -1534,7 +1532,7 @@ JobStart(GNode *gn, int flags, Job *previous) * up the graph. */ job->cmdFILE = stdout; - Job_Touch(gn, job->flags&JOB_SILENT); + Job_Touch(gn, job->flags & JOB_SILENT); noExec = TRUE; } @@ -1560,8 +1558,7 @@ JobStart(GNode *gn, int flags, Job *previous) if (aborting == 0) { if (job->tailCmds != NULL) { Lst_ForEachFrom(job->node->commands, job->tailCmds, - JobSaveCommand, - (void *)job->node); + JobSaveCommand, job->node); } job->node->made = MADE; Make_Update(job->node); @@ -1618,7 +1615,7 @@ JobStart(GNode *gn, int flags, Job *previous) DEBUGF(JOB, ("Can only run job locally.\n")); job->flags |= JOB_RESTART; - Lst_AtEnd(stoppedJobs, (void *)job); + Lst_AtEnd(stoppedJobs, job); } else { if (nJobs >= maxJobs) { /* @@ -1716,7 +1713,6 @@ JobDoOutput(Job *job, Boolean finish) FILE *oFILE; /* Stream pointer to shell's output file */ char inLine[132]; - if (usePipes) { /* * Read as many bytes as will fit in the buffer. @@ -1853,8 +1849,8 @@ end_loop: */ oFILE = fopen(job->outFile, "r"); if (oFILE != NULL) { - fprintf(stdout, "Results of making %s:\n", job->node->name); - fflush(stdout); + fprintf(stdout, "Results of making %s:\n", job->node->name); + fflush(stdout); while (fgets(inLine, sizeof(inLine), oFILE) != NULL) { char *cp, *endp, *oendp; @@ -1877,8 +1873,8 @@ end_loop: fflush(stdout); } } - fclose(oFILE); - eunlink(job->outFile); + fclose(oFILE); + eunlink(job->outFile); } } } @@ -1923,23 +1919,23 @@ Job_CatchChildren(Boolean block) break; DEBUGF(JOB, ("Process %d exited or stopped.\n", pid)); - jnode = Lst_Find(jobs, (void *)&pid, JobCmpPid); + jnode = Lst_Find(jobs, &pid, JobCmpPid); if (jnode == NULL) { if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGCONT)) { - jnode = Lst_Find(stoppedJobs, (void *)&pid, JobCmpPid); + jnode = Lst_Find(stoppedJobs, &pid, JobCmpPid); if (jnode == NULL) { Error("Resumed child (%d) not in table", pid); continue; } - job = (Job *)Lst_Datum(jnode); + job = Lst_Datum(jnode); Lst_Remove(stoppedJobs, jnode); } else { Error("Child (%d) not in table?", pid); continue; } } else { - job = (Job *)Lst_Datum(jnode); + job = Lst_Datum(jnode); Lst_Remove(jobs, jnode); nJobs -= 1; if (fifoFd >= 0 && maxJobs > 1) { @@ -2025,8 +2021,8 @@ Job_CatchOutput(int flag) if (flag && jobFull && fifoFd >= 0) FD_SET(fifoFd, &readfds); - nfds = select(FD_SETSIZE, &readfds, (fd_set *) 0, - (fd_set *) 0, &timeout); + nfds = select(FD_SETSIZE, &readfds, (fd_set *)NULL, + (fd_set *)NULL, &timeout); if (nfds <= 0) { if (interrupted) JobPassSig(interrupted); @@ -2040,7 +2036,7 @@ Job_CatchOutput(int flag) Punt("Cannot open job table"); } while (nfds && (ln = Lst_Next(jobs)) != NULL) { - job = (Job *)Lst_Datum(ln); + job = Lst_Datum(ln); if (FD_ISSET(job->inPipe, &readfds)) { JobDoOutput(job, FALSE); nfds -= 1; @@ -2210,7 +2206,7 @@ Job_Init(int maxproc) while (maxproc-- > 0) { write(fifoFd, "+", 1); } - /*The master make does not get a magic token */ + /* The master make does not get a magic token */ jobFull = TRUE; maxJobs = 0; } else { @@ -2309,7 +2305,7 @@ Job_Init(int maxproc) begin = Targ_FindNode(".BEGIN", TARG_NOCREATE); if (begin != NULL) { - JobStart(begin, JOB_SPECIAL, (Job *)0); + JobStart(begin, JOB_SPECIAL, (Job *)NULL); while (nJobs) { Job_CatchOutput(0); Job_CatchChildren(!usePipes); @@ -2642,7 +2638,7 @@ JobInterrupt(int runINTERRUPT, int signo) Lst_Open(jobs); while ((ln = Lst_Next(jobs)) != NULL) { - job = (Job *)Lst_Datum(ln); + job = Lst_Datum(ln); if (!Targ_Precious(job->node)) { char *file = (job->node->path == NULL ? @@ -2668,7 +2664,7 @@ JobInterrupt(int runINTERRUPT, int signo) if (interrupt != NULL) { ignoreErrors = FALSE; - JobStart(interrupt, JOB_IGNDOTS, (Job *)0); + JobStart(interrupt, JOB_IGNDOTS, (Job *)NULL); while (nJobs) { Job_CatchOutput(0); Job_CatchChildren(!usePipes); @@ -2762,10 +2758,9 @@ Job_AbortAll(void) aborting = ABORT_ERROR; if (nJobs) { - Lst_Open(jobs); while ((ln = Lst_Next(jobs)) != NULL) { - job = (Job *)Lst_Datum(ln); + job = Lst_Datum(ln); /* * kill the child process with increasingly drastic signals to make @@ -2803,6 +2798,6 @@ JobRestartJobs(void) { while (!jobFull && !Lst_IsEmpty(stoppedJobs)) { DEBUGF(JOB, ("Job queue is not full. Restarting a stopped job.\n")); - JobRestart((Job *)Lst_DeQueue(stoppedJobs)); + JobRestart(Lst_DeQueue(stoppedJobs)); } } diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 487945fedf..67aae68ea1 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -38,7 +38,7 @@ * @(#) Copyright (c) 1988, 1989, 1990, 1993 The Regents of the University of California. All rights reserved. * @(#)main.c 8.3 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/main.c,v 1.35.2.10 2003/12/16 08:34:11 des Exp $ - * $DragonFly: src/usr.bin/make/main.c,v 1.31 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/main.c,v 1.32 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -251,7 +251,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { case 'E': p = emalloc(strlen(optarg) + 1); strcpy(p, optarg); - Lst_AtEnd(envFirstVars, (void *)p); + Lst_AtEnd(envFirstVars, p); MFLAGS_append("-E", optarg); break; case 'e': @@ -259,7 +259,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { MFLAGS_append("-e", NULL); break; case 'f': - Lst_AtEnd(makefiles, (void *)optarg); + Lst_AtEnd(makefiles, optarg); break; case 'i': ignoreErrors = TRUE; @@ -342,7 +342,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { optind = 1; /* - */ goto rearg; } - Lst_AtEnd(create, (void *)estrdup(*argv)); + Lst_AtEnd(create, estrdup(*argv)); } } @@ -580,7 +580,6 @@ main(int argc, char **argv) forceJobs = FALSE; /* No -j flag */ compatMake = FALSE; /* No compat mode */ - /* * Initialize the parsing, directory and variable modules to prepare * for the reading of inclusion paths and variable settings on the @@ -707,9 +706,8 @@ main(int argc, char **argv) if (!Lst_IsEmpty(create)) { LstNode ln; - for (ln = Lst_First(create); ln != NULL; - ln = Lst_Succ(ln)) { - char *name = (char *)Lst_Datum(ln); + for (ln = Lst_First(create); ln != NULL; ln = Lst_Succ(ln)) { + char *name = Lst_Datum(ln); Var_Append(".TARGETS", name, VAR_GLOBAL); } @@ -747,7 +745,7 @@ main(int argc, char **argv) Dir_Expand(_PATH_DEFSYSMK, sysIncPath, sysMkPath); if (Lst_IsEmpty(sysMkPath)) Fatal("make: no system rules (%s).", _PATH_DEFSYSMK); - ln = Lst_Find(sysMkPath, (void *)NULL, ReadMakefile); + ln = Lst_Find(sysMkPath, NULL, ReadMakefile); if (ln != NULL) Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); } @@ -755,7 +753,7 @@ main(int argc, char **argv) if (!Lst_IsEmpty(makefiles)) { LstNode ln; - ln = Lst_Find(makefiles, (void *)NULL, ReadMakefile); + ln = Lst_Find(makefiles, NULL, ReadMakefile); if (ln != NULL) Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); } else if (!ReadMakefile("BSDmakefile", NULL)) @@ -819,12 +817,12 @@ main(int argc, char **argv) ln = Lst_Succ(ln)) { char *value; if (expandVars) { - p1 = emalloc(strlen((char *)Lst_Datum(ln)) + 1 + 3); + p1 = emalloc(strlen(Lst_Datum(ln)) + 1 + 3); /* This sprintf is safe, because of the malloc above */ sprintf(p1, "${%s}", (char *)Lst_Datum(ln)); value = Var_Subst(NULL, p1, VAR_GLOBAL, FALSE); } else { - value = Var_Value((char *)Lst_Datum(ln), + value = Var_Value(Lst_Datum(ln), VAR_GLOBAL, &p1); } printf("%s\n", value ? value : ""); diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index 1b9375aa20..3a520b8e09 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -37,7 +37,7 @@ * * @(#)make.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.bin/make/make.c,v 1.11 1999/09/11 13:08:01 hoek Exp $ - * $DragonFly: src/usr.bin/make/make.c,v 1.12 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/make.c,v 1.13 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -121,7 +121,7 @@ static int MakeTimeStamp(void *pgn, void *cgn) { - return (Make_TimeStamp((GNode *)pgn, (GNode *)cgn)); + return (Make_TimeStamp(pgn, cgn)); } /*- @@ -152,7 +152,7 @@ Make_OODate(GNode *gn) * doesn't depend on their modification time... */ if ((gn->type & (OP_JOIN | OP_USE | OP_EXEC)) == 0) { - Dir_MTime(gn); + Dir_MTime(gn); if (gn->mtime != 0) { DEBUGF(MAKE, ("modified %s...", Targ_FmtTime(gn->mtime))); } else { @@ -240,7 +240,7 @@ Make_OODate(GNode *gn) * thinking they're out-of-date. */ if (!oodate) { - Lst_ForEach(gn->parents, MakeTimeStamp, (void *)gn); + Lst_ForEach(gn->parents, MakeTimeStamp, gn); } return (oodate); @@ -262,11 +262,11 @@ Make_OODate(GNode *gn) static int MakeAddChild(void *gnp, void *lp) { - GNode *gn = (GNode *)gnp; - Lst l = (Lst)lp; + GNode *gn = gnp; + Lst l = lp; if (!gn->make && !(gn->type & OP_USE)) { - Lst_EnQueue(l, (void *)gn); + Lst_EnQueue(l, gn); } return (0); } @@ -300,7 +300,7 @@ Make_HandleUse(GNode *cgn, GNode *pgn) GNode *gn; /* A child of the .USE node */ LstNode ln; /* An element in the children list */ - if (cgn->type & (OP_USE|OP_TRANSFORM)) { + if (cgn->type & (OP_USE | OP_TRANSFORM)) { if ((cgn->type & OP_USE) || Lst_IsEmpty(pgn->commands)) { /* * .USE or transformation and target has no commands -- append @@ -311,7 +311,7 @@ Make_HandleUse(GNode *cgn, GNode *pgn) if (Lst_Open(cgn->children) == SUCCESS) { while ((ln = Lst_Next(cgn->children)) != NULL) { - gn = (GNode *)Lst_Datum(ln); + gn = Lst_Datum(ln); if (Lst_Member(pgn->children, gn) == NULL) { Lst_AtEnd(pgn->children, gn); @@ -342,7 +342,7 @@ static int MakeHandleUse(void *pgn, void *cgn) { - return (Make_HandleUse((GNode *)pgn, (GNode *)cgn)); + return (Make_HandleUse(pgn, cgn)); } /*- @@ -448,7 +448,7 @@ Make_Update(GNode *cgn) if (Lst_Open(cgn->parents) == SUCCESS) { while ((ln = Lst_Next(cgn->parents)) != NULL) { - pgn = (GNode *)Lst_Datum(ln); + pgn = Lst_Datum(ln); if (pgn->make) { pgn->unmade -= 1; @@ -467,7 +467,7 @@ Make_Update(GNode *cgn) * Queue the node up -- any unmade predecessors will * be dealt with in MakeStartJobs. */ - Lst_EnQueue(toBeMade, (void *)pgn); + Lst_EnQueue(toBeMade, pgn); } else if (pgn->unmade < 0) { Error("Graph cycles through %s", pgn->name); } @@ -482,12 +482,12 @@ Make_Update(GNode *cgn) * before. */ for (ln = Lst_First(cgn->successors); ln != NULL; ln = Lst_Succ(ln)) { - GNode *succ = (GNode *)Lst_Datum(ln); + GNode *succ = Lst_Datum(ln); if (succ->make && succ->unmade == 0 && succ->made == UNMADE && - Lst_Member(toBeMade, (void *)succ) == NULL) + Lst_Member(toBeMade, succ) == NULL) { - Lst_EnQueue(toBeMade, (void *)succ); + Lst_EnQueue(toBeMade, succ); } } @@ -500,7 +500,7 @@ Make_Update(GNode *cgn) char *cpref = Var_Value(PREFIX, cgn, &ptr); while ((ln = Lst_Next(cgn->iParents)) != NULL) { - pgn = (GNode *)Lst_Datum (ln); + pgn = Lst_Datum (ln); if (pgn->make) { Var_Set(IMPSRC, cname, pgn); Var_Set(PREFIX, cpref, pgn); @@ -606,7 +606,7 @@ void Make_DoAllVar(GNode *gn) { - Lst_ForEach(gn->children, MakeAddAllSrc, (void *)gn); + Lst_ForEach(gn->children, MakeAddAllSrc, gn); if (!Var_Exists (OODATE, gn)) { Var_Set(OODATE, "", gn); @@ -644,8 +644,8 @@ MakeStartJobs(void) { GNode *gn; - while (!Lst_IsEmpty (toBeMade) && !Job_Full()) { - gn = (GNode *)Lst_DeQueue(toBeMade); + while (!Lst_IsEmpty(toBeMade) && !Job_Full()) { + gn = Lst_DeQueue(toBeMade); DEBUGF(MAKE, ("Examining %s...", gn->name)); /* * Make sure any and all predecessors that are going to be made, @@ -655,7 +655,7 @@ MakeStartJobs(void) LstNode ln; for (ln = Lst_First(gn->preds); ln != NULL; ln = Lst_Succ(ln)){ - GNode *pgn = (GNode *)Lst_Datum(ln); + GNode *pgn = Lst_Datum(ln); if (pgn->make && pgn->made == UNMADE) { DEBUGF(MAKE, ("predecessor %s not made yet.\n", pgn->name)); @@ -720,8 +720,8 @@ MakeStartJobs(void) static int MakePrintStatus(void *gnp, void *cyclep) { - GNode *gn = (GNode *)gnp; - Boolean cycle = *(Boolean *)cyclep; + GNode *gn = gnp; + Boolean cycle = *(Boolean *)cyclep; if (gn->made == UPTODATE) { printf("`%s' is up to date.\n", gn->name); @@ -741,11 +741,11 @@ MakePrintStatus(void *gnp, void *cyclep) if (gn->made == CYCLE) { Error("Graph cycles through `%s'", gn->name); gn->made = ENDCYCLE; - Lst_ForEach(gn->children, MakePrintStatus, (void *)&t); + Lst_ForEach(gn->children, MakePrintStatus, &t); gn->made = UNMADE; } else if (gn->made != ENDCYCLE) { gn->made = CYCLE; - Lst_ForEach(gn->children, MakePrintStatus, (void *)&t); + Lst_ForEach(gn->children, MakePrintStatus, &t); } } else { printf("`%s' not remade because of errors.\n", gn->name); @@ -796,7 +796,7 @@ Make_Run(Lst targs) * and go on about our business. */ while (!Lst_IsEmpty(examine)) { - gn = (GNode *)Lst_DeQueue(examine); + gn = Lst_DeQueue(examine); if (!gn->make) { gn->make = TRUE; @@ -806,13 +806,13 @@ Make_Run(Lst targs) * Apply any .USE rules before looking for implicit dependencies * to make sure everything has commands that should... */ - Lst_ForEach(gn->children, MakeHandleUse, (void *)gn); + Lst_ForEach(gn->children, MakeHandleUse, gn); Suff_FindDeps(gn); if (gn->unmade != 0) { - Lst_ForEach(gn->children, MakeAddChild, (void *)examine); + Lst_ForEach(gn->children, MakeAddChild, examine); } else { - Lst_EnQueue(toBeMade, (void *)gn); + Lst_EnQueue(toBeMade, gn); } } } @@ -848,7 +848,7 @@ Make_Run(Lst targs) * keepgoing flag was given. */ while (!Job_Empty ()) { - Job_CatchOutput(!Lst_IsEmpty (toBeMade)); + Job_CatchOutput(!Lst_IsEmpty(toBeMade)); Job_CatchChildren(!usePipes); MakeStartJobs(); } @@ -860,7 +860,7 @@ Make_Run(Lst targs) * because some inferior reported an error. */ errors = ((errors == 0) && (numNodes != 0)); - Lst_ForEach(targs, MakePrintStatus, (void *)&errors); + Lst_ForEach(targs, MakePrintStatus, &errors); return (TRUE); } diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 1809ae2bb4..dc5174f872 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -37,7 +37,7 @@ * * @(#)parse.c 8.3 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/parse.c,v 1.22.2.2 2004/07/10 08:14:42 eik Exp $ - * $DragonFly: src/usr.bin/make/parse.c,v 1.21 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/parse.c,v 1.22 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -319,13 +319,13 @@ Parse_Error(int type, const char *fmt, ...) static int ParseLinkSrc(void *pgnp, void *cgnp) { - GNode *pgn = (GNode *)pgnp; - GNode *cgn = (GNode *)cgnp; + GNode *pgn = pgnp; + GNode *cgn = cgnp; - if (Lst_Member(pgn->children, (void *)cgn) == NULL) { - Lst_AtEnd (pgn->children, (void *)cgn); + if (Lst_Member(pgn->children, cgn) == NULL) { + Lst_AtEnd(pgn->children, cgn); if (specType == Not) { - Lst_AtEnd (cgn->parents, (void *)pgn); + Lst_AtEnd(cgn->parents, pgn); } pgn->unmade += 1; } @@ -351,8 +351,8 @@ ParseLinkSrc(void *pgnp, void *cgnp) static int ParseDoOp(void *gnp, void *opp) { - GNode *gn = (GNode *)gnp; - int op = *(int *)opp; + GNode *gn = gnp; + int op = *(int *)opp; /* * If the dependency mask of the operator and the node don't match and @@ -388,15 +388,15 @@ ParseDoOp(void *gnp, void *opp) * anything with their local variables, but better safe than * sorry. */ - Lst_ForEach(gn->parents, ParseLinkSrc, (void *)cohort); + Lst_ForEach(gn->parents, ParseLinkSrc, cohort); cohort->type = OP_DOUBLEDEP|OP_INVISIBLE; - Lst_AtEnd(gn->cohorts, (void *)cohort); + Lst_AtEnd(gn->cohorts, cohort); /* * Replace the node in the targets list with the new copy */ - ln = Lst_Member(targets, (void *)gn); - Lst_Replace(ln, (void *)cohort); + ln = Lst_Member(targets, gn); + Lst_Replace(ln, cohort); gn = cohort; } /* @@ -427,8 +427,8 @@ ParseDoOp(void *gnp, void *opp) static int ParseAddDep(void *pp, void *sp) { - GNode *p = (GNode *)pp; - GNode *s = (GNode *)sp; + GNode *p = pp; + GNode *s = sp; if (p->order < s->order) { /* @@ -436,8 +436,8 @@ ParseAddDep(void *pp, void *sp) * but checking is tedious, and the debugging output can show the * problem */ - Lst_AtEnd(p->successors, (void *)s); - Lst_AtEnd(s->preds, (void *)p); + Lst_AtEnd(p->successors, s); + Lst_AtEnd(s->preds, p); return (0); } else @@ -472,7 +472,7 @@ ParseDoSrc(int tOp, char *src, Lst allsrc) if (keywd != -1) { int op = parseKeywords[keywd].op; if (op != 0) { - Lst_ForEach (targets, ParseDoOp, (void *)&op); + Lst_ForEach(targets, ParseDoOp, &op); return; } if (parseKeywords[keywd].spec == Wait) { @@ -492,7 +492,7 @@ ParseDoSrc(int tOp, char *src, Lst allsrc) * invoked if the user didn't specify a target on the command * line. This is to allow #ifmake's to succeed, or something... */ - Lst_AtEnd (create, (void *)estrdup(src)); + Lst_AtEnd(create, estrdup(src)); /* * Add the name to the .TARGETS variable as well, so the user cna * employ that, if desired. @@ -507,8 +507,8 @@ ParseDoSrc(int tOp, char *src, Lst allsrc) */ gn = Targ_FindNode(src, TARG_CREATE); if (predecessor != NULL) { - Lst_AtEnd(predecessor->successors, (void *)gn); - Lst_AtEnd(gn->preds, (void *)predecessor); + Lst_AtEnd(predecessor->successors, gn); + Lst_AtEnd(gn->preds, predecessor); } /* * The current source now becomes the predecessor for the next one. @@ -532,18 +532,18 @@ ParseDoSrc(int tOp, char *src, Lst allsrc) if (tOp) { gn->type |= tOp; } else { - Lst_ForEach (targets, ParseLinkSrc, (void *)gn); + Lst_ForEach(targets, ParseLinkSrc, gn); } if ((gn->type & OP_OPMASK) == OP_DOUBLEDEP) { GNode *cohort; LstNode ln; for (ln=Lst_First(gn->cohorts); ln != NULL; ln = Lst_Succ(ln)){ - cohort = (GNode *)Lst_Datum(ln); + cohort = Lst_Datum(ln); if (tOp) { cohort->type |= tOp; } else { - Lst_ForEach(targets, ParseLinkSrc, (void *)cohort); + Lst_ForEach(targets, ParseLinkSrc, cohort); } } } @@ -551,9 +551,9 @@ ParseDoSrc(int tOp, char *src, Lst allsrc) } gn->order = waiting; - Lst_AtEnd(allsrc, (void *)gn); + Lst_AtEnd(allsrc, gn); if (waiting) { - Lst_ForEach(allsrc, ParseAddDep, (void *)gn); + Lst_ForEach(allsrc, ParseAddDep, gn); } } @@ -575,7 +575,8 @@ ParseDoSrc(int tOp, char *src, Lst allsrc) static int ParseFindMain(void *gnp, void *dummy __unused) { - GNode *gn = (GNode *) gnp; + GNode *gn = gnp; + if ((gn->type & (OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM)) == 0) { mainNode = gn; Targ_SetMain(gn); @@ -602,7 +603,7 @@ static int ParseAddDir(void *path, void *name) { - Dir_AddDir((Lst)path, (char *)name); + Dir_AddDir(path, name); return(0); } @@ -623,7 +624,7 @@ static int ParseClearPath(void *path, void *dummy __unused) { - Dir_ClearPath((Lst)path); + Dir_ClearPath(path); return (0); } @@ -681,15 +682,15 @@ ParseDoDependency (char *line) specType = Not; waiting = 0; - paths = (Lst)NULL; + paths = NULL; curTargs = Lst_Init(FALSE); curSrcs = Lst_Init(FALSE); do { for (cp = line; - *cp && !isspace ((unsigned char)*cp) && *cp != '('; - cp++) + *cp && !isspace((unsigned char)*cp) && *cp != '('; + cp++) { if (*cp == '$') { /* @@ -780,7 +781,7 @@ ParseDoDependency (char *line) * Have a word in line. See if it's a special target and set * specType to match it. */ - if (*line == '.' && isupper ((unsigned char)line[1])) { + if (*line == '.' && isupper((unsigned char)line[1])) { /* * See if the target is a special target that must have it * or its sources handled specially. @@ -828,7 +829,7 @@ ParseDoDependency (char *line) if (paths == NULL) { paths = Lst_Init(FALSE); } - Lst_AtEnd(paths, (void *)dirSearchPath); + Lst_AtEnd(paths, dirSearchPath); break; case Main: if (!Lst_IsEmpty(create)) { @@ -840,12 +841,12 @@ ParseDoDependency (char *line) case Interrupt: gn = Targ_FindNode(line, TARG_CREATE); gn->type |= OP_NOTMAIN; - Lst_AtEnd(targets, (void *)gn); + Lst_AtEnd(targets, gn); break; case Default: gn = Targ_NewGN(".DEFAULT"); gn->type |= (OP_NOTMAIN|OP_TRANSFORM); - Lst_AtEnd(targets, (void *)gn); + Lst_AtEnd(targets, gn); DEFAULT = gn; break; case NotParallel: @@ -881,7 +882,7 @@ ParseDoDependency (char *line) if (paths == (Lst)NULL) { paths = Lst_Init(FALSE); } - Lst_AtEnd(paths, (void *)path); + Lst_AtEnd(paths, path); } } } @@ -908,11 +909,11 @@ ParseDoDependency (char *line) * No wildcards, but we want to avoid code duplication, * so create a list with the word on it. */ - Lst_AtEnd(curTargs, (void *)line); + Lst_AtEnd(curTargs, line); } while(!Lst_IsEmpty(curTargs)) { - char *targName = (char *)Lst_DeQueue(curTargs); + char *targName = Lst_DeQueue(curTargs); if (!Suff_IsTransform (targName)) { gn = Targ_FindNode(targName, TARG_CREATE); @@ -920,7 +921,7 @@ ParseDoDependency (char *line) gn = Suff_AddTransform(targName); } - Lst_AtEnd(targets, (void *)gn); + Lst_AtEnd(targets, gn); } } else if (specType == ExPath && *line != '.' && *line != '\0') { Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line); @@ -944,7 +945,7 @@ ParseDoDependency (char *line) Parse_Error(PARSE_WARNING, "Extra target ignored"); } } else { - while (*cp && isspace ((unsigned char) *cp)) { + while (*cp && isspace((unsigned char)*cp)) { cp++; } } @@ -957,7 +958,7 @@ ParseDoDependency (char *line) Lst_Destroy(curTargs, NOFREE); if (!Lst_IsEmpty(targets)) { - switch(specType) { + switch (specType) { default: Parse_Error(PARSE_WARNING, "Special and mundane targets don't mix. Mundane ones ignored"); break; @@ -997,12 +998,12 @@ ParseDoDependency (char *line) cp++; /* Advance beyond operator */ - Lst_ForEach(targets, ParseDoOp, (void *)&op); + Lst_ForEach(targets, ParseDoOp, &op); /* * Get to the first source */ - while (*cp && isspace ((unsigned char)*cp)) { + while (*cp && isspace((unsigned char)*cp)) { cp++; } line = cp; @@ -1031,7 +1032,7 @@ ParseDoDependency (char *line) beSilent = TRUE; break; case ExPath: - Lst_ForEach(paths, ParseClearPath, (void *)NULL); + Lst_ForEach(paths, ParseClearPath, NULL); break; case Posix: Var_Set("%POSIX", "1003.2", VAR_GLOBAL); @@ -1090,7 +1091,7 @@ ParseDoDependency (char *line) * has no valid suffix. */ char savech; - while (*cp && !isspace ((unsigned char)*cp)) { + while (*cp && !isspace((unsigned char)*cp)) { cp++; } savech = *cp; @@ -1100,7 +1101,7 @@ ParseDoDependency (char *line) Suff_AddSuffix(line); break; case ExPath: - Lst_ForEach(paths, ParseAddDir, (void *)line); + Lst_ForEach(paths, ParseAddDir, line); break; case Includes: Suff_AddInclude(line); @@ -1118,7 +1119,7 @@ ParseDoDependency (char *line) if (savech != '\0') { cp++; } - while (*cp && isspace ((unsigned char)*cp)) { + while (*cp && isspace((unsigned char)*cp)) { cp++; } line = cp; @@ -1133,7 +1134,7 @@ ParseDoDependency (char *line) * specifications (i.e. things with left parentheses in them) * and handle them accordingly. */ - while (*cp && !isspace ((unsigned char)*cp)) { + while (*cp && !isspace((unsigned char)*cp)) { if ((*cp == '(') && (cp > line) && (cp[-1] != '$')) { /* * Only stop for a left parenthesis if it isn't at the @@ -1158,7 +1159,7 @@ ParseDoDependency (char *line) } while (!Lst_IsEmpty (sources)) { - gnp = (GNode *)Lst_DeQueue(sources); + gnp = Lst_DeQueue(sources); ParseDoSrc(tOp, gnp->name, curSrcs); } Lst_Destroy(sources, NOFREE); @@ -1171,7 +1172,7 @@ ParseDoDependency (char *line) ParseDoSrc(tOp, line, curSrcs); } - while (*cp && isspace ((unsigned char)*cp)) { + while (*cp && isspace((unsigned char)*cp)) { cp++; } line = cp; @@ -1185,7 +1186,7 @@ ParseDoDependency (char *line) * the first dependency line that is actually a real target * (i.e. isn't a .USE or .EXEC rule) to be made. */ - Lst_ForEach(targets, ParseFindMain, (void *)0); + Lst_ForEach(targets, ParseFindMain, NULL); } /* @@ -1341,7 +1342,7 @@ Parse_DoVar(char *line, GNode *ctxt) * Skip to operator character, nulling out whitespace as we go */ for (cp = line + 1; *cp != '='; cp++) { - if (isspace ((unsigned char)*cp)) { + if (isspace((unsigned char)*cp)) { *cp = '\0'; } } @@ -1397,7 +1398,7 @@ Parse_DoVar(char *line, GNode *ctxt) break; } - while (isspace ((unsigned char)*cp)) { + while (isspace((unsigned char)*cp)) { cp++; } @@ -1463,7 +1464,6 @@ Parse_DoVar(char *line, GNode *ctxt) } } - /*- * ParseAddCmd -- * Lst_ForEach function to add a command line to all targets @@ -1477,7 +1477,7 @@ Parse_DoVar(char *line, GNode *ctxt) static int ParseAddCmd(void *gnp, void *cmd) { - GNode *gn = (GNode *) gnp; + GNode *gn = gnp; /* if target already supplied, ignore commands */ if (!(gn->type & OP_HAS_COMMANDS)) @@ -1508,8 +1508,7 @@ ParseAddCmd(void *gnp, void *cmd) static void ParseHasCommands(void *gnp) { - - GNode *gn = (GNode *) gnp; + GNode *gn = gnp; if (!Lst_IsEmpty(gn->commands)) { gn->type |= OP_HAS_COMMANDS; @@ -1696,20 +1695,20 @@ ParseDoInclude (char *file) else newName = str_concat(Fname, file, STR_ADDSLASH); fullname = Dir_FindFile(newName, parseIncPath); - if (fullname == (char *)NULL) { + if (fullname == NULL) { fullname = Dir_FindFile(newName, dirSearchPath); } free(newName); *prefEnd = '/'; } else { - fullname = (char *)NULL; + fullname = NULL; } free(Fname); } else { - fullname = (char *)NULL; + fullname = NULL; } - if (fullname == (char *)NULL) { + if (fullname == NULL) { /* * System makefile or makefile wasn't found in same directory as * included makefile. Search for it first on the -I search path, @@ -1717,12 +1716,12 @@ ParseDoInclude (char *file) * XXX: Suffix specific? */ fullname = Dir_FindFile(file, parseIncPath); - if (fullname == (char *)NULL) { + if (fullname == NULL) { fullname = Dir_FindFile(file, dirSearchPath); } } - if (fullname == (char *)NULL) { + if (fullname == NULL) { /* * Still haven't found the makefile. Look for it on the system * path as a last resort. @@ -1730,7 +1729,7 @@ ParseDoInclude (char *file) fullname = Dir_FindFile(file, sysIncPath); } - if (fullname == (char *) NULL) { + if (fullname == NULL) { *cp = endc; Parse_Error(PARSE_FATAL, "Could not find %s", file); return; @@ -1745,10 +1744,10 @@ ParseDoInclude (char *file) * is placed on a list with other IFile structures. The list makes * a very nice stack to track how we got here... */ - oldFile = (IFile *) emalloc(sizeof (IFile)); - memcpy(oldFile, &curFile, sizeof (IFile)); + oldFile = emalloc(sizeof (IFile)); + memcpy(oldFile, &curFile, sizeof(IFile)); - Lst_AtFront(includes, (void *)oldFile); + Lst_AtFront(includes, oldFile); /* * Once the previous state has been saved, we can get down to reading @@ -1761,7 +1760,7 @@ ParseDoInclude (char *file) curFile.F = fopen(fullname, "r"); curFile.p = NULL; - if (curFile.F == (FILE * ) NULL) { + if (curFile.F == NULL) { Parse_Error(PARSE_FATAL, "Cannot open %s", fullname); /* * Pop to previous file @@ -1792,13 +1791,13 @@ Parse_FromString(char *str, int lineno) DEBUGF(FOR, ("%s\n---- at line %d\n", str, lineno)); - oldFile = (IFile *)emalloc(sizeof(IFile)); + oldFile = emalloc(sizeof(IFile)); memcpy(oldFile, &curFile, sizeof(IFile)); - Lst_AtFront (includes, (void *)oldFile); + Lst_AtFront(includes, oldFile); curFile.F = NULL; - curFile.p = (PTR *)emalloc(sizeof (PTR)); + curFile.p = emalloc(sizeof (PTR)); curFile.p->str = curFile.p->ptr = str; curFile.lineno = lineno; curFile.fname = estrdup(curFile.fname); @@ -1862,11 +1861,11 @@ ParseTraditionalInclude (char *file) * search path, if not found in a -I directory. */ fullname = Dir_FindFile(file, parseIncPath); - if (fullname == (char *)NULL) { + if (fullname == NULL) { fullname = Dir_FindFile(file, dirSearchPath); } - if (fullname == (char *)NULL) { + if (fullname == NULL) { /* * Still haven't found the makefile. Look for it on the system * path as a last resort. @@ -1874,7 +1873,7 @@ ParseTraditionalInclude (char *file) fullname = Dir_FindFile(file, sysIncPath); } - if (fullname == (char *) NULL) { + if (fullname == NULL) { Parse_Error(PARSE_FATAL, "Could not find %s", file); return; } @@ -1886,10 +1885,10 @@ ParseTraditionalInclude (char *file) * is placed on a list with other IFile structures. The list makes * a very nice stack to track how we got here... */ - oldFile = (IFile *)emalloc(sizeof(IFile)); + oldFile = emalloc(sizeof(IFile)); memcpy(oldFile, &curFile, sizeof(IFile)); - Lst_AtFront(includes, (void *)oldFile); + Lst_AtFront(includes, oldFile); /* * Once the previous state has been saved, we can get down to reading @@ -1902,7 +1901,7 @@ ParseTraditionalInclude (char *file) curFile.F = fopen(fullname, "r"); curFile.p = NULL; - if (curFile.F == (FILE * )NULL) { + if (curFile.F == NULL) { Parse_Error(PARSE_FATAL, "Cannot open %s", fullname); /* * Pop to previous file @@ -1940,7 +1939,7 @@ ParseEOF(int opened) return (DONE); } - ifile = (IFile *)Lst_DeQueue(includes); + ifile = Lst_DeQueue(includes); free(curFile.fname); if (opened && curFile.F) { fclose(curFile.F); @@ -2052,7 +2051,7 @@ ParseSkipLine(int skip, int keep_newline) if (c == EOF) { Parse_Error(PARSE_FATAL, "Unclosed conditional/for loop"); Buf_Destroy(buf, TRUE); - return ((char *)NULL); + return (NULL); } curFile.lineno++; @@ -2327,7 +2326,7 @@ test_char: /* * Hit end-of-file, so return a NULL line to indicate this. */ - return ((char *)NULL); + return (NULL); } } @@ -2349,7 +2348,7 @@ ParseFinishLine(void) { if (inLine) { - Lst_ForEach(targets, Suff_EndTransform, (void *)NULL); + Lst_ForEach(targets, Suff_EndTransform, NULL); Lst_Destroy(targets, ParseHasCommands); targets = NULL; inLine = FALSE; @@ -2451,7 +2450,7 @@ Parse_File(char *name, FILE *stream) * commands of all targets in the dependency spec */ Lst_ForEach(targets, ParseAddCmd, cp); - Lst_AtEnd(targCmds, (void *)line); + Lst_AtEnd(targCmds, line); continue; } else { Parse_Error(PARSE_FATAL, @@ -2590,10 +2589,10 @@ Parse_MainName(void) Punt("no target to make."); /*NOTREACHED*/ } else if (mainNode->type & OP_DOUBLEDEP) { - Lst_AtEnd(listmain, (void *)mainNode); + Lst_AtEnd(listmain, mainNode); Lst_Concat(listmain, mainNode->cohorts, LST_CONCNEW); } else - Lst_AtEnd(listmain, (void *)mainNode); + Lst_AtEnd(listmain, mainNode); return (listmain); } diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c index 54503fd3e0..a6fadf07a2 100644 --- a/usr.bin/make/str.c +++ b/usr.bin/make/str.c @@ -37,7 +37,7 @@ * * @(#)str.c 5.8 (Berkeley) 6/1/90 * $FreeBSD: src/usr.bin/make/str.c,v 1.12.2.2 2004/02/23 12:10:57 ru Exp $ - * $DragonFly: src/usr.bin/make/str.c,v 1.10 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/str.c,v 1.11 2004/12/16 00:17:05 okumoto Exp $ */ #include "make.h" @@ -55,7 +55,7 @@ str_init(void) { char *p1; - argv = (char **)emalloc(((argmax = 50) + 1) * sizeof(char *)); + argv = emalloc(((argmax = 50) + 1) * sizeof(char *)); argv[0] = Var_Value(".MAKE", VAR_GLOBAL, &p1); } @@ -96,7 +96,7 @@ 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); @@ -161,7 +161,7 @@ brk_string(char *str, int *store_argc, Boolean expand) if (!start) start = t; } else - inquote = (char) ch; + inquote = (char)ch; if (expand) continue; break; @@ -184,11 +184,11 @@ brk_string(char *str, int *store_argc, Boolean expand) *t++ = '\0'; if (argc == argmax) { argmax *= 2; /* ramp up fast */ - argv = (char **)erealloc(argv, + argv = erealloc(argv, (argmax + 1) * sizeof(char *)); } argv[argc++] = start; - start = (char *)NULL; + start = NULL; if (ch == '\n' || ch == '\0') goto done; continue; @@ -234,7 +234,7 @@ brk_string(char *str, int *store_argc, Boolean expand) start = t; *t++ = (char)ch; } -done: argv[argc] = (char *)NULL; +done: argv[argc] = NULL; *store_argc = argc; return (argv); } diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 9f9e67efba..abfc3589b4 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -37,7 +37,7 @@ * * @(#)suff.c 8.4 (Berkeley) 3/21/94 * $FreeBSD: src/usr.bin/make/suff.c,v 1.12.2.2 2004/06/10 13:07:53 ru Exp $ - * $DragonFly: src/usr.bin/make/suff.c,v 1.14 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/suff.c,v 1.15 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -251,7 +251,7 @@ static int SuffSuffIsSuffixP(void *s, void *str) { - return (!SuffSuffIsSuffix((Suff *)s, (char *)str)); + return (!SuffSuffIsSuffix(s, str)); } /*- @@ -271,7 +271,7 @@ static int SuffSuffHasNameP(void *s, void *sname) { - return (strcmp((char *)sname, ((Suff *)s)->name)); + return (strcmp(sname, ((Suff *)s)->name)); } /*- @@ -293,7 +293,7 @@ static int SuffSuffIsPrefix(void *s, void *str) { - return (SuffStrIsPrefix(((Suff *)s)->name, (char *)str) == NULL ? 1 : 0); + return (SuffStrIsPrefix(((Suff *)s)->name, str) == NULL ? 1 : 0); } /*- @@ -312,7 +312,7 @@ static int SuffGNHasNameP(void *gn, void *name) { - return (strcmp((char *)name, ((GNode *)gn)->name)); + return (strcmp(name, ((GNode *)gn)->name)); } /*********** Maintenance Functions ************/ @@ -332,7 +332,7 @@ SuffGNHasNameP(void *gn, void *name) static void SuffFree(void *sp) { - Suff *s = (Suff *) sp; + Suff *s = sp; if (s == suffNull) suffNull = NULL; @@ -364,7 +364,8 @@ SuffFree(void *sp) static void SuffRemove(Lst l, Suff *s) { - LstNode ln = Lst_Member(l, (void *)s); + LstNode ln = Lst_Member(l, s); + if (ln != NULL) { Lst_Remove(l, ln); s->refCount--; @@ -394,7 +395,7 @@ SuffInsert(Lst l, Suff *s) return; } while ((ln = Lst_Next(l)) != NULL) { - s2 = (Suff *)Lst_Datum(ln); + s2 = Lst_Datum(ln); if (s2->sNum >= s->sNum) { break; } @@ -407,14 +408,14 @@ SuffInsert(Lst l, Suff *s) DEBUGF(SUFF, ("inserting %s(%d)...", s->name, s->sNum)); if (ln == NULL) { DEBUGF(SUFF, ("at end of list\n")); - Lst_AtEnd (l, (void *)s); + Lst_AtEnd (l, s); s->refCount++; - Lst_AtEnd(s->ref, (void *)l); + Lst_AtEnd(s->ref, l); } else if (s2->sNum != s->sNum) { DEBUGF(SUFF, ("before %s(%d)\n", s2->name, s2->sNum)); - Lst_Insert(l, ln, (void *)s); + Lst_Insert(l, ln, s); s->refCount++; - Lst_AtEnd(s->ref, (void *)l); + Lst_AtEnd(s->ref, l); } else { DEBUGF(SUFF, ("already there\n")); } @@ -491,9 +492,9 @@ SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr) */ for (;;) { if (srcLn == NULL) { - srcLn = Lst_Find(sufflist, (void *)str, SuffSuffIsPrefix); + srcLn = Lst_Find(sufflist, str, SuffSuffIsPrefix); } else { - srcLn = Lst_FindFrom(sufflist, Lst_Succ(srcLn), (void *)str, + srcLn = Lst_FindFrom(sufflist, Lst_Succ(srcLn), str, SuffSuffIsPrefix); } if (srcLn == NULL) { @@ -516,16 +517,16 @@ SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr) } return (FALSE); } - src = (Suff *) Lst_Datum (srcLn); + src = Lst_Datum (srcLn); str2 = str + src->nameLen; if (*str2 == '\0') { single = src; singleLn = srcLn; } else { - targLn = Lst_Find(sufflist, (void *)str2, SuffSuffHasNameP); + targLn = Lst_Find(sufflist, str2, SuffSuffHasNameP); if (targLn != NULL) { *srcPtr = src; - *targPtr = (Suff *)Lst_Datum(targLn); + *targPtr = Lst_Datum(targLn); return (TRUE); } } @@ -576,14 +577,14 @@ Suff_AddTransform(char *line) *t; /* target suffix */ LstNode ln; /* Node for existing transformation */ - ln = Lst_Find(transforms, (void *)line, SuffGNHasNameP); + ln = Lst_Find(transforms, line, SuffGNHasNameP); if (ln == NULL) { /* * Make a new graph node for the transformation. It will be filled in * by the Parse module. */ gn = Targ_NewGN(line); - Lst_AtEnd (transforms, (void *)gn); + Lst_AtEnd(transforms, gn); } else { /* * New specification for transformation rule. Just nuke the old list @@ -591,7 +592,7 @@ Suff_AddTransform(char *line) * free the commands themselves, because a given command can be * attached to several different transformations. */ - gn = (GNode *)Lst_Datum(ln); + gn = Lst_Datum(ln); Lst_Destroy(gn->commands, NOFREE); Lst_Destroy(gn->children, NOFREE); gn->commands = Lst_Init(FALSE); @@ -693,8 +694,8 @@ Suff_EndTransform(void *gnp, void *dummy __unused) static int SuffRebuildGraph(void *transformp, void *sp) { - GNode *transform = (GNode *)transformp; - Suff *s = (Suff *)sp; + GNode *transform = transformp; + Suff *s = sp; char *cp; LstNode ln; Suff *s2 = NULL; @@ -707,9 +708,9 @@ SuffRebuildGraph(void *transformp, void *sp) if (cp[0] == '\0') /* null rule */ s2 = suffNull; else { - ln = Lst_Find(sufflist, (void *)cp, SuffSuffHasNameP); + ln = Lst_Find(sufflist, cp, SuffSuffHasNameP); if (ln != NULL) - s2 = (Suff *)Lst_Datum(ln); + s2 = Lst_Datum(ln); } if (s2 != NULL) { /* @@ -726,12 +727,12 @@ SuffRebuildGraph(void *transformp, void *sp) * Not from, maybe to? */ cp = SuffSuffIsSuffix(s, transform->name + strlen(transform->name)); - if (cp != (char *)NULL) { + if (cp != NULL) { /* * Null-terminate the source suffix in order to find it. */ cp[1] = '\0'; - ln = Lst_Find(sufflist, (void *)transform->name, SuffSuffHasNameP); + ln = Lst_Find(sufflist, transform->name, SuffSuffHasNameP); /* * Replace the start of the target suffix */ @@ -740,7 +741,7 @@ SuffRebuildGraph(void *transformp, void *sp) /* * Found it -- establish the proper relationship */ - s2 = (Suff *)Lst_Datum(ln); + s2 = Lst_Datum(ln); SuffInsert(s->children, s2); SuffInsert(s2->parents, s); } @@ -768,9 +769,9 @@ Suff_AddSuffix(char *str) Suff *s; /* new suffix descriptor */ LstNode ln; - ln = Lst_Find(sufflist, (void *)str, SuffSuffHasNameP); + ln = Lst_Find(sufflist, str, SuffSuffHasNameP); if (ln == NULL) { - s = (Suff *)emalloc(sizeof(Suff)); + s = emalloc(sizeof(Suff)); s->name = estrdup(str); s->nameLen = strlen (s->name); @@ -782,12 +783,13 @@ Suff_AddSuffix(char *str) s->flags = 0; s->refCount = 0; - Lst_AtEnd(sufflist, (void *)s); + Lst_AtEnd(sufflist, s); + /* * Look for any existing transformations from or to this suffix. * XXX: Only do this after a Suff_ClearSuffixes? */ - Lst_ForEach(transforms, SuffRebuildGraph, (void *)s); + Lst_ForEach(transforms, SuffRebuildGraph, s); } } @@ -810,11 +812,11 @@ Suff_GetPath(char *sname) LstNode ln; Suff *s; - ln = Lst_Find(sufflist, (void *)sname, SuffSuffHasNameP); + ln = Lst_Find(sufflist, sname, SuffSuffHasNameP); if (ln == NULL) { return (NULL); } else { - s = (Suff *)Lst_Datum(ln); + s = Lst_Datum(ln); return (s->searchPath); } } @@ -854,7 +856,7 @@ Suff_DoPaths(void) inLibs = Lst_Init(FALSE); while ((ln = Lst_Next(sufflist)) != NULL) { - s = (Suff *)Lst_Datum(ln); + s = Lst_Datum(ln); if (!Lst_IsEmpty(s->searchPath)) { #ifdef INCLUDES if (s->flags & SUFF_INCLUDE) { @@ -905,9 +907,9 @@ Suff_AddInclude(char *sname) LstNode ln; Suff *s; - ln = Lst_Find(sufflist, (void *)sname, SuffSuffHasNameP); + ln = Lst_Find(sufflist, sname, SuffSuffHasNameP); if (ln != NULL) { - s = (Suff *)Lst_Datum(ln); + s = Lst_Datum(ln); s->flags |= SUFF_INCLUDE; } } @@ -934,9 +936,9 @@ Suff_AddLib(char *sname) LstNode ln; Suff *s; - ln = Lst_Find(sufflist, (void *)sname, SuffSuffHasNameP); + ln = Lst_Find(sufflist, sname, SuffSuffHasNameP); if (ln != NULL) { - s = (Suff *)Lst_Datum(ln); + s = Lst_Datum(ln); s->flags |= SUFF_LIBRARY; } } @@ -960,8 +962,8 @@ Suff_AddLib(char *sname) static int SuffAddSrc(void *sp, void *lsp) { - Suff *s = (Suff *) sp; - LstSrc *ls = (LstSrc *) lsp; + Suff *s = sp; + LstSrc *ls = lsp; Src *s2; /* new Src structure */ Src *targ; /* Target structure */ @@ -973,7 +975,7 @@ SuffAddSrc(void *sp, void *lsp) * structure for a file with no suffix attached. Two birds, and all * that... */ - s2 = (Src *)emalloc(sizeof(Src)); + s2 = emalloc(sizeof(Src)); s2->file = estrdup(targ->pref); s2->pref = targ->pref; s2->parent = targ; @@ -982,30 +984,30 @@ SuffAddSrc(void *sp, void *lsp) s->refCount++; s2->children = 0; targ->children += 1; - Lst_AtEnd(ls->l, (void *)s2); + Lst_AtEnd(ls->l, s2); #ifdef DEBUG_SRC s2->cp = Lst_Init(FALSE); - Lst_AtEnd(targ->cp, (void *) s2); + Lst_AtEnd(targ->cp, s2); printf("1 add %x %x to %x:", targ, s2, ls->l); - Lst_ForEach(ls->l, PrintAddr, (void *) 0); + Lst_ForEach(ls->l, PrintAddr, (void *)NULL); printf("\n"); #endif } - s2 = (Src *)emalloc(sizeof(Src)); + s2 = emalloc(sizeof(Src)); s2->file = str_concat(targ->pref, s->name, 0); s2->pref = targ->pref; s2->parent = targ; s2->node = NULL; s2->suff = s; s->refCount++; - s2->children = 0; + s2->children = 0; targ->children += 1; - Lst_AtEnd(ls->l, (void *)s2); + Lst_AtEnd(ls->l, s2); #ifdef DEBUG_SRC s2->cp = Lst_Init(FALSE); - Lst_AtEnd(targ->cp, (void *) s2); + Lst_AtEnd(targ->cp, s2); printf("2 add %x %x to %x:", targ, s2, ls->l); - Lst_ForEach(ls->l, PrintAddr, (void *) 0); + Lst_ForEach(ls->l, PrintAddr, (void *)NULL); printf("\n"); #endif @@ -1032,7 +1034,7 @@ SuffAddLevel(Lst l, Src *targ) ls.s = targ; ls.l = l; - Lst_ForEach(targ->suff->children, SuffAddSrc, (void *)&ls); + Lst_ForEach(targ->suff->children, SuffAddSrc, &ls); } /*- @@ -1059,7 +1061,7 @@ SuffRemoveSrc(Lst l) } #ifdef DEBUG_SRC printf("cleaning %lx: ", (unsigned long) l); - Lst_ForEach(l, PrintAddr, (void *) 0); + Lst_ForEach(l, PrintAddr, (void *)NULL); printf("\n"); #endif @@ -1072,7 +1074,7 @@ SuffRemoveSrc(Lst l) free(s->pref); else { #ifdef DEBUG_SRC - LstNode ln = Lst_Member(s->parent->cp, (void *)s); + LstNode ln = Lst_Member(s->parent->cp, s); if (ln != NULL) Lst_Remove(s->parent->cp, ln); #endif @@ -1091,7 +1093,7 @@ SuffRemoveSrc(Lst l) #ifdef DEBUG_SRC else { printf("keep: [l=%x] p=%x %d: ", l, s, s->children); - Lst_ForEach(s->cp, PrintAddr, (void *)0); + Lst_ForEach(s->cp, PrintAddr, (void *)NULL); printf("\n"); } #endif @@ -1121,10 +1123,10 @@ SuffFindThem (Lst srcs, Lst slst) Src *rs; /* returned Src */ char *ptr; - rs = (Src *)NULL; + rs = NULL; while (!Lst_IsEmpty (srcs)) { - s = (Src *)Lst_DeQueue(srcs); + s = Lst_DeQueue(srcs); DEBUGF(SUFF, ("\ttrying %s...", s->file)); @@ -1152,7 +1154,7 @@ SuffFindThem (Lst srcs, Lst slst) DEBUGF(SUFF, ("not there\n")); SuffAddLevel(srcs, s); - Lst_AtEnd(slst, (void *)s); + Lst_AtEnd(slst, s); } if (rs) { @@ -1192,10 +1194,10 @@ SuffFindCmds (Src *targ, Lst slst) prefLen = strlen(targ->pref); while ((ln = Lst_Next(t->children)) != NULL) { - s = (GNode *)Lst_Datum(ln); + s = Lst_Datum(ln); cp = strrchr(s->name, '/'); - if (cp == (char *)NULL) { + if (cp == NULL) { cp = s->name; } else { cp++; @@ -1205,7 +1207,7 @@ SuffFindCmds (Src *targ, Lst slst) * The node matches the prefix ok, see if it has a known * suffix. */ - ln = Lst_Find(sufflist, (void *)&cp[prefLen], SuffSuffHasNameP); + ln = Lst_Find(sufflist, &cp[prefLen], SuffSuffHasNameP); if (ln != NULL) { /* * It even has a known suffix, see if there's a transformation @@ -1213,17 +1215,16 @@ SuffFindCmds (Src *targ, Lst slst) * * XXX: Handle multi-stage transformations here, too. */ - suff = (Suff *)Lst_Datum(ln); + suff = Lst_Datum(ln); - if (Lst_Member(suff->parents, (void *)targ->suff) != NULL) - { + if (Lst_Member(suff->parents, targ->suff) != NULL) { /* * Hot Damn! Create a new Src structure to describe * this transformation (making sure to duplicate the * source node's name so Suff_FindDeps can free it * again (ick)), and return the new structure. */ - ret = (Src *)emalloc (sizeof(Src)); + ret = emalloc(sizeof(Src)); ret->file = estrdup(s->name); ret->pref = targ->pref; ret->suff = suff; @@ -1235,9 +1236,9 @@ SuffFindCmds (Src *targ, Lst slst) #ifdef DEBUG_SRC ret->cp = Lst_Init(FALSE); printf("3 add %x %x\n", targ, ret); - Lst_AtEnd(targ->cp, (void *)ret); + Lst_AtEnd(targ->cp, ret); #endif - Lst_AtEnd(slst, (void *)ret); + Lst_AtEnd(slst, ret); DEBUGF(SUFF, ("\tusing existing source %s\n", s->name)); return (ret); } @@ -1245,7 +1246,7 @@ SuffFindCmds (Src *targ, Lst slst) } } Lst_Close(t->children); - return ((Src *)NULL); + return (NULL); } /*- @@ -1255,7 +1256,7 @@ SuffFindCmds (Src *targ, Lst slst) * variable invocations or file wildcards into actual targets. * * Results: - * === 0 (continue) + * == 0 (continue) * * Side Effects: * The expanded node is removed from the parent's list of children, @@ -1267,8 +1268,8 @@ SuffFindCmds (Src *targ, Lst slst) static int SuffExpandChildren(void *cgnp, void *pgnp) { - GNode *cgn = (GNode *)cgnp; - GNode *pgn = (GNode *)pgnp; + GNode *cgn = cgnp; + GNode *pgn = pgnp; GNode *gn; /* New source 8) */ LstNode prevLN; /* Node after which new source should be put */ LstNode ln; /* List element for old source */ @@ -1278,7 +1279,7 @@ SuffExpandChildren(void *cgnp, void *pgnp) * New nodes effectively take the place of the child, so place them * after the child */ - prevLN = Lst_Member(pgn->children, (void *)cgn); + prevLN = Lst_Member(pgn->children, cgn); /* * First do variable expansion -- this takes precedence over @@ -1286,11 +1287,11 @@ SuffExpandChildren(void *cgnp, void *pgnp) * to later since the resulting words are tacked on to the end of * the children list. */ - if (strchr(cgn->name, '$') != (char *)NULL) { + if (strchr(cgn->name, '$') != NULL) { DEBUGF(SUFF, ("Expanding \"%s\"...", cgn->name)); cp = Var_Subst(NULL, cgn->name, pgn, TRUE); - if (cp != (char *)NULL) { + if (cp != NULL) { Lst members = Lst_Init(FALSE); if (cgn->type & OP_ARCHV) { @@ -1323,7 +1324,7 @@ SuffExpandChildren(void *cgnp, void *pgnp) */ *cp++ = '\0'; gn = Targ_FindNode(start, TARG_CREATE); - Lst_AtEnd(members, (void *)gn); + Lst_AtEnd(members, gn); while (*cp == ' ' || *cp == '\t') { cp++; } @@ -1362,7 +1363,7 @@ SuffExpandChildren(void *cgnp, void *pgnp) * Stuff left over -- add it to the list too */ gn = Targ_FindNode(start, TARG_CREATE); - Lst_AtEnd(members, (void *)gn); + Lst_AtEnd(members, gn); } /* * Point cp back at the beginning again so the variable value @@ -1374,13 +1375,13 @@ SuffExpandChildren(void *cgnp, void *pgnp) * Add all elements of the members list to the parent node. */ while(!Lst_IsEmpty(members)) { - gn = (GNode *)Lst_DeQueue(members); + gn = Lst_DeQueue(members); DEBUGF(SUFF, ("%s...", gn->name)); - if (Lst_Member(pgn->children, (void *)gn) == NULL) { - Lst_Append(pgn->children, prevLN, (void *)gn); + if (Lst_Member(pgn->children, gn) == NULL) { + Lst_Append(pgn->children, prevLN, gn); prevLN = Lst_Succ(prevLN); - Lst_AtEnd(gn->parents, (void *)pgn); + Lst_AtEnd(gn->parents, pgn); pgn->unmade++; } } @@ -1388,13 +1389,13 @@ SuffExpandChildren(void *cgnp, void *pgnp) /* * Free the result */ - free((char *)cp); + free(cp); } /* * Now the source is expanded, remove it from the list of children to * keep it from being processed. */ - ln = Lst_Member(pgn->children, (void *)cgn); + ln = Lst_Member(pgn->children, cgn); pgn->unmade--; Lst_Remove(pgn->children, ln); DEBUGF(SUFF, ("\n")); @@ -1411,12 +1412,12 @@ SuffExpandChildren(void *cgnp, void *pgnp) * Else use the default system search path. */ cp = cgn->name + strlen(cgn->name); - ln = Lst_Find(sufflist, (void *)cp, SuffSuffIsSuffixP); + ln = Lst_Find(sufflist, cp, SuffSuffIsSuffixP); DEBUGF(SUFF, ("Wildcard expanding \"%s\"...", cgn->name)); if (ln != NULL) { - Suff *s = (Suff *)Lst_Datum(ln); + Suff *s = Lst_Datum(ln); DEBUGF(SUFF, ("suffix is \"%s\"...", s->name)); path = s->searchPath; @@ -1437,7 +1438,7 @@ SuffExpandChildren(void *cgnp, void *pgnp) /* * Fetch next expansion off the list and find its GNode */ - cp = (char *)Lst_DeQueue(exp); + cp = Lst_DeQueue(exp); DEBUGF(SUFF, ("%s...", cp)); gn = Targ_FindNode(cp, TARG_CREATE); @@ -1446,10 +1447,10 @@ SuffExpandChildren(void *cgnp, void *pgnp) * If gn isn't already a child of the parent, make it so and * up the parent's count of unmade children. */ - if (Lst_Member(pgn->children, (void *)gn) == NULL) { - Lst_Append(pgn->children, prevLN, (void *)gn); + if (Lst_Member(pgn->children, gn) == NULL) { + Lst_Append(pgn->children, prevLN, gn); prevLN = Lst_Succ(prevLN); - Lst_AtEnd(gn->parents, (void *)pgn); + Lst_AtEnd(gn->parents, pgn); pgn->unmade++; } } @@ -1463,7 +1464,7 @@ SuffExpandChildren(void *cgnp, void *pgnp) * Now the source is expanded, remove it from the list of children to * keep it from being processed. */ - ln = Lst_Member(pgn->children, (void *)cgn); + ln = Lst_Member(pgn->children, cgn); pgn->unmade--; Lst_Remove(pgn->children, ln); DEBUGF(SUFF, ("\n")); @@ -1497,13 +1498,13 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s) char *tname; /* Name of transformation rule */ GNode *gn; /* Node for same */ - if (Lst_Member(tGn->children, (void *)sGn) == NULL) { + if (Lst_Member(tGn->children, sGn) == NULL) { /* * Not already linked, so form the proper links between the * target and source. */ - Lst_AtEnd(tGn->children, (void *)sGn); - Lst_AtEnd(sGn->parents, (void *)tGn); + Lst_AtEnd(tGn->children, sGn); + Lst_AtEnd(sGn->parents, tGn); tGn->unmade += 1; } @@ -1514,16 +1515,16 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s) * sGn gets the target in its iParents list, however, as that * will be sufficient to get the .IMPSRC variable set for tGn */ - for (ln=Lst_First(sGn->cohorts); ln != NULL; ln=Lst_Succ(ln)) { - gn = (GNode *)Lst_Datum(ln); + for (ln = Lst_First(sGn->cohorts); ln != NULL; ln = Lst_Succ(ln)) { + gn = Lst_Datum(ln); - if (Lst_Member(tGn->children, (void *)gn) == NULL) { + if (Lst_Member(tGn->children, gn) == NULL) { /* * Not already linked, so form the proper links between the * target and source. */ - Lst_AtEnd(tGn->children, (void *)gn); - Lst_AtEnd(gn->parents, (void *)tGn); + Lst_AtEnd(tGn->children, gn); + Lst_AtEnd(gn->parents, tGn); tGn->unmade += 1; } } @@ -1532,7 +1533,7 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s) * Locate the transformation rule itself */ tname = str_concat(s->name, t->name, 0); - ln = Lst_Find(transforms, (void *)tname, SuffGNHasNameP); + ln = Lst_Find(transforms, tname, SuffGNHasNameP); free(tname); if (ln == NULL) { @@ -1544,7 +1545,7 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s) return (FALSE); } - gn = (GNode *)Lst_Datum(ln); + gn = Lst_Datum(ln); DEBUGF(SUFF, ("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name)); @@ -1563,14 +1564,14 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s) */ ln = Lst_Succ(ln); if (ln != NULL) { - Lst_ForEachFrom(tGn->children, ln, SuffExpandChildren, (void *)tGn); + Lst_ForEachFrom(tGn->children, ln, SuffExpandChildren, tGn); } /* * Keep track of another parent to which this beast is transformed so * the .IMPSRC variable can be set correctly for the parent. */ - Lst_AtEnd(sGn->iParents, (void *)tGn); + Lst_AtEnd(sGn->iParents, tGn); return (TRUE); } @@ -1628,9 +1629,9 @@ SuffFindArchiveDeps(GNode *gn, Lst slst) /* * Create the link between the two nodes right off */ - if (Lst_Member(gn->children, (void *)mem) == NULL) { - Lst_AtEnd(gn->children, (void *)mem); - Lst_AtEnd(mem->parents, (void *)gn); + if (Lst_Member(gn->children, mem) == NULL) { + Lst_AtEnd(gn->children, mem); + Lst_AtEnd(mem->parents, gn); gn->unmade += 1; } @@ -1678,7 +1679,7 @@ SuffFindArchiveDeps(GNode *gn, Lst slst) /* * Got one -- apply it */ - if (!SuffApplyTransform(gn, mem, (Suff *)Lst_Datum(ln), ms)) { + if (!SuffApplyTransform(gn, mem, Lst_Datum(ln), ms)) { DEBUGF(SUFF, ("\tNo transformation from %s -> %s\n", ms->name, ((Suff *)Lst_Datum(ln))->name)); } @@ -1779,12 +1780,12 @@ SuffFindNormalDeps(GNode *gn, Lst slst) /* * Allocate a Src structure to which things can be transformed */ - target = (Src *)emalloc(sizeof(Src)); + target = emalloc(sizeof(Src)); target->file = estrdup(gn->name); - target->suff = (Suff *)Lst_Datum(ln); + target->suff = Lst_Datum(ln); target->suff->refCount++; target->node = gn; - target->parent = (Src *)NULL; + target->parent = NULL; target->children = 0; #ifdef DEBUG_SRC target->cp = Lst_Init(FALSE); @@ -1807,7 +1808,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst) /* * Record the target so we can nuke it */ - Lst_AtEnd(targs, (void *)target); + Lst_AtEnd(targs, target); /* * Search from this suffix's successor... @@ -1822,12 +1823,12 @@ SuffFindNormalDeps(GNode *gn, Lst slst) if (Lst_IsEmpty(targs) && suffNull != NULL) { DEBUGF(SUFF, ("\tNo known suffix on %s. Using .NULL suffix\n", gn->name)); - targ = (Src *)emalloc(sizeof(Src)); + targ = emalloc(sizeof(Src)); targ->file = estrdup(gn->name); targ->suff = suffNull; targ->suff->refCount++; targ->node = gn; - targ->parent = (Src *)NULL; + targ->parent = NULL; targ->children = 0; targ->pref = estrdup(sopref); #ifdef DEBUG_SRC @@ -1846,7 +1847,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst) DEBUGF(SUFF, ("adding suffix rules\n")); - Lst_AtEnd(targs, (void *)targ); + Lst_AtEnd(targs, targ); } /* @@ -1855,15 +1856,15 @@ SuffFindNormalDeps(GNode *gn, Lst slst) */ bottom = SuffFindThem(srcs, slst); - if (bottom == (Src *)NULL) { + if (bottom == NULL) { /* * No known transformations -- use the first suffix found for setting * the local variables. */ if (!Lst_IsEmpty(targs)) { - targ = (Src *)Lst_Datum(Lst_First(targs)); + targ = Lst_Datum(Lst_First(targs)); } else { - targ = (Src *)NULL; + targ = NULL; } } else { /* @@ -1983,14 +1984,14 @@ sfnd_abort: if (!Lst_IsEmpty(gn->children)) { src = SuffFindCmds(targ, slst); - if (src != (Src *)NULL) { + if (src != NULL) { /* * Free up all the Src structures in the transformation path * up to, but not including, the parent node. */ while (bottom && bottom->parent != NULL) { - if (Lst_Member(slst, (void *)bottom) == NULL) { - Lst_AtEnd(slst, (void *)bottom); + if (Lst_Member(slst, bottom) == NULL) { + Lst_AtEnd(slst, bottom); } bottom = bottom->parent; } @@ -2021,7 +2022,7 @@ sfnd_abort: bottom->node = Targ_FindNode(bottom->file, TARG_CREATE); } - for (src = bottom; src->parent != (Src *)NULL; src = src->parent) { + for (src = bottom; src->parent != NULL; src = src->parent) { targ = src->parent; if (src->node->suffix) @@ -2071,8 +2072,8 @@ sfnd_abort: */ sfnd_return: if (bottom) - if (Lst_Member(slst, (void *)bottom) == NULL) - Lst_AtEnd(slst, (void *)bottom); + if (Lst_Member(slst, bottom) == NULL) + Lst_AtEnd(slst, bottom); while (SuffRemoveSrc(srcs) || SuffRemoveSrc(targs)) continue; @@ -2147,11 +2148,11 @@ SuffFindDeps(GNode *gn, Lst slst) LstNode ln; Suff *s; - ln = Lst_Find(sufflist, (void *)LIBSUFF, SuffSuffHasNameP); + ln = Lst_Find(sufflist, LIBSUFF, SuffSuffHasNameP); if (gn->suffix) gn->suffix->refCount--; if (ln != NULL) { - gn->suffix = s = (Suff *)Lst_Datum (ln); + gn->suffix = s = Lst_Datum (ln); gn->suffix->refCount++; Arch_FindLib(gn, s->searchPath); } else { @@ -2192,10 +2193,10 @@ Suff_SetNull(char *name) Suff *s; LstNode ln; - ln = Lst_Find(sufflist, (void *)name, SuffSuffHasNameP); + ln = Lst_Find(sufflist, name, SuffSuffHasNameP); if (ln != NULL) { - s = (Suff *)Lst_Datum(ln); - if (suffNull != (Suff *)NULL) { + s = Lst_Datum(ln); + if (suffNull != NULL) { suffNull->flags &= ~SUFF_NULL; } s->flags |= SUFF_NULL; @@ -2236,7 +2237,7 @@ Suff_Init(void) * actually go on the suffix list or everyone will think that's its * suffix. */ - emptySuff = suffNull = (Suff *)emalloc(sizeof(Suff)); + emptySuff = suffNull = emalloc(sizeof(Suff)); suffNull->name = estrdup(""); suffNull->nameLen = 0; @@ -2288,7 +2289,7 @@ SuffPrintName(void *s, void *dummy __unused) static int SuffPrintSuff(void *sp, void *dummy __unused) { - Suff *s = (Suff *)sp; + Suff *s = sp; int flags; int flag; @@ -2318,10 +2319,10 @@ SuffPrintSuff(void *sp, void *dummy __unused) } fputc('\n', stdout); printf("#\tTo: "); - Lst_ForEach (s->parents, SuffPrintName, (void *)0); + Lst_ForEach(s->parents, SuffPrintName, (void *)NULL); fputc('\n', stdout); printf("#\tFrom: "); - Lst_ForEach (s->children, SuffPrintName, (void *)0); + Lst_ForEach(s->children, SuffPrintName, (void *)NULL); fputc('\n', stdout); printf("#\tSearch Path: "); Dir_PrintPath(s->searchPath); @@ -2332,12 +2333,12 @@ SuffPrintSuff(void *sp, void *dummy __unused) static int SuffPrintTrans(void *tp, void *dummy __unused) { - GNode *t = (GNode *)tp; + GNode *t = tp; printf("%-16s: ", t->name); Targ_PrintType(t->type); fputc('\n', stdout); - Lst_ForEach(t->commands, Targ_PrintCmd, (void *)0); + Lst_ForEach(t->commands, Targ_PrintCmd, (void *)NULL); fputc('\n', stdout); return (0); } @@ -2347,8 +2348,8 @@ Suff_PrintAll(void) { printf("#*** Suffixes:\n"); - Lst_ForEach(sufflist, SuffPrintSuff, (void *)0); + Lst_ForEach(sufflist, SuffPrintSuff, (void *)NULL); printf("#*** Transformations:\n"); - Lst_ForEach(transforms, SuffPrintTrans, (void *)0); + Lst_ForEach(transforms, SuffPrintTrans, (void *)NULL); } diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c index 120d5daa7c..1ba32d9060 100644 --- a/usr.bin/make/targ.c +++ b/usr.bin/make/targ.c @@ -37,7 +37,7 @@ * * @(#)targ.c 8.2 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/targ.c,v 1.10 1999/09/11 13:08:02 hoek Exp $ - * $DragonFly: src/usr.bin/make/targ.c,v 1.13 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/targ.c,v 1.14 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -158,9 +158,9 @@ Targ_NewGN(char *name) { GNode *gn; - gn = (GNode *)emalloc(sizeof(GNode)); + gn = emalloc(sizeof(GNode)); gn->name = estrdup(name); - gn->path = (char *)0; + gn->path = NULL; if (name[0] == '-' && name[1] == 'l') { gn->type = OP_LIB; } else { @@ -204,7 +204,7 @@ Targ_NewGN(char *name) static void TargFreeGN(void *gnp) { - GNode *gn = (GNode *) gnp; + GNode *gn = gnp; free(gn->name); free(gn->path); @@ -220,7 +220,6 @@ TargFreeGN(void *gnp) free(gn); } - /*- *----------------------------------------------------------------------- * Targ_FindNode -- @@ -248,16 +247,16 @@ Targ_FindNode(char *name, int flags) if (isNew) { gn = Targ_NewGN(name); Hash_SetValue (he, gn); - Lst_AtEnd(allTargets, (void *)gn); + Lst_AtEnd(allTargets, gn); } } else { he = Hash_FindEntry(&targets, name); } - if (he == (Hash_Entry *) NULL) { + if (he == NULL) { return (NULL); } else { - return ((GNode *)Hash_GetValue(he)); + return (Hash_GetValue(he)); } } @@ -290,7 +289,7 @@ Targ_FindList(Lst names, int flags) return (nodes); } while ((ln = Lst_Next(names)) != NULL) { - name = (char *)Lst_Datum(ln); + name = Lst_Datum(ln); gn = Targ_FindNode(name, flags); if (gn != NULL) { /* @@ -298,7 +297,7 @@ Targ_FindList(Lst names, int flags) * are added to the list in the order in which they were * encountered in the makefile. */ - Lst_AtEnd(nodes, (void *)gn); + Lst_AtEnd(nodes, gn); if (gn->type & OP_DOUBLEDEP) { Lst_Concat(nodes, gn->cohorts, LST_CONCNEW); } @@ -512,7 +511,7 @@ Targ_PrintType(int type) static int TargPrintNode(void *gnp, void *passp) { - GNode *gn = (GNode *)gnp; + GNode *gn = gnp; int pass = *(int *)passp; if (!OP_NOP(gn->type)) { @@ -526,7 +525,7 @@ TargPrintNode(void *gnp, void *passp) } else { printf("# No unmade children\n"); } - if (! (gn->type & (OP_JOIN|OP_USE|OP_EXEC))) { + if (!(gn->type & (OP_JOIN | OP_USE | OP_EXEC))) { if (gn->mtime != 0) { printf("# last modified %s: %s\n", Targ_FmtTime(gn->mtime), @@ -546,13 +545,13 @@ TargPrintNode(void *gnp, void *passp) } if (!Lst_IsEmpty (gn->iParents)) { printf("# implicit parents: "); - Lst_ForEach(gn->iParents, TargPrintName, (void *)0); + Lst_ForEach(gn->iParents, TargPrintName, (void *)NULL); fputc('\n', stdout); } } if (!Lst_IsEmpty (gn->parents)) { printf("# parents: "); - Lst_ForEach(gn->parents, TargPrintName, (void *)0); + Lst_ForEach(gn->parents, TargPrintName, (void *)NULL); fputc('\n', stdout); } @@ -568,12 +567,12 @@ TargPrintNode(void *gnp, void *passp) break; } Targ_PrintType(gn->type); - Lst_ForEach(gn->children, TargPrintName, (void *)0); + Lst_ForEach(gn->children, TargPrintName, (void *)NULL); fputc('\n', stdout); - Lst_ForEach(gn->commands, Targ_PrintCmd, (void *)0); + Lst_ForEach(gn->commands, Targ_PrintCmd, (void *)NULL); printf("\n\n"); if (gn->type & OP_DOUBLEDEP) { - Lst_ForEach(gn->cohorts, TargPrintNode, (void *)&pass); + Lst_ForEach(gn->cohorts, TargPrintNode, &pass); } } return (0); @@ -595,7 +594,7 @@ TargPrintNode(void *gnp, void *passp) static int TargPrintOnlySrc(void *gnp, void *dummy __unused) { - GNode *gn = (GNode *)gnp; + GNode *gn = gnp; if (OP_NOP(gn->type)) printf("#\t%s [%s]\n", gn->name, gn->path ? gn->path : gn->name); @@ -618,11 +617,12 @@ TargPrintOnlySrc(void *gnp, void *dummy __unused) void Targ_PrintGraph(int pass) { + printf("#*** Input graph:\n"); - Lst_ForEach(allTargets, TargPrintNode, (void *)&pass); + Lst_ForEach(allTargets, TargPrintNode, &pass); printf("\n\n"); printf("#\n# Files that are only sources:\n"); - Lst_ForEach(allTargets, TargPrintOnlySrc, (void *)0); + Lst_ForEach(allTargets, TargPrintOnlySrc, (void *)NULL); printf("#*** Global Variables:\n"); Var_Dump(VAR_GLOBAL); printf("#*** Command-line Variables:\n"); diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 5ef26053f6..8b20d4d857 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -37,7 +37,7 @@ * * @(#)var.c 8.3 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/var.c,v 1.16.2.3 2002/02/27 14:18:57 cjc Exp $ - * $DragonFly: src/usr.bin/make/var.c,v 1.20 2004/12/10 19:22:24 okumoto Exp $ + * $DragonFly: src/usr.bin/make/var.c,v 1.21 2004/12/16 00:17:05 okumoto Exp $ */ /*- @@ -157,7 +157,7 @@ static int VarCmp(void *v, void *name) { - return (strcmp((char *)name, ((Var *)v)->name)); + return (strcmp(name, ((Var *)v)->name)); } /*- @@ -248,9 +248,7 @@ VarFind(char *name, GNode *ctxt, int flags) * Note whether this is one of the specific variables we were told through * the -E flag to use environment-variable-override for. */ - if (Lst_Find(envFirstVars, (void *)name, - (int (*)(void *, void *)) strcmp) != NULL) - { + if (Lst_Find(envFirstVars, name, (CompareProc *)strcmp) != NULL) { localCheckEnvFirst = TRUE; } else { localCheckEnvFirst = FALSE; @@ -261,15 +259,15 @@ VarFind(char *name, GNode *ctxt, int flags) * look for it in VAR_CMD, VAR_GLOBAL and the environment, in that order, * depending on the FIND_* flags in 'flags' */ - var = Lst_Find(ctxt->context, (void *)name, VarCmp); + var = Lst_Find(ctxt->context, name, VarCmp); if ((var == NULL) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) { - var = Lst_Find(VAR_CMD->context, (void *)name, VarCmp); + var = Lst_Find(VAR_CMD->context, name, VarCmp); } if ((var == NULL) && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL) && !checkEnvFirst && !localCheckEnvFirst) { - var = Lst_Find(VAR_GLOBAL->context, (void *)name, VarCmp); + var = Lst_Find(VAR_GLOBAL->context, name, VarCmp); } if ((var == NULL) && (flags & FIND_ENV)) { char *env; @@ -277,7 +275,7 @@ VarFind(char *name, GNode *ctxt, int flags) if ((env = getenv(name)) != NULL) { int len; - v = (Var *)emalloc(sizeof(Var)); + v = emalloc(sizeof(Var)); v->name = estrdup(name); len = strlen(env); @@ -290,19 +288,19 @@ VarFind(char *name, GNode *ctxt, int flags) } else if ((checkEnvFirst || localCheckEnvFirst) && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL)) { - var = Lst_Find(VAR_GLOBAL->context, (void *)name, VarCmp); + var = Lst_Find(VAR_GLOBAL->context, name, VarCmp); if (var == NULL) { - return ((Var *)NULL); + return (NULL); } else { - return ((Var *)Lst_Datum(var)); + return (Lst_Datum(var)); } } else { - return ((Var *)NULL); + return (NULL); } } else if (var == NULL) { - return ((Var *)NULL); + return (NULL); } else { - return ((Var *)Lst_Datum(var)); + return (Lst_Datum(var)); } } @@ -326,7 +324,7 @@ VarAdd(char *name, char *val, GNode *ctxt) Var *v; int len; - v = (Var *)emalloc(sizeof(Var)); + v = emalloc(sizeof(Var)); v->name = estrdup(name); @@ -336,8 +334,8 @@ VarAdd(char *name, char *val, GNode *ctxt) v->flags = 0; - Lst_AtFront(ctxt->context, (void *)v); - Lst_AtEnd(allVars, (void *)v); + Lst_AtFront(ctxt->context, v); + Lst_AtEnd(allVars, v); DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, val)); } @@ -356,7 +354,7 @@ VarAdd(char *name, char *val, GNode *ctxt) static void VarDelete(void *vp) { - Var *v = (Var *)vp; + Var *v = vp; free(v->name); Buf_Destroy(v->val, TRUE); @@ -382,15 +380,15 @@ Var_Delete(char *name, GNode *ctxt) LstNode ln; DEBUGF(VAR, ("%s:delete %s\n", ctxt->name, name)); - ln = Lst_Find(ctxt->context, (void *)name, VarCmp); + ln = Lst_Find(ctxt->context, name, VarCmp); if (ln != NULL) { Var *v; - v = (Var *)Lst_Datum(ln); + v = Lst_Datum(ln); Lst_Remove(ctxt->context, ln); ln = Lst_Member(allVars, v); Lst_Remove(allVars, ln); - VarDelete((void *)v); + VarDelete(v); } } @@ -427,7 +425,7 @@ Var_Set(char *name, char *val, GNode *ctxt) */ VarPossiblyExpand(&name, ctxt); v = VarFind(name, ctxt, 0); - if (v == (Var *)NULL) { + if (v == NULL) { VarAdd(name, val, ctxt); } else { Buf_Discard(v->val, Buf_Size(v->val)); @@ -495,7 +493,7 @@ Var_Append(char *name, char *val, GNode *ctxt) VarPossiblyExpand(&name, ctxt); v = VarFind(name, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0); - if (v == (Var *)NULL) { + if (v == NULL) { VarAdd(name, val, ctxt); } else { Buf_AddByte(v->val, (Byte)' '); @@ -512,7 +510,7 @@ Var_Append(char *name, char *val, GNode *ctxt) * export other variables...) */ v->flags &= ~VAR_FROM_ENV; - Lst_AtFront(ctxt->context, (void *)v); + Lst_AtFront(ctxt->context, v); } } free(name); @@ -540,12 +538,12 @@ Var_Exists(char *name, GNode *ctxt) v = VarFind(name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV); free(name); - if (v == (Var *)NULL) { + if (v == NULL) { return (FALSE); } else if (v->flags & VAR_FROM_ENV) { free(v->name); Buf_Destroy(v->val, TRUE); - free((char *)v); + free(v); } return (TRUE); } @@ -571,8 +569,9 @@ Var_Value(char *name, GNode *ctxt, char **frp) v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); free(name); *frp = NULL; - if (v != (Var *) NULL) { - char *p = ((char *)Buf_GetAll(v->val, (int *)NULL)); + if (v != NULL) { + char *p = (char *)Buf_GetAll(v->val, (int *)NULL); + if (v->flags & VAR_FROM_ENV) { Buf_Destroy(v->val, FALSE); free(v); @@ -580,7 +579,7 @@ Var_Value(char *name, GNode *ctxt, char **frp) } return (p); } else { - return ((char *)NULL); + return (NULL); } } @@ -675,7 +674,7 @@ VarSortWords(char *str, int (*cmp)(const void *, const void *)) buf = Buf_Init(0); av = brk_string(str, &ac, FALSE); - qsort((void*)(av + 1), ac - 1, sizeof(char*), cmp); + qsort(av + 1, ac - 1, sizeof(char *), cmp); for (i = 1; i < ac; i++) { Buf_AddBytes(buf, strlen(av[i]), (Byte *)av[i]); Buf_AddByte(buf, (Byte)((i < ac - 1) ? ' ' : '\0')); @@ -988,7 +987,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) *tstr = '\0'; Buf_AddByte(buf, (Byte)'\0'); - str = Buf_GetAll(buf, NULL); + str = Buf_GetAll(buf, (int *)NULL); vlen = strlen(str); v = VarFind(str, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); @@ -1017,7 +1016,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) vname[1] = '\0'; v = VarFind(vname, ctxt, 0); - if (v != (Var *)NULL && !haveModifier) { + if (v != NULL && !haveModifier) { /* * No need for nested expansion or anything, as we're * the only one who sets these things and we sure don't @@ -1026,9 +1025,9 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) val = (char *)Buf_GetAll(v->val, (int *)NULL); if (str[1] == 'D') { - val = VarModify(val, VarHead, (void *)0); + val = VarModify(val, VarHead, (void *)NULL); } else { - val = VarModify(val, VarTail, (void *)0); + val = VarModify(val, VarTail, (void *)NULL); } /* * Resulting string is dynamically allocated, so @@ -1110,7 +1109,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) * Still need to get to the end of the variable specification, * so kludge up a Var structure for the modifications */ - v = (Var *)emalloc(sizeof(Var)); + v = emalloc(sizeof(Var)); v->name = estrdup(str); v->val = Buf_Init(1); v->flags = VAR_JUNK; @@ -1163,7 +1162,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) * :U Converts variable to upper-case. * :L Converts variable to lower-case. */ - if ((str != (char *)NULL) && haveModifier) { + if ((str != NULL) && haveModifier) { /* * Skip initial colon while putting it back. */ @@ -1217,9 +1216,9 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) pattern = &tstr[1]; } if (*tstr == 'M' || *tstr == 'm') { - newStr = VarModify(str, VarMatch, (void *)pattern); + newStr = VarModify(str, VarMatch, pattern); } else { - newStr = VarModify(str, VarNoMatch, (void *)pattern); + newStr = VarModify(str, VarNoMatch, pattern); } if (copy) { free(pattern); @@ -1389,7 +1388,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) Fatal("Global substitution of the empty string"); termc = *cp; - newStr = VarModify(str, VarSubstitute, (void *)&pattern); + newStr = VarModify(str, VarSubstitute, &pattern); /* * Free the two strings. */ @@ -1467,8 +1466,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) pattern.nsub = 10; pattern.matches = emalloc(pattern.nsub * sizeof(regmatch_t)); - newStr = VarModify(str, VarRESubstitute, - (void *) &pattern); + newStr = VarModify(str, VarRESubstitute, &pattern); regfree(&pattern.re); free(pattern.replace); free(pattern.matches); @@ -1508,7 +1506,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) /*FALLTHRU*/ case 'T': if (tstr[1] == endc || tstr[1] == ':') { - newStr = VarModify(str, VarTail, (void *)0); + newStr = VarModify(str, VarTail, (void *)NULL); cp = tstr + 1; termc = *cp; break; @@ -1532,7 +1530,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) /* FALLTHROUGH */ case 'H': if (tstr[1] == endc || tstr[1] == ':') { - newStr = VarModify(str, VarHead, (void *)0); + newStr = VarModify(str, VarHead, (void *)NULL); cp = tstr + 1; termc = *cp; break; @@ -1540,7 +1538,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) /*FALLTHRU*/ case 'E': if (tstr[1] == endc || tstr[1] == ':') { - newStr = VarModify(str, VarSuffix, (void *)0); + newStr = VarModify(str, VarSuffix, (void *)NULL); cp = tstr + 1; termc = *cp; break; @@ -1548,7 +1546,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) /*FALLTHRU*/ case 'R': if (tstr[1] == endc || tstr[1] == ':') { - newStr = VarModify(str, VarRoot, (void *)0); + newStr = VarModify(str, VarRoot, (void *)NULL); cp = tstr + 1; termc = *cp; break; @@ -1640,7 +1638,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) */ termc = *--cp; delim = '\0'; - newStr = VarModify(str, VarSYSVMatch, (void *)&pattern); + newStr = VarModify(str, VarSYSVMatch, &pattern); free(pattern.lhs); free(pattern.rhs); @@ -1904,7 +1902,7 @@ char * Var_GetTail(char *file) { - return (VarModify(file, VarTail, (void *)0)); + return (VarModify(file, VarTail, (void *)NULL)); } /*- @@ -1926,7 +1924,7 @@ char * Var_GetHead(char *file) { - return (VarModify(file, VarHead, (void *)0)); + return (VarModify(file, VarHead, (void *)NULL)); } /*- @@ -1979,5 +1977,5 @@ void Var_Dump(GNode *ctxt) { - Lst_ForEach (ctxt->context, VarPrintVar, (void *)0); + Lst_ForEach (ctxt->context, VarPrintVar, (void *)NULL); } diff --git a/usr.bin/make/var_modify.c b/usr.bin/make/var_modify.c index 205f9f22b1..9f005d17c0 100644 --- a/usr.bin/make/var_modify.c +++ b/usr.bin/make/var_modify.c @@ -37,7 +37,7 @@ * * @(#)var.c 8.3 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/var.c,v 1.16.2.3 2002/02/27 14:18:57 cjc Exp $ - * $DragonFly: src/usr.bin/make/Attic/var_modify.c,v 1.6 2004/12/16 00:03:54 okumoto Exp $ + * $DragonFly: src/usr.bin/make/Attic/var_modify.c,v 1.7 2004/12/16 00:17:05 okumoto Exp $ */ #include @@ -248,7 +248,7 @@ VarSYSVMatch(const char *word, Boolean addSpace, Buffer buf, void *patp) if ((ptr = Str_SYSVMatch(word, pat->lhs, &len)) != NULL) Str_SYSVSubst(buf, pat->rhs, ptr, len); else - Buf_AddBytes(buf, strlen(word), (Byte *) word); + Buf_AddBytes(buf, strlen(word), (Byte *)word); return (addSpace); } @@ -305,7 +305,7 @@ VarSubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp) { int wordLen; /* Length of word */ const char *cp; /* General pointer */ - VarPattern *pattern = (VarPattern *)patternp; + VarPattern *pattern = patternp; wordLen = strlen(word); if (1) { /* substitute in each word of the variable */ @@ -473,17 +473,17 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp) int added; int flags = 0; -#define MAYBE_ADD_SPACE() \ - if (addSpace && !added) \ - Buf_AddByte(buf, ' '); \ +#define MAYBE_ADD_SPACE() \ + if (addSpace && !added) \ + Buf_AddByte(buf, (Byte)' '); \ added = 1 added = 0; wp = word; pat = patternp; - if ((pat->flags & (VAR_SUB_ONE|VAR_SUB_MATCHED)) == - (VAR_SUB_ONE|VAR_SUB_MATCHED)) + if ((pat->flags & (VAR_SUB_ONE | VAR_SUB_MATCHED)) == + (VAR_SUB_ONE | VAR_SUB_MATCHED)) xrv = REG_NOMATCH; else { tryagain: @@ -495,13 +495,13 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp) 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, pat->matches[0].rm_so, (Byte *)wp); } for (rp = pat->replace; *rp; rp++) { if ((*rp == '\\') && ((rp[1] == '&') || (rp[1] == '\\'))) { MAYBE_ADD_SPACE(); - Buf_AddByte(buf,rp[1]); + Buf_AddByte(buf, (Byte)rp[1]); rp++; } else if ((*rp == '&') || @@ -539,11 +539,11 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp) if (sublen > 0) { MAYBE_ADD_SPACE(); - Buf_AddBytes(buf, sublen, subbuf); + Buf_AddBytes(buf, sublen, (Byte *)subbuf); } } else { MAYBE_ADD_SPACE(); - Buf_AddByte(buf, *rp); + Buf_AddByte(buf, (Byte)*rp); } } wp += pat->matches[0].rm_eo; @@ -551,7 +551,7 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp) flags |= REG_NOTBOL; if (pat->matches[0].rm_so == 0 && pat->matches[0].rm_eo == 0) { MAYBE_ADD_SPACE(); - Buf_AddByte(buf, *wp); + Buf_AddByte(buf, (Byte)*wp); wp++; } @@ -560,7 +560,7 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp) } if (*wp) { MAYBE_ADD_SPACE(); - Buf_AddBytes(buf, strlen(wp), wp); + Buf_AddBytes(buf, strlen(wp), (Byte *)wp); } break; default: @@ -569,10 +569,10 @@ VarRESubstitute(const char *word, Boolean addSpace, Buffer buf, void *patternp) case REG_NOMATCH: if (*wp) { MAYBE_ADD_SPACE(); - Buf_AddBytes(buf,strlen(wp),wp); + Buf_AddBytes(buf, strlen(wp), (Byte *)wp); } break; } - return (addSpace||added); + return (addSpace || added); } -- 2.41.0