summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2023-07-01 10:04:27 +0000
committerrillig <rillig@NetBSD.org>2023-07-01 10:04:27 +0000
commitf77d93c93fbd7e43e3d5184f8b56eac95ee56cd1 (patch)
treee65ab1c390e63d527d68b4ce17a084e52ab68597 /usr.bin
parentd86f03fc8f05a5b46bfbc973065155c709df793e (diff)
lint: constify, reduce indentation
No functional change.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xlint/lint1/decl.c8
-rw-r--r--usr.bin/xlint/lint1/tree.c19
2 files changed, 13 insertions, 14 deletions
diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c
index 28fbeee6faf..214b2b5793f 100644
--- a/usr.bin/xlint/lint1/decl.c
+++ b/usr.bin/xlint/lint1/decl.c
@@ -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 --git a/usr.bin/xlint/lint1/tree.c b/usr.bin/xlint/lint1/tree.c
index d58762a1b1e..292e2ff2284 100644
--- a/usr.bin/xlint/lint1/tree.c
+++ b/usr.bin/xlint/lint1/tree.c
@@ -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;
}