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: constify, reduce indentation



details:   https://anonhg.NetBSD.org/src/rev/abf01fe3b8a9
branches:  trunk
changeset: 377219:abf01fe3b8a9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jul 01 10:04:27 2023 +0000

description:
lint: constify, reduce indentation

No functional change.

diffstat:

 usr.bin/xlint/lint1/decl.c |   8 ++++----
 usr.bin/xlint/lint1/tree.c |  19 +++++++++----------
 2 files changed, 13 insertions(+), 14 deletions(-)

diffs (83 lines):

diff -r faa2ca06a4f3 -r abf01fe3b8a9 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Jul 01 09:59:51 2023 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sat Jul 01 10:04:27 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.331 2023/07/01 09:31:55 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.332 2023/07/01 10:04:27 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.331 2023/07/01 09:31:55 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.332 2023/07/01 10:04:27 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -424,7 +424,7 @@ set_first_typedef(type_t *tp, sym_t *sym
 }
 
 static unsigned int
-bit_fields_width(sym_t **mem, bool *named)
+bit_fields_width(const sym_t **mem, bool *named)
 {
        unsigned int width = 0;
        unsigned int align = 0;
@@ -452,7 +452,7 @@ pack_struct_or_union(type_t *tp)
 
        unsigned int bits = 0;
        bool named = false;
-       for (sym_t *mem = tp->t_sou->sou_first_member;
+       for (const sym_t *mem = tp->t_sou->sou_first_member;
             mem != NULL; mem = mem->s_next) {
                // TODO: Maybe update mem->u.s_member.sm_offset_in_bits.
                if (mem->s_type->t_bitfield) {
diff -r faa2ca06a4f3 -r abf01fe3b8a9 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sat Jul 01 09:59:51 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sat Jul 01 10:04:27 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.541 2023/07/01 09:31:55 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.542 2023/07/01 10:04:27 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.541 2023/07/01 09:31:55 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.542 2023/07/01 10:04:27 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -4014,6 +4014,11 @@ type_size_in_bits(const type_t *tp)
 
        unsigned int elsz;
        switch (tp->t_tspec) {
+       case VOID:
+               /* cannot take size/alignment of void */
+               error(146);
+               elsz = 1;
+               break;
        case FUNC:
                /* cannot take size/alignment of function type '%s' */
                error(144, type_name(tp));
@@ -4040,14 +4045,8 @@ type_size_in_bits(const type_t *tp)
                        /* cannot take size/alignment of bit-field */
                        error(145);
                }
-               if (tp->t_tspec == VOID) {
-                       /* cannot take size/alignment of void */
-                       error(146);
-                       elsz = 1;
-               } else {
-                       elsz = size_in_bits(tp->t_tspec);
-                       lint_assert(elsz > 0);
-               }
+               elsz = size_in_bits(tp->t_tspec);
+               lint_assert(elsz > 0);
                break;
        }
 



Home | Main Index | Thread Index | Old Index