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 is_member into separate fu...



details:   https://anonhg.NetBSD.org/src/rev/1bb50782ca21
branches:  trunk
changeset: 365135:1bb50782ca21
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Apr 09 16:02:14 2022 +0000

description:
lint: extract is_member into separate function

No functional change.

diffstat:

 usr.bin/xlint/lint1/debug.c |   7 +++----
 usr.bin/xlint/lint1/decl.c  |  10 ++++------
 usr.bin/xlint/lint1/lint1.h |   8 +++++++-
 usr.bin/xlint/lint1/tree.c  |   8 ++++----
 4 files changed, 18 insertions(+), 15 deletions(-)

diffs (116 lines):

diff -r 9d258eff973c -r 1bb50782ca21 usr.bin/xlint/lint1/debug.c
--- a/usr.bin/xlint/lint1/debug.c       Sat Apr 09 15:43:41 2022 +0000
+++ b/usr.bin/xlint/lint1/debug.c       Sat Apr 09 16:02:14 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.14 2022/04/09 15:43:41 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.15 2022/04/09 16:02:14 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: debug.c,v 1.14 2022/04/09 15:43:41 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.15 2022/04/09 16:02:14 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -277,8 +277,7 @@
                debug_printf(" value=%s",
                    sym->u.s_bool_constant ? "true" : "false");
 
-       if ((sym->s_scl == MOS || sym->s_scl == MOU) &&
-           sym->u.s_member.sm_sou_type != NULL) {
+       if (is_member(sym) && sym->u.s_member.sm_sou_type != NULL) {
                struct_or_union *sou_type = sym->u.s_member.sm_sou_type;
                const char *tag = sou_type->sou_tag->s_name;
                const sym_t *def = sou_type->sou_first_typedef;
diff -r 9d258eff973c -r 1bb50782ca21 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Apr 09 15:43:41 2022 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sat Apr 09 16:02:14 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.273 2022/04/09 15:43:41 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.274 2022/04/09 16:02:14 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.273 2022/04/09 15:43:41 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.274 2022/04/09 16:02:14 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1123,12 +1123,10 @@
        int     sz;
        unsigned int o = 0;     /* Appease GCC */
 
-       lint_assert(dsym->s_scl == MOS || dsym->s_scl == MOU);
+       lint_assert(is_member(dsym));
 
        if (dcs->d_redeclared_symbol != NULL) {
-               /* should be ensured by storesym() */
-               lint_assert(dcs->d_redeclared_symbol->s_scl == MOS ||
-                   dcs->d_redeclared_symbol->s_scl == MOU);
+               lint_assert(is_member(dcs->d_redeclared_symbol));
 
                if (dsym->u.s_member.sm_sou_type ==
                    dcs->d_redeclared_symbol->u.s_member.sm_sou_type) {
diff -r 9d258eff973c -r 1bb50782ca21 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Sat Apr 09 15:43:41 2022 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Sat Apr 09 16:02:14 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.147 2022/04/09 15:43:41 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.148 2022/04/09 16:02:14 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -582,3 +582,9 @@
 {
        return t == STRUCT || t == UNION;
 }
+
+static inline bool
+is_member(const sym_t *sym)
+{
+       return sym->s_scl == MOS || sym->s_scl == MOU;
+}
diff -r 9d258eff973c -r 1bb50782ca21 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sat Apr 09 15:43:41 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sat Apr 09 16:02:14 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.422 2022/04/09 15:43:41 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.423 2022/04/09 16:02:14 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.422 2022/04/09 15:43:41 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.423 2022/04/09 16:02:14 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -386,7 +386,7 @@
         */
        if (str != NULL) {
                for (sym = msym; sym != NULL; sym = sym->s_symtab_next) {
-                       if (sym->s_scl != MOS && sym->s_scl != MOU)
+                       if (!is_member(sym))
                                continue;
                        if (sym->u.s_member.sm_sou_type != str)
                                continue;
@@ -2776,7 +2776,7 @@
        bool    nolval;
 
        lint_assert(rn->tn_op == NAME);
-       lint_assert(rn->tn_sym->s_scl == MOS || rn->tn_sym->s_scl == MOU);
+       lint_assert(is_member(rn->tn_sym));
 
        /*
         * Remember if the left operand is an lvalue (structure members



Home | Main Index | Thread Index | Old Index