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 compilation for -DNDEBUG and -O3



details:   https://anonhg.NetBSD.org/src/rev/09145ccdc0a8
branches:  trunk
changeset: 1013576:09145ccdc0a8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Aug 31 16:44:25 2020 +0000

description:
make(1): fix compilation for -DNDEBUG and -O3

The -O3 option of GCC 5.5 is unsure about whether s and t are always
defined, since SuffParseTransform only defines them if it returns TRUE.

Therefore assert that it does.  When compiled with -NDEBUG, this would
result in an unused variable, therefore use it using the well-known
cast-to-void pattern.

diffstat:

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

diffs (45 lines):

diff -r 49a1680f0247 -r 09145ccdc0a8 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Mon Aug 31 16:42:10 2020 +0000
+++ b/usr.bin/make/suff.c       Mon Aug 31 16:44:25 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.141 2020/08/31 05:56:02 rillig Exp $        */
+/*     $NetBSD: suff.c,v 1.142 2020/08/31 16:44:25 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.141 2020/08/31 05:56:02 rillig Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.142 2020/08/31 16:44:25 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)suff.c     8.4 (Berkeley) 3/21/94";
 #else
-__RCSID("$NetBSD: suff.c,v 1.141 2020/08/31 05:56:02 rillig Exp $");
+__RCSID("$NetBSD: suff.c,v 1.142 2020/08/31 16:44:25 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -567,6 +567,7 @@
     Suff          *s,          /* source suffix */
                  *t;           /* target suffix */
     LstNode      ln;           /* Node for existing transformation */
+    Boolean ok;
 
     ln = Lst_Find(transforms, SuffGNHasName, line);
     if (ln == NULL) {
@@ -592,7 +593,9 @@
 
     gn->type = OP_TRANSFORM;
 
-    (void)SuffParseTransform(line, &s, &t);
+    ok = SuffParseTransform(line, &s, &t);
+    assert(ok);
+    (void)ok;
 
     /*
      * link the two together in the proper relationship and order



Home | Main Index | Thread Index | Old Index