Get rid of the third argument to Var_Value() the pointer it pointed

to has always been set to NULL for some time now.

Obtained from:	DragonFlyBSD
This commit is contained in:
harti 2005-05-24 15:58:35 +00:00
parent 910dc606b9
commit 79613308dc
8 changed files with 28 additions and 67 deletions

View File

@ -993,12 +993,9 @@ void
Arch_Touch(GNode *gn)
{
struct arfile *ar;
char *p1, *p2;
ar = ArchFindMember(Var_Value(ARCHIVE, gn, &p1),
Var_Value(TARGET, gn, &p2), "r+");
free(p1);
free(p2);
ar = ArchFindMember(Var_Value(ARCHIVE, gn),
Var_Value(TARGET, gn), "r+");
if (ar != NULL) {
ArchArchiveTouch(ar, (int64_t)now);
@ -1057,12 +1054,9 @@ int
Arch_MTime(GNode *gn)
{
int64_t mtime;
char *p1, *p2;
mtime = ArchStatMember(Var_Value(ARCHIVE, gn, &p1),
Var_Value(TARGET, gn, &p2), TRUE);
free(p1);
free(p2);
mtime = ArchStatMember(Var_Value(ARCHIVE, gn),
Var_Value(TARGET, gn), TRUE);
if (mtime == INT_MIN) {
mtime = 0;

View File

@ -283,16 +283,14 @@ static Boolean
CondDoDefined(int argLen, char *arg)
{
char savec = arg[argLen];
char *p1;
Boolean result;
arg[argLen] = '\0';
if (Var_Value(arg, VAR_CMD, &p1) != NULL) {
if (Var_Value(arg, VAR_CMD) != NULL) {
result = TRUE;
} else {
result = FALSE;
}
free(p1);
arg[argLen] = savec;
return (result);
}

View File

@ -1236,7 +1236,6 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
* commands.
*/
if (DEFAULT != NULL && !Lst_IsEmpty(&DEFAULT->commands)) {
char *p1;
/*
* Make only looks for a .DEFAULT if the node was
* never the target of an operator, so that's what we
@ -1248,8 +1247,7 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
* .DEFAULT itself.
*/
Make_HandleUse(DEFAULT, gn);
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn);
free(p1);
Var_Set(IMPSRC, Var_Value(TARGET, gn), gn);
} else if (Dir_MTime(gn) == 0) {
/*
@ -2788,13 +2786,11 @@ CompatInterrupt(int signo)
interrupted = 0;
if (curTarg != NULL && !Targ_Precious(curTarg)) {
char *p1;
char *file = Var_Value(TARGET, curTarg, &p1);
char *file = Var_Value(TARGET, curTarg);
if (!noExecute && eunlink(file) != -1) {
printf("*** %s removed\n", file);
}
free(p1);
}
/*
@ -3109,9 +3105,7 @@ CompatMake(GNode *gn, GNode *pgn)
}
if (Lst_Member(&gn->iParents, pgn) != NULL) {
char *p1;
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
free(p1);
Var_Set(IMPSRC, Var_Value(TARGET, gn), pgn);
}
/*
@ -3254,11 +3248,7 @@ CompatMake(GNode *gn, GNode *pgn)
pgn->make = FALSE;
} else {
char *p1;
printf("\n\nStop in %s.\n",
Var_Value(".CURDIR", gn, &p1));
free(p1);
printf("\n\nStop in %s.\n", Var_Value(".CURDIR", gn));
exit(1);
}
} else if (gn->made == ERROR) {
@ -3269,9 +3259,7 @@ CompatMake(GNode *gn, GNode *pgn)
pgn->make = FALSE;
} else {
if (Lst_Member(&gn->iParents, pgn) != NULL) {
char *p1;
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
free(p1);
Var_Set(IMPSRC, Var_Value(TARGET, gn), pgn);
}
switch(gn->made) {
case BEINGMADE:

View File

@ -663,7 +663,7 @@ main(int argc, char **argv)
const char *machine_arch;
const char *machine_cpu;
Boolean outOfDate = TRUE; /* FALSE if all targets up to date */
char *p, *p1;
char *p;
const char *pathp;
const char *path;
char mdpath[MAXPATHLEN];
@ -973,9 +973,8 @@ main(int argc, char **argv)
ReadMakefile(".depend");
/* Install all the flags into the MAKE envariable. */
if (((p = Var_Value(".MAKEFLAGS", VAR_GLOBAL, &p1)) != NULL) && *p)
if (((p = Var_Value(".MAKEFLAGS", VAR_GLOBAL)) != NULL) && *p)
setenv("MAKEFLAGS", p, 1);
free(p1);
/*
* For compatibility, look at the directories in the VPATH variable

View File

@ -341,12 +341,9 @@ Make_Update(GNode *cgn)
GNode *pgn; /* the parent node */
char *cname; /* the child's name */
LstNode *ln; /* Element in parents and iParents lists */
char *p1;
char *ptr;
char *cpref;
cname = Var_Value(TARGET, cgn, &p1);
free(p1);
cname = Var_Value(TARGET, cgn);
/*
* If the child was actually made, see what its modification time is
@ -464,7 +461,7 @@ Make_Update(GNode *cgn)
* Set the .PREFIX and .IMPSRC variables for all the implied parents
* of this node.
*/
cpref = Var_Value(PREFIX, cgn, &ptr);
cpref = Var_Value(PREFIX, cgn);
for (ln = Lst_First(&cgn->iParents); ln != NULL; ln = Lst_Succ(ln)) {
pgn = Lst_Datum(ln);
if (pgn->make) {
@ -472,7 +469,6 @@ Make_Update(GNode *cgn)
Var_Set(PREFIX, cpref, pgn);
}
}
free(ptr);
}
/**
@ -498,7 +494,6 @@ Make_DoAllVar(GNode *gn)
LstNode *ln;
GNode *cgn;
char *child;
char *p1;
LST_FOREACH(ln, &gn->children) {
/*
@ -517,7 +512,6 @@ Make_DoAllVar(GNode *gn)
cgn = Lst_Datum(ln);
if ((cgn->type & (OP_EXEC | OP_USE | OP_INVISIBLE)) == 0) {
p1 = NULL;
if (OP_NOP(cgn->type)) {
/*
* this node is only source; use the specific
@ -525,7 +519,7 @@ Make_DoAllVar(GNode *gn)
*/
child = cgn->path ? cgn->path : cgn->name;
} else
child = Var_Value(TARGET, cgn, &p1);
child = Var_Value(TARGET, cgn);
Var_Append(ALLSRC, child, gn);
if (gn->type & OP_JOIN) {
if (cgn->made == MADE) {
@ -554,7 +548,6 @@ Make_DoAllVar(GNode *gn)
*/
Var_Append(OODATE, child, gn);
}
free(p1);
}
}
@ -566,8 +559,7 @@ Make_DoAllVar(GNode *gn)
}
if (gn->type & OP_JOIN) {
Var_Set(TARGET, Var_Value(ALLSRC, gn, &p1), gn);
free(p1);
Var_Set(TARGET, Var_Value(ALLSRC, gn), gn);
}
}

View File

@ -1504,7 +1504,6 @@ SuffFindArchiveDeps(GNode *gn, Lst *slst)
char *eoarch; /* End of archive portion */
char *eoname; /* End of member portion */
char *name; /* Start of member's name */
char *p1;
GNode *mem; /* Node for member */
Suff *ms; /* Suffix descriptor for member */
@ -1547,10 +1546,8 @@ SuffFindArchiveDeps(GNode *gn, Lst *slst)
/*
* Copy in the variables from the member node to this one.
*/
Var_Set(copy[1], Var_Value(copy[1], mem, &p1), gn);
free(p1);
Var_Set(copy[0], Var_Value(copy[0], mem, &p1), gn);
free(p1);
Var_Set(copy[1], Var_Value(copy[1], mem), gn);
Var_Set(copy[0], Var_Value(copy[0], mem), gn);
ms = mem->suffix;
if (ms == NULL) {

View File

@ -1142,26 +1142,22 @@ Var_Exists(const char *name, GNode *ctxt)
* Return the value of the named variable in the given context
*
* Results:
* The value if the variable exists, NULL if it doesn't
* The value if the variable exists, NULL if it doesn't.
*/
char *
Var_Value(const char *name, GNode *ctxt, char **frp)
Var_Value(const char name[], GNode *ctxt)
{
Var *v;
char *n;
char *p;
n = VarPossiblyExpand(name, ctxt);
v = VarFindAny(n, ctxt);
if (v == NULL) {
p = NULL;
*frp = NULL;
} else {
p = Buf_Data(v->val);
*frp = NULL;
}
free(n);
return (p);
if (v == NULL) {
return (NULL);
} else {
return (Buf_Data(v->val));
}
}
/**
@ -2558,17 +2554,14 @@ Var_Print(Lst *vlist, Boolean expandVars)
v = emalloc(strlen(name) + 1 + 3);
sprintf(v, "${%s}", name);
value = Buf_Peel(Var_Subst(v,
VAR_GLOBAL, FALSE));
value = Buf_Peel(Var_Subst(v, VAR_GLOBAL, FALSE));
printf("%s\n", value);
free(v);
free(value);
} else {
value = Var_Value(name, VAR_GLOBAL, &v);
value = Var_Value(name, VAR_GLOBAL);
printf("%s\n", value != NULL ? value : "");
if (v != NULL)
free(v);
}
}
}

View File

@ -80,6 +80,6 @@ void Var_SetGlobal(const char *, const char *);
void Var_SetEnv(const char *, struct GNode *);
struct Buffer *Var_Subst(const char *, struct GNode *, Boolean);
struct Buffer *Var_SubstOnly(const char *, const char *, Boolean);
char *Var_Value(const char *, struct GNode *, char **);
char *Var_Value(const char *, struct GNode *);
#endif /* var_h_9cccafce */