Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: extract has_side_effect from check...



details:   https://anonhg.NetBSD.org/src/rev/34a95de70f68
branches:  trunk
changeset: 959068:34a95de70f68
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 30 22:48:50 2021 +0000

description:
lint: extract has_side_effect from check_null_effect

No functional change.

diffstat:

 usr.bin/xlint/lint1/tree.c |  23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diffs (54 lines):

diff -r 63387dc13014 -r 34a95de70f68 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sat Jan 30 22:38:54 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sat Jan 30 22:48:50 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.196 2021/01/30 21:58:04 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.197 2021/01/30 22:48:50 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.196 2021/01/30 21:58:04 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.197 2021/01/30 22:48:50 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -3770,13 +3770,9 @@
                tfreeblk();
 }
 
-static void
-check_null_effect(const tnode_t *tn)
+static bool
+has_side_effect(const tnode_t *tn)
 {
-
-       if (!hflag)
-               return;
-
        while (!modtab[tn->tn_op].m_has_side_effect) {
                if (tn->tn_op == CVT && tn->tn_type->t_tspec == VOID) {
                        tn = tn->tn_left;
@@ -3808,9 +3804,18 @@
                        break;
                }
        }
-       if (!modtab[tn->tn_op].m_has_side_effect)
+
+       return modtab[tn->tn_op].m_has_side_effect;
+}
+
+static void
+check_null_effect(const tnode_t *tn)
+{
+
+       if (hflag && !has_side_effect(tn)) {
                /* expression has null effect */
                warning(129);
+       }
 }
 
 /*



Home | Main Index | Thread Index | Old Index