Module Name: src Committed By: rillig Date: Sat Jan 30 22:48:50 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: extract has_side_effect from check_null_effect No functional change. To generate a diff of this commit: cvs rdiff -u -r1.196 -r1.197 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.196 src/usr.bin/xlint/lint1/tree.c:1.197 --- src/usr.bin/xlint/lint1/tree.c:1.196 Sat Jan 30 21:58:04 2021 +++ src/usr.bin/xlint/lint1/tree.c Sat Jan 30 22:48:50 2021 @@ -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 @@ expr(tnode_t *tn, bool vctx, bool tctx, 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 @@ check_null_effect(const tnode_t *tn) 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); + } } /*