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: use unsigned int for struct alignment



details:   https://anonhg.NetBSD.org/src/rev/8893f6ddceeb
branches:  trunk
changeset: 377234:8893f6ddceeb
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 02 17:41:30 2023 +0000

description:
lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.

diffstat:

 usr.bin/xlint/lint1/debug.c |  9 ++++-----
 usr.bin/xlint/lint1/decl.c  |  6 +++---
 usr.bin/xlint/lint1/lint1.h |  6 +++---
 3 files changed, 10 insertions(+), 11 deletions(-)

diffs (91 lines):

diff -r c8268999fd82 -r 8893f6ddceeb usr.bin/xlint/lint1/debug.c
--- a/usr.bin/xlint/lint1/debug.c       Sun Jul 02 13:25:52 2023 +0000
+++ b/usr.bin/xlint/lint1/debug.c       Sun Jul 02 17:41:30 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.43 2023/07/02 10:20:45 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.44 2023/07/02 17:41:30 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.43 2023/07/02 10:20:45 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.44 2023/07/02 17:41:30 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -126,8 +126,7 @@ debug_type_details(const type_t *tp)
        if (is_struct_or_union(tp->t_tspec)) {
                debug_indent_inc();
                debug_step("size %u bits, align %u bits, %s",
-                   tp->t_sou->sou_size_in_bits,
-                   (unsigned int)tp->t_sou->sou_align_in_bits,
+                   tp->t_sou->sou_size_in_bits, tp->t_sou->sou_align_in_bits,
                    tp->t_sou->sou_incomplete ? "incomplete" : "complete");
 
                for (const sym_t *mem = tp->t_sou->sou_first_member;
@@ -418,7 +417,7 @@ debug_decl_level(const decl_level *dl)
        if (dl->d_offset_in_bits != 0)
                debug_printf(" offset=%u", dl->d_offset_in_bits);
        if (dl->d_sou_align_in_bits != 0)
-               debug_printf(" align=%u", (unsigned)dl->d_sou_align_in_bits);
+               debug_printf(" align=%u", dl->d_sou_align_in_bits);
 
        debug_word(dl->d_const, "const");
        debug_word(dl->d_volatile, "volatile");
diff -r c8268999fd82 -r 8893f6ddceeb usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sun Jul 02 13:25:52 2023 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sun Jul 02 17:41:30 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.335 2023/07/02 10:20:45 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.336 2023/07/02 17:41:30 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.335 2023/07/02 10:20:45 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.336 2023/07/02 17:41:30 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1731,7 +1731,7 @@ complete_struct_or_union(sym_t *first_me
        if (tp == NULL)         /* in case of syntax errors */
                return gettyp(INT);
 
-       dcs_align((u_int)dcs->d_sou_align_in_bits, 0);
+       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;
diff -r c8268999fd82 -r 8893f6ddceeb usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Sun Jul 02 13:25:52 2023 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Sun Jul 02 17:41:30 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.175 2023/07/02 08:16:19 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.176 2023/07/02 17:41:30 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -121,7 +121,7 @@ typedef struct {
  */
 typedef        struct {
        unsigned int sou_size_in_bits;
-       unsigned short sou_align_in_bits;
+       unsigned int sou_align_in_bits;
        bool    sou_incomplete:1;
        struct  sym *sou_first_member;
        struct  sym *sou_tag;
@@ -354,7 +354,7 @@ typedef     struct decl_level {
                                 * used for all declarators */
        sym_t   *d_redeclared_symbol;
        unsigned int d_offset_in_bits; /* offset of next structure member */
-       unsigned short d_sou_align_in_bits; /* alignment required for current
+       unsigned int d_sou_align_in_bits; /* alignment required for current
                                 * structure */
        bool    d_const:1;      /* const in declaration specifiers */
        bool    d_volatile:1;   /* volatile in declaration specifiers */



Home | Main Index | Thread Index | Old Index