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: clean up variable names relating t...



details:   https://anonhg.NetBSD.org/src/rev/ee639909b3df
branches:  trunk
changeset: 377236:ee639909b3df
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 02 18:28:15 2023 +0000

description:
lint: clean up variable names relating to structure padding

diffstat:

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

diffs (178 lines):

diff -r fc7e413795f1 -r ee639909b3df usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun Jul 02 18:14:44 2023 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Jul 02 18:28:15 2023 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.443 2023/06/30 21:39:54 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.444 2023/07/02 18:28:15 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: cgram.y,v 1.443 2023/06/30 21:39:54 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.444 2023/07/02 18:28:15 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -898,7 +898,7 @@ struct_or_union:            /* C99 6.7.2.1 */
          T_STRUCT_OR_UNION {
                symtyp = FTAG;
                begin_declaration_level($1 == STRUCT ? DLK_STRUCT : DLK_UNION);
-               dcs->d_offset_in_bits = 0;
+               dcs->d_sou_size_in_bits = 0;
                dcs->d_sou_align_in_bits = CHAR_SIZE;
                $$ = $1;
          }
diff -r fc7e413795f1 -r ee639909b3df usr.bin/xlint/lint1/debug.c
--- a/usr.bin/xlint/lint1/debug.c       Sun Jul 02 18:14:44 2023 +0000
+++ b/usr.bin/xlint/lint1/debug.c       Sun Jul 02 18:28:15 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.45 2023/07/02 18:14:44 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.46 2023/07/02 18:28:15 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: debug.c,v 1.45 2023/07/02 18:14:44 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.46 2023/07/02 18:28:15 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -414,8 +414,8 @@ debug_decl_level(const decl_level *dl)
        }
        if (dl->d_redeclared_symbol != NULL)
                debug_sym(" redeclared=(", dl->d_redeclared_symbol, ")");
-       if (dl->d_offset_in_bits != 0)
-               debug_printf(" offset=%u", dl->d_offset_in_bits);
+       if (dl->d_sou_size_in_bits != 0)
+               debug_printf(" size=%u", dl->d_sou_size_in_bits);
        if (dl->d_sou_align_in_bits != 0)
                debug_printf(" align=%u", dl->d_sou_align_in_bits);
 
diff -r fc7e413795f1 -r ee639909b3df usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sun Jul 02 18:14:44 2023 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sun Jul 02 18:28:15 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.337 2023/07/02 18:14:44 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.338 2023/07/02 18:28:15 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.337 2023/07/02 18:14:44 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.338 2023/07/02 18:28:15 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1024,28 +1024,28 @@ dcs_add_member(sym_t *mem)
 {
        type_t *tp = mem->s_type;
 
-       unsigned int union_offset = 0;
+       unsigned int union_size = 0;
        if (dcs->d_kind == DLK_UNION) {
-               union_offset = dcs->d_offset_in_bits;
-               dcs->d_offset_in_bits = 0;
+               union_size = dcs->d_sou_size_in_bits;
+               dcs->d_sou_size_in_bits = 0;
        }
 
        if (mem->s_bitfield) {
                dcs_align(alignment_in_bits(tp), tp->t_bit_field_width);
                // XXX: Why round down?
-               mem->u.s_member.sm_offset_in_bits = dcs->d_offset_in_bits
-                   - dcs->d_offset_in_bits % size_in_bits(tp->t_tspec);
-               tp->t_bit_field_offset = dcs->d_offset_in_bits
+               mem->u.s_member.sm_offset_in_bits = dcs->d_sou_size_in_bits
+                   - dcs->d_sou_size_in_bits % size_in_bits(tp->t_tspec);
+               tp->t_bit_field_offset = dcs->d_sou_size_in_bits
                    - mem->u.s_member.sm_offset_in_bits;
-               dcs->d_offset_in_bits += tp->t_bit_field_width;
+               dcs->d_sou_size_in_bits += tp->t_bit_field_width;
        } else {
                dcs_align(alignment_in_bits(tp), 0);
-               mem->u.s_member.sm_offset_in_bits = dcs->d_offset_in_bits;
-               dcs->d_offset_in_bits += type_size_in_bits(tp);
+               mem->u.s_member.sm_offset_in_bits = dcs->d_sou_size_in_bits;
+               dcs->d_sou_size_in_bits += type_size_in_bits(tp);
        }
 
-       if (union_offset > dcs->d_offset_in_bits)
-               dcs->d_offset_in_bits = union_offset;
+       if (union_size > dcs->d_sou_size_in_bits)
+               dcs->d_sou_size_in_bits = union_size;
 }
 
 sym_t *
@@ -1125,11 +1125,11 @@ dcs_align(unsigned int member_alignment,
        if (member_alignment > dcs->d_sou_align_in_bits)
                dcs->d_sou_align_in_bits = member_alignment;
 
-       unsigned int offset = (dcs->d_offset_in_bits + member_alignment - 1)
+       unsigned int offset = (dcs->d_sou_size_in_bits + member_alignment - 1)
            & ~(member_alignment - 1);
        if (bit_field_width == 0
-           || dcs->d_offset_in_bits + bit_field_width > offset)
-               dcs->d_offset_in_bits = offset;
+           || dcs->d_sou_size_in_bits + bit_field_width > offset)
+               dcs->d_sou_size_in_bits = offset;
 }
 
 sym_t *
@@ -1733,16 +1733,16 @@ complete_struct_or_union(sym_t *first_me
 
        dcs_align(dcs->d_sou_align_in_bits, 0);
 
-       struct_or_union *sp = tp->t_sou;
-       sp->sou_align_in_bits = dcs->d_sou_align_in_bits;
-       sp->sou_incomplete = false;
-       sp->sou_first_member = first_member;
+       struct_or_union *sou = tp->t_sou;
+       sou->sou_align_in_bits = dcs->d_sou_align_in_bits;
+       sou->sou_incomplete = false;
+       sou->sou_first_member = first_member;
        if (tp->t_packed)
                pack_struct_or_union(tp);
        else
-               sp->sou_size_in_bits = dcs->d_offset_in_bits;
-
-       if (sp->sou_size_in_bits == 0) {
+               sou->sou_size_in_bits = dcs->d_sou_size_in_bits;
+
+       if (sou->sou_size_in_bits == 0) {
                /* zero sized %s is a C99 feature */
                c99ism(47, tspec_name(tp->t_tspec));
        } else if (!has_named_member(tp)) {
diff -r fc7e413795f1 -r ee639909b3df usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Sun Jul 02 18:14:44 2023 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Sun Jul 02 18:28:15 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.177 2023/07/02 18:14:44 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.178 2023/07/02 18:28:15 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -350,9 +350,11 @@ typedef    struct decl_level {
        type_t  *d_type;        /* after dcs_end_type, the pointer to the type
                                 * used for all declarators */
        sym_t   *d_redeclared_symbol;
-       unsigned int d_offset_in_bits; /* offset of next structure member */
-       unsigned int d_sou_align_in_bits; /* alignment required for current
-                                * structure */
+       unsigned int d_sou_size_in_bits;        /* size of the structure or
+                                                * union being built, without
+                                                * trailing padding */
+       unsigned int d_sou_align_in_bits;       /* alignment of the structure
+                                                * or union being built */
        bool    d_const:1;      /* const in declaration specifiers */
        bool    d_volatile:1;   /* volatile in declaration specifiers */
        bool    d_inline:1;     /* inline in declaration specifiers */



Home | Main Index | Thread Index | Old Index