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(1): fix build errors for USER_CPPFLAGS=-DN...



details:   https://anonhg.NetBSD.org/src/rev/6b128cc3e3e8
branches:  trunk
changeset: 937915:6b128cc3e3e8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 28 19:46:04 2020 +0000

description:
make(1): fix build errors for USER_CPPFLAGS=-DNDEBUG

The functions LstIsValid and LstNodeIsValid are only used in assertions.

Without the always-false assertion, Enum_ValueToString could have
returned undefined behavior.

diffstat:

 usr.bin/make/enum.c |   9 +++++----
 usr.bin/make/lst.c  |  10 +++++-----
 2 files changed, 10 insertions(+), 9 deletions(-)

diffs (74 lines):

diff -r 113fa9562a19 -r 6b128cc3e3e8 usr.bin/make/enum.c
--- a/usr.bin/make/enum.c       Fri Aug 28 19:35:07 2020 +0000
+++ b/usr.bin/make/enum.c       Fri Aug 28 19:46:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: enum.c,v 1.4 2020/08/24 20:15:51 rillig Exp $  */
+/*     $NetBSD: enum.c,v 1.5 2020/08/28 19:46:04 rillig Exp $  */
 
 /*
  Copyright (c) 2020 Roland Illig <rillig%NetBSD.org@localhost>
@@ -28,15 +28,16 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: enum.c,v 1.4 2020/08/24 20:15:51 rillig Exp $";
+static char rcsid[] = "$NetBSD: enum.c,v 1.5 2020/08/28 19:46:04 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: enum.c,v 1.4 2020/08/24 20:15:51 rillig Exp $");
+__RCSID("$NetBSD: enum.c,v 1.5 2020/08/28 19:46:04 rillig Exp $");
 #endif
 #endif
 
 #include <assert.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include "enum.h"
@@ -90,5 +91,5 @@
            if (value == spec->es_value)
                return spec->es_name;
        }
-       assert(!"unknown enum value");
+       abort(/* unknown enum value */);
 }
diff -r 113fa9562a19 -r 6b128cc3e3e8 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Fri Aug 28 19:35:07 2020 +0000
+++ b/usr.bin/make/lst.c        Fri Aug 28 19:46:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.50 2020/08/28 04:48:57 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.51 2020/08/28 19:46:04 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.50 2020/08/28 04:48:57 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.51 2020/08/28 19:46:04 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.50 2020/08/28 04:48:57 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.51 2020/08/28 19:46:04 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -75,13 +75,13 @@
     LstNode prev;              /* Previous node, if open. Used by Lst_Remove */
 };
 
-static Boolean
+static Boolean MAKE_ATTR_UNUSED
 LstIsValid(Lst list)
 {
     return list != NULL;
 }
 
-static Boolean
+static Boolean MAKE_ATTR_UNUSED
 LstNodeIsValid(LstNode node)
 {
     return node != NULL;



Home | Main Index | Thread Index | Old Index