Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make: use assertion for internal error condition



details:   https://anonhg.NetBSD.org/src/rev/dc6d076d3b75
branches:  trunk
changeset: 370676:dc6d076d3b75
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Sep 24 10:12:46 2022 +0000

description:
make: use assertion for internal error condition

When the nesting level of conditionals is restored to an unreasonably
high value, the error message "0 open conditionals" doesn't make sense.

diffstat:

 usr.bin/make/cond.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 92c041a522b2 -r dc6d076d3b75 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Fri Sep 23 22:58:15 2022 +0000
+++ b/usr.bin/make/cond.c       Sat Sep 24 10:12:46 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.338 2022/09/23 22:58:15 sjg Exp $   */
+/*     $NetBSD: cond.c,v 1.339 2022/09/24 10:12:46 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.338 2022/09/23 22:58:15 sjg Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.339 2022/09/24 10:12:46 rillig Exp $");
 
 /*
  * Conditional expressions conform to this grammar:
@@ -1260,7 +1260,8 @@
 {
        unsigned int open_conds = cond_depth - cond_min_depth;
 
-       if (open_conds != 0 || saved_depth > cond_depth) {
+       assert(saved_depth <= cond_depth);
+       if (open_conds != 0) {
                Parse_Error(PARSE_FATAL, "%u open conditional%s",
                    open_conds, open_conds == 1 ? "" : "s");
                cond_depth = cond_min_depth;



Home | Main Index | Thread Index | Old Index