Module Name:    src
Committed By:   rillig
Date:           Sat Jul  1 10:04:27 UTC 2023

Modified Files:
        src/usr.bin/xlint/lint1: decl.c tree.c

Log Message:
lint: constify, reduce indentation

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.331 -r1.332 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.541 -r1.542 src/usr.bin/xlint/lint1/tree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.331 src/usr.bin/xlint/lint1/decl.c:1.332
--- src/usr.bin/xlint/lint1/decl.c:1.331	Sat Jul  1 09:31:55 2023
+++ src/usr.bin/xlint/lint1/decl.c	Sat Jul  1 10:04:27 2023
@@ -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) {

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.541 src/usr.bin/xlint/lint1/tree.c:1.542
--- src/usr.bin/xlint/lint1/tree.c:1.541	Sat Jul  1 09:31:55 2023
+++ src/usr.bin/xlint/lint1/tree.c	Sat Jul  1 10:04:27 2023
@@ -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;
 	}
 

Reply via email to