Module Name: src Committed By: rillig Date: Sun Aug 2 19:59:17 UTC 2020
Modified Files: src/usr.bin/make: var.c Log Message: make(1): clean up NULL pointer comparisons, use separate variable st->newVal is not meant to be a general-purpose storage. Eliminate the unnecessary initialization of freeIt since Var_Parse initializes it in every case. To generate a diff of this commit: cvs rdiff -u -r1.405 -r1.406 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.405 src/usr.bin/make/var.c:1.406 --- src/usr.bin/make/var.c:1.405 Sun Aug 2 19:49:17 2020 +++ src/usr.bin/make/var.c Sun Aug 2 19:59:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.405 2020/08/02 19:49:17 rillig Exp $ */ +/* $NetBSD: var.c,v 1.406 2020/08/02 19:59:17 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.405 2020/08/02 19:49:17 rillig Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.406 2020/08/02 19:59:17 rillig Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.405 2020/08/02 19:49:17 rillig Exp $"); +__RCSID("$NetBSD: var.c,v 1.406 2020/08/02 19:59:17 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -2061,7 +2061,7 @@ ApplyModifier_Path(const char *mod, Appl } else { st->newVal = Dir_FindFile(st->v->name, Suff_FindPath(gn)); } - if (!st->newVal) + if (st->newVal == NULL) st->newVal = bmake_strdup(st->v->name); st->next = mod + 1; return AMR_OK; @@ -2087,7 +2087,7 @@ ApplyModifier_Exclam(const char *mod, Ap st->newVal = varNoError; free(cmd); - if (emsg) + if (emsg != NULL) Error(emsg, st->val); /* XXX: why still return AMR_OK? */ if (st->v->flags & VAR_JUNK) @@ -2749,12 +2749,12 @@ ApplyModifier_Assign(const char *mod, Ap break; case '!': { const char *emsg; - st->newVal = Cmd_Exec(val, &emsg); + char *cmd_output = Cmd_Exec(val, &emsg); if (emsg) Error(emsg, st->val); else - Var_Set(st->v->name, st->newVal, v_ctxt); - free(st->newVal); + Var_Set(st->v->name, cmd_output, v_ctxt); + free(cmd_output); break; } case '?': @@ -3592,7 +3592,7 @@ Var_Subst(const char *str, GNode *ctxt, Buf_AddBytesBetween(&buf, cp, str); } else { int length; - void *freeIt = NULL; + void *freeIt; const char *val = Var_Parse(str, ctxt, eflags, &length, &freeIt); /*