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: rename confusing function setcompl



details:   https://anonhg.NetBSD.org/src/rev/bae4228c5adf
branches:  trunk
changeset: 948686:bae4228c5adf
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Dec 28 22:31:31 2020 +0000

description:
lint: rename confusing function setcompl

The previous function name suggested that it would set the complete flag
of the type, but it was the exact opposite.  To reduce confusion, negate
the meaning of the parameter.

diffstat:

 usr.bin/xlint/lint1/decl.c     |  29 ++++++++++++-----------------
 usr.bin/xlint/lint1/externs1.h |   4 ++--
 usr.bin/xlint/lint1/init.c     |  10 ++++------
 3 files changed, 18 insertions(+), 25 deletions(-)

diffs (143 lines):

diff -r bd5f63ad2ff5 -r bae4228c5adf usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Mon Dec 28 22:16:42 2020 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Mon Dec 28 22:31:31 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.73 2020/12/28 21:24:55 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.74 2020/12/28 22:31:31 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.73 2020/12/28 21:24:55 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.74 2020/12/28 22:31:31 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -189,22 +189,21 @@
 }
 
 /*
- * Set the flag for (in)complete array, struct, union or enum
- * types.
+ * Mark an array, struct, union or enum type as complete or incomplete.
  */
 void
-setcompl(type_t *tp, int ic)
+setcomplete(type_t *tp, int complete)
 {
        tspec_t t;
 
        if ((t = tp->t_tspec) == ARRAY) {
-               tp->t_aincompl = ic;
+               tp->t_aincompl = !complete;
        } else if (t == STRUCT || t == UNION) {
-               tp->t_str->sincompl = ic;
+               tp->t_str->sincompl = !complete;
        } else {
                if (t != ENUM)
-                       LERROR("setcompl()");
-               tp->t_enum->eincompl = ic;
+                       LERROR("setcomplete()");
+               tp->t_enum->eincompl = !complete;
        }
 }
 
@@ -1357,8 +1356,7 @@
                /* zero array dimension */
                c99ism(322, dim);
        } else if (n == 0 && !dim) {
-               /* is incomplete type */
-               setcompl(tp, 1);
+               setcomplete(tp, 0);
        }
 
        return (decl);
@@ -1687,8 +1685,7 @@
                        tp->t_enum = getblk(sizeof(*tp->t_enum));
                        tp->t_enum->etag = tag;
                }
-               /* ist unvollstaendiger Typ */
-               setcompl(tp, 1);
+               setcomplete(tp, 0);
        }
        return (tp);
 }
@@ -1781,8 +1778,7 @@
        int     n;
        sym_t   *mem;
 
-       /* from now on the type is complete */
-       setcompl(tp, 0);
+       setcomplete(tp, 1);
 
        if ((t = tp->t_tspec) != ENUM) {
                align(dcs->d_stralign, 0);
@@ -2312,8 +2308,7 @@
                        if (dst->t_dim == 0 && src->t_dim != 0) {
                                *dstp = dst = duptyp(dst);
                                dst->t_dim = src->t_dim;
-                               /* now a complete Typ */
-                               setcompl(dst, 0);
+                               setcomplete(dst, 1);
                        }
                } else if (dst->t_tspec == FUNC) {
                        if (!dst->t_proto && src->t_proto) {
diff -r bd5f63ad2ff5 -r bae4228c5adf usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Mon Dec 28 22:16:42 2020 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Mon Dec 28 22:31:31 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.35 2017/03/06 21:01:39 christos Exp $   */
+/*     $NetBSD: externs1.h,v 1.36 2020/12/28 22:31:31 rillig Exp $     */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -140,7 +140,7 @@
 extern type_t  *duptyp(const type_t *);
 extern type_t  *tduptyp(const type_t *);
 extern int     incompl(type_t *);
-extern void    setcompl(type_t *, int);
+extern void    setcomplete(type_t *, int);
 extern void    addscl(scl_t);
 extern void    addtype(type_t *);
 extern void    addqual(tqual_t);
diff -r bd5f63ad2ff5 -r bae4228c5adf usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Mon Dec 28 22:16:42 2020 +0000
+++ b/usr.bin/xlint/lint1/init.c        Mon Dec 28 22:31:31 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.31 2020/12/28 19:07:43 rillig Exp $ */
+/*     $NetBSD: init.c,v 1.32 2020/12/28 22:31:31 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.31 2020/12/28 19:07:43 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.32 2020/12/28 22:31:31 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -275,8 +275,7 @@
                if (istk->i_type->t_tspec != ARRAY)
                        LERROR("pushinit()");
                istk->i_type->t_dim++;
-               /* from now its an complete type */
-               setcompl(istk->i_type, 0);
+               setcomplete(istk->i_type, 1);
        }
 
        if (istk->i_cnt <= 0)
@@ -671,8 +670,7 @@
        if (istk->i_nolimit) {
                istk->i_nolimit = 0;
                istk->i_type->t_dim = len + 1;
-               /* from now complete type */
-               setcompl(istk->i_type, 0);
+               setcomplete(istk->i_type, 1);
        } else {
                if (istk->i_type->t_dim < len) {
                        /* non-null byte ignored in string initializer */



Home | Main Index | Thread Index | Old Index