Module Name: src Committed By: rillig Date: Sat Apr 9 21:19:52 UTC 2022
Modified Files: src/usr.bin/xlint/lint1: cgram.y debug.c decl.c lint1.h Log Message: lint: rename dinfo_t.d_offset to d_offset_in_bits Most often, offsets are measured in bytes, so better embed the unit in the variable name. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.391 -r1.392 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.274 -r1.275 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.148 -r1.149 src/usr.bin/xlint/lint1/lint1.h 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/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.391 src/usr.bin/xlint/lint1/cgram.y:1.392 --- src/usr.bin/xlint/lint1/cgram.y:1.391 Sat Apr 9 15:43:41 2022 +++ src/usr.bin/xlint/lint1/cgram.y Sat Apr 9 21:19:52 2022 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.391 2022/04/09 15:43:41 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.392 2022/04/09 21:19:52 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.391 2022/04/09 15:43:41 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.392 2022/04/09 21:19:52 rillig Exp $"); #endif #include <limits.h> @@ -921,7 +921,7 @@ struct_or_union: /* C99 6.7.2.1 */ T_STRUCT_OR_UNION { symtyp = FTAG; begin_declaration_level($1 == STRUCT ? MOS : MOU); - dcs->d_offset = 0; + dcs->d_offset_in_bits = 0; dcs->d_sou_align_in_bits = CHAR_SIZE; $$ = $1; } Index: src/usr.bin/xlint/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.15 src/usr.bin/xlint/lint1/debug.c:1.16 --- src/usr.bin/xlint/lint1/debug.c:1.15 Sat Apr 9 16:02:14 2022 +++ src/usr.bin/xlint/lint1/debug.c Sat Apr 9 21:19:52 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.15 2022/04/09 16:02:14 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.16 2022/04/09 21:19:52 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: debug.c,v 1.15 2022/04/09 16:02:14 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.16 2022/04/09 21:19:52 rillig Exp $"); #endif #include <stdlib.h> @@ -325,8 +325,8 @@ debug_dinfo(const dinfo_t *d) // NOLINT( } if (d->d_redeclared_symbol != NULL) debug_sym(" redeclared=(", d->d_redeclared_symbol, ")"); - if (d->d_offset != 0) - debug_printf(" offset=%u", d->d_offset); + if (d->d_offset_in_bits != 0) + debug_printf(" offset=%u", d->d_offset_in_bits); if (d->d_sou_align_in_bits != 0) debug_printf(" align=%u", (unsigned)d->d_sou_align_in_bits); Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.274 src/usr.bin/xlint/lint1/decl.c:1.275 --- src/usr.bin/xlint/lint1/decl.c:1.274 Sat Apr 9 16:02:14 2022 +++ src/usr.bin/xlint/lint1/decl.c Sat Apr 9 21:19:52 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.274 2022/04/09 16:02:14 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.275 2022/04/09 21:19:52 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.274 2022/04/09 16:02:14 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.275 2022/04/09 21:19:52 rillig Exp $"); #endif #include <sys/param.h> @@ -1161,24 +1161,24 @@ declarator_1_struct_union(sym_t *dsym) } if (dcs->d_ctx == MOU) { - o = dcs->d_offset; - dcs->d_offset = 0; + o = dcs->d_offset_in_bits; + dcs->d_offset_in_bits = 0; } if (dsym->s_bitfield) { align(alignment_in_bits(tp), tp->t_flen); - dsym->u.s_member.sm_offset_in_bits = - dcs->d_offset - dcs->d_offset % size_in_bits(t); - tp->t_foffs = - dcs->d_offset - dsym->u.s_member.sm_offset_in_bits; - dcs->d_offset += tp->t_flen; + dsym->u.s_member.sm_offset_in_bits = dcs->d_offset_in_bits - + dcs->d_offset_in_bits % size_in_bits(t); + tp->t_foffs = dcs->d_offset_in_bits - + dsym->u.s_member.sm_offset_in_bits; + dcs->d_offset_in_bits += tp->t_flen; } else { align(alignment_in_bits(tp), 0); - dsym->u.s_member.sm_offset_in_bits = dcs->d_offset; - dcs->d_offset += sz; + dsym->u.s_member.sm_offset_in_bits = dcs->d_offset_in_bits; + dcs->d_offset_in_bits += sz; } if (dcs->d_ctx == MOU) { - if (o > dcs->d_offset) - dcs->d_offset = o; + if (o > dcs->d_offset_in_bits) + dcs->d_offset_in_bits = o; } check_function_definition(dsym, false); @@ -1210,9 +1210,9 @@ align(unsigned int al, unsigned int len) if (al > dcs->d_sou_align_in_bits) dcs->d_sou_align_in_bits = al; - no = (dcs->d_offset + (al - 1)) & ~(al - 1); - if (len == 0 || dcs->d_offset + len > no) - dcs->d_offset = no; + no = (dcs->d_offset_in_bits + (al - 1)) & ~(al - 1); + if (len == 0 || dcs->d_offset_in_bits + len > no) + dcs->d_offset_in_bits = no; } /* @@ -1847,7 +1847,7 @@ complete_tag_struct_or_union(type_t *tp, if (tp->t_packed) setpackedsize(tp); else - sp->sou_size_in_bits = dcs->d_offset; + sp->sou_size_in_bits = dcs->d_offset_in_bits; if (sp->sou_size_in_bits == 0) { /* zero sized %s is a C99 feature */ Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.148 src/usr.bin/xlint/lint1/lint1.h:1.149 --- src/usr.bin/xlint/lint1/lint1.h:1.148 Sat Apr 9 16:02:14 2022 +++ src/usr.bin/xlint/lint1/lint1.h Sat Apr 9 21:19:52 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.148 2022/04/09 16:02:14 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.149 2022/04/09 21:19:52 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -349,7 +349,7 @@ typedef struct dinfo { type_t *d_type; /* after end_type() pointer to the type used for all declarators */ sym_t *d_redeclared_symbol; - unsigned int d_offset; /* offset of next structure member in bits */ + unsigned int d_offset_in_bits; /* offset of next structure member */ unsigned short d_sou_align_in_bits; /* alignment required for current * structure */ scl_t d_ctx; /* context of declaration */