Module Name:    src
Committed By:   rillig
Date:           Sun Aug  9 09:07:54 UTC 2020

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

Log Message:
make(1): remove redundant assignment from Cmd_Exec

A Buffer is always null-terminated.


To generate a diff of this commit:
cvs rdiff -u -r1.298 -r1.299 src/usr.bin/make/main.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/main.c
diff -u src/usr.bin/make/main.c:1.298 src/usr.bin/make/main.c:1.299
--- src/usr.bin/make/main.c:1.298	Sun Aug  9 09:01:29 2020
+++ src/usr.bin/make/main.c	Sun Aug  9 09:07:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.298 2020/08/09 09:01:29 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.299 2020/08/09 09:07:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.298 2020/08/09 09:01:29 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.299 2020/08/09 09:07:54 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.298 2020/08/09 09:01:29 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.299 2020/08/09 09:07:54 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1698,20 +1698,13 @@ Cmd_Exec(const char *cmd, const char **e
 	else if (WEXITSTATUS(status) != 0)
 	    *errfmt = "\"%s\" returned non-zero status";
 
-	/* Null-terminate the result and convert newlines to spaces. */
-	res[res_len] = '\0';
+	/* Convert newlines to spaces.  A final newline is just stripped */
 	cp = &res[res_len];
-
-	if (res_len > 0 && *--cp == '\n') {
-	    /*
-	     * A final newline is just stripped
-	     */
+	if (res_len > 0 && *--cp == '\n')
 	    *cp-- = '\0';
-	}
 	while (cp >= res) {
-	    if (*cp == '\n') {
+	    if (*cp == '\n')
 		*cp = ' ';
-	    }
 	    cp--;
 	}
 	break;

Reply via email to