Module Name:    src
Committed By:   rillig
Date:           Sun Sep 13 06:36:54 UTC 2020

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

Log Message:
make(1): reduce indentation in Compat_RunCommand

The while (1) had been there since the initial import on 1993-03-21, and
in all that time there had never been a good reason for having it.


To generate a diff of this commit:
cvs rdiff -u -r1.143 -r1.144 src/usr.bin/make/compat.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/compat.c
diff -u src/usr.bin/make/compat.c:1.143 src/usr.bin/make/compat.c:1.144
--- src/usr.bin/make/compat.c:1.143	Sat Sep 12 15:10:55 2020
+++ src/usr.bin/make/compat.c	Sun Sep 13 06:36:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.143 2020/09/12 15:10:55 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.144 2020/09/13 06:36:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.143 2020/09/12 15:10:55 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.144 2020/09/13 06:36:54 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.143 2020/09/12 15:10:55 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.144 2020/09/13 06:36:54 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -390,85 +390,80 @@ Compat_RunCommand(char *cmdp, struct GNo
     /*
      * The child is off and running. Now all we can do is wait...
      */
-    while (1) {
-
-	while ((retstat = wait(&reason)) != cpid) {
-	    if (retstat > 0)
-		JobReapChild(retstat, reason, FALSE); /* not ours? */
-	    if (retstat == -1 && errno != EINTR) {
-		break;
-	    }
+    while ((retstat = wait(&reason)) != cpid) {
+	if (retstat > 0)
+	    JobReapChild(retstat, reason, FALSE); /* not ours? */
+	if (retstat == -1 && errno != EINTR) {
+	    break;
 	}
+    }
+
+    if (retstat < 0)
+	Fatal("error in wait: %d: %s", retstat, strerror(errno));
 
-	if (retstat > -1) {
-	    if (WIFSTOPPED(reason)) {
-		status = WSTOPSIG(reason);		/* stopped */
-	    } else if (WIFEXITED(reason)) {
-		status = WEXITSTATUS(reason);		/* exited */
+    if (WIFSTOPPED(reason)) {
+	status = WSTOPSIG(reason);		/* stopped */
+    } else if (WIFEXITED(reason)) {
+	status = WEXITSTATUS(reason);		/* exited */
 #if defined(USE_META) && defined(USE_FILEMON_ONCE)
-		if (useMeta) {
-		    meta_cmd_finish(NULL);
-		}
+	if (useMeta) {
+	    meta_cmd_finish(NULL);
+	}
 #endif
-		if (status != 0) {
-		    if (DEBUG(ERROR)) {
-			fprintf(debug_file, "\n*** Failed target:  %s\n*** Failed command: ",
-			    gn->name);
-			for (cp = cmd; *cp; ) {
-			    if (ch_isspace(*cp)) {
-				fprintf(debug_file, " ");
-				while (ch_isspace(*cp))
-				    cp++;
-			    } else {
-				fprintf(debug_file, "%c", *cp);
-				cp++;
-			    }
-			}
-			fprintf(debug_file, "\n");
+	if (status != 0) {
+	    if (DEBUG(ERROR)) {
+		fprintf(debug_file, "\n*** Failed target:  %s\n*** Failed command: ",
+		    gn->name);
+		for (cp = cmd; *cp; ) {
+		    if (ch_isspace(*cp)) {
+			fprintf(debug_file, " ");
+			while (ch_isspace(*cp))
+			    cp++;
+		    } else {
+			fprintf(debug_file, "%c", *cp);
+			cp++;
 		    }
-		    printf("*** Error code %d", status);
 		}
-	    } else {
-		status = WTERMSIG(reason);		/* signaled */
-		printf("*** Signal %d", status);
+		fprintf(debug_file, "\n");
 	    }
+	    printf("*** Error code %d", status);
+	}
+    } else {
+	status = WTERMSIG(reason);		/* signaled */
+	printf("*** Signal %d", status);
+    }
 
 
-	    if (!WIFEXITED(reason) || (status != 0)) {
-		if (errCheck) {
+    if (!WIFEXITED(reason) || (status != 0)) {
+	if (errCheck) {
 #ifdef USE_META
-		    if (useMeta) {
-			meta_job_error(NULL, gn, 0, status);
-		    }
+	    if (useMeta) {
+		meta_job_error(NULL, gn, 0, status);
+	    }
 #endif
-		    gn->made = ERROR;
-		    if (keepgoing) {
-			/*
-			 * Abort the current target, but let others
-			 * continue.
-			 */
-			printf(" (continuing)\n");
-		    } else {
-			printf("\n");
-		    }
-		    if (deleteOnError) {
-			    CompatDeleteTarget(gn);
-		    }
-		} else {
-		    /*
-		     * Continue executing commands for this target.
-		     * If we return 0, this will happen...
-		     */
-		    printf(" (ignored)\n");
-		    status = 0;
-		}
+	    gn->made = ERROR;
+	    if (keepgoing) {
+		/*
+		 * Abort the current target, but let others
+		 * continue.
+		 */
+		printf(" (continuing)\n");
+	    } else {
+		printf("\n");
+	    }
+	    if (deleteOnError) {
+		    CompatDeleteTarget(gn);
 	    }
-	    break;
 	} else {
-	    Fatal("error in wait: %d: %s", retstat, strerror(errno));
-	    /*NOTREACHED*/
+	    /*
+	     * Continue executing commands for this target.
+	     * If we return 0, this will happen...
+	     */
+	    printf(" (ignored)\n");
+	    status = 0;
 	}
     }
+
     free(cmdStart);
     compatChild = 0;
     if (compatSigno) {

Reply via email to