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/6830c118bf84
branches: trunk
changeset: 980292:6830c118bf84
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 3c0198f8340d -r 6830c118bf84 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