Module Name:    src
Committed By:   rillig
Date:           Wed Aug 12 18:53:59 UTC 2020

Modified Files:
        src/usr.bin/make: var.c

Log Message:
make(1): replace redundant NULL tests with assertions


To generate a diff of this commit:
cvs rdiff -u -r1.446 -r1.447 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.446 src/usr.bin/make/var.c:1.447
--- src/usr.bin/make/var.c:1.446	Mon Aug 10 20:07:14 2020
+++ src/usr.bin/make/var.c	Wed Aug 12 18:53:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.446 2020/08/10 20:07:14 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.447 2020/08/12 18:53:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.446 2020/08/10 20:07:14 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.447 2020/08/12 18:53:59 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.446 2020/08/10 20:07:14 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.447 2020/08/12 18:53:59 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3026,17 +3026,19 @@ ApplyModifiers(
 	     * we are not interested.
 	     */
 	    int c;
-	    if (rval != NULL && *rval &&
+	    assert(rval != NULL);
+	    if (rval[0] != '\0' &&
 		(c = p[rlen]) != '\0' && c != ':' && c != st.endc) {
 		free(freeIt);
 		goto apply_mods;
 	    }
 
-	    VAR_DEBUG("Indirect modifier \"%s\" from \"%.*s\"\n", rval, rlen, p);
+	    VAR_DEBUG("Indirect modifier \"%s\" from \"%.*s\"\n",
+		      rval, rlen, p);
 
 	    p += rlen;
 
-	    if (rval != NULL && *rval) {
+	    if (rval[0] != '\0') {
 		const char *rval_pp = rval;
 		st.val = ApplyModifiers(&rval_pp, st.val, '\0', '\0', v,
 					ctxt, eflags, freePtr);
@@ -3549,11 +3551,12 @@ Var_Parse(const char * const str, GNode 
     if (strchr(nstr, '$') != NULL && (eflags & VARE_WANTRES) != 0) {
 	nstr = Var_Subst(nstr, ctxt, eflags);
 	*freePtr = nstr;
+	assert(nstr != NULL);
     }
 
     v->flags &= ~VAR_IN_USE;
 
-    if (nstr != NULL && (haveModifier || extramodifiers != NULL)) {
+    if (haveModifier || extramodifiers != NULL) {
 	void *extraFree;
 
 	extraFree = NULL;

Reply via email to