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 dinfo_t.d_offset to d_offse...



details:   https://anonhg.NetBSD.org/src/rev/a0e9c6153224
branches:  trunk
changeset: 365137:a0e9c6153224
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Apr 09 21:19:52 2022 +0000

description:
lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y |   6 +++---
 usr.bin/xlint/lint1/debug.c |   8 ++++----
 usr.bin/xlint/lint1/decl.c  |  34 +++++++++++++++++-----------------
 usr.bin/xlint/lint1/lint1.h |   4 ++--
 4 files changed, 26 insertions(+), 26 deletions(-)

diffs (151 lines):

diff -r ead33d824a2b -r a0e9c6153224 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sat Apr 09 19:59:08 2022 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sat Apr 09 21:19:52 2022 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.391 2022/04/09 15:43:41 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.392 2022/04/09 21:19:52 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.391 2022/04/09 15:43:41 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.392 2022/04/09 21:19:52 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -921,7 +921,7 @@
          T_STRUCT_OR_UNION {
                symtyp = FTAG;
                begin_declaration_level($1 == STRUCT ? MOS : MOU);
-               dcs->d_offset = 0;
+               dcs->d_offset_in_bits = 0;
                dcs->d_sou_align_in_bits = CHAR_SIZE;
                $$ = $1;
          }
diff -r ead33d824a2b -r a0e9c6153224 usr.bin/xlint/lint1/debug.c
--- a/usr.bin/xlint/lint1/debug.c       Sat Apr 09 19:59:08 2022 +0000
+++ b/usr.bin/xlint/lint1/debug.c       Sat Apr 09 21:19:52 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.15 2022/04/09 16:02:14 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.16 2022/04/09 21:19:52 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.15 2022/04/09 16:02:14 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.16 2022/04/09 21:19:52 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -325,8 +325,8 @@
        }
        if (d->d_redeclared_symbol != NULL)
                debug_sym(" redeclared=(", d->d_redeclared_symbol, ")");
-       if (d->d_offset != 0)
-               debug_printf(" offset=%u", d->d_offset);
+       if (d->d_offset_in_bits != 0)
+               debug_printf(" offset=%u", d->d_offset_in_bits);
        if (d->d_sou_align_in_bits != 0)
                debug_printf(" align=%u", (unsigned)d->d_sou_align_in_bits);
 
diff -r ead33d824a2b -r a0e9c6153224 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Apr 09 19:59:08 2022 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sat Apr 09 21:19:52 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.274 2022/04/09 16:02:14 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.275 2022/04/09 21:19:52 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.274 2022/04/09 16:02:14 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.275 2022/04/09 21:19:52 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1161,24 +1161,24 @@
        }
 
        if (dcs->d_ctx == MOU) {
-               o = dcs->d_offset;
-               dcs->d_offset = 0;
+               o = dcs->d_offset_in_bits;
+               dcs->d_offset_in_bits = 0;
        }
        if (dsym->s_bitfield) {
                align(alignment_in_bits(tp), tp->t_flen);
-               dsym->u.s_member.sm_offset_in_bits =
-                   dcs->d_offset - dcs->d_offset % size_in_bits(t);
-               tp->t_foffs =
-                   dcs->d_offset - dsym->u.s_member.sm_offset_in_bits;
-               dcs->d_offset += tp->t_flen;
+               dsym->u.s_member.sm_offset_in_bits = dcs->d_offset_in_bits -
+                   dcs->d_offset_in_bits % size_in_bits(t);
+               tp->t_foffs = dcs->d_offset_in_bits -
+                   dsym->u.s_member.sm_offset_in_bits;
+               dcs->d_offset_in_bits += tp->t_flen;
        } else {
                align(alignment_in_bits(tp), 0);
-               dsym->u.s_member.sm_offset_in_bits = dcs->d_offset;
-               dcs->d_offset += sz;
+               dsym->u.s_member.sm_offset_in_bits = dcs->d_offset_in_bits;
+               dcs->d_offset_in_bits += sz;
        }
        if (dcs->d_ctx == MOU) {
-               if (o > dcs->d_offset)
-                       dcs->d_offset = o;
+               if (o > dcs->d_offset_in_bits)
+                       dcs->d_offset_in_bits = o;
        }
 
        check_function_definition(dsym, false);
@@ -1210,9 +1210,9 @@
        if (al > dcs->d_sou_align_in_bits)
                dcs->d_sou_align_in_bits = al;
 
-       no = (dcs->d_offset + (al - 1)) & ~(al - 1);
-       if (len == 0 || dcs->d_offset + len > no)
-               dcs->d_offset = no;
+       no = (dcs->d_offset_in_bits + (al - 1)) & ~(al - 1);
+       if (len == 0 || dcs->d_offset_in_bits + len > no)
+               dcs->d_offset_in_bits = no;
 }
 
 /*
@@ -1847,7 +1847,7 @@
        if (tp->t_packed)
                setpackedsize(tp);
        else
-               sp->sou_size_in_bits = dcs->d_offset;
+               sp->sou_size_in_bits = dcs->d_offset_in_bits;
 
        if (sp->sou_size_in_bits == 0) {
                /* zero sized %s is a C99 feature */
diff -r ead33d824a2b -r a0e9c6153224 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Sat Apr 09 19:59:08 2022 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Sat Apr 09 21:19:52 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.148 2022/04/09 16:02:14 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.149 2022/04/09 21:19:52 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -349,7 +349,7 @@
        type_t  *d_type;        /* after end_type() pointer to the type used
                                   for all declarators */
        sym_t   *d_redeclared_symbol;
-       unsigned int d_offset;  /* offset of next structure member in bits */
+       unsigned int d_offset_in_bits; /* offset of next structure member */
        unsigned short d_sou_align_in_bits; /* alignment required for current
                                 * structure */
        scl_t   d_ctx;          /* context of declaration */



Home | Main Index | Thread Index | Old Index