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: add typedef for types in initializ...



details:   https://anonhg.NetBSD.org/src/rev/703cd5c6c03e
branches:  trunk
changeset: 1028277:703cd5c6c03e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 19 10:17:00 2021 +0000

description:
lint: add typedef for types in initializations

No binary change except for line numbers in assertions.

diffstat:

 usr.bin/xlint/lint1/init.c |  100 ++++++++++++++++++++++----------------------
 1 files changed, 50 insertions(+), 50 deletions(-)

diffs (truncated from 362 to 300 lines):

diff -r 053d7a71f350 -r 703cd5c6c03e usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Sun Dec 19 09:59:57 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Sun Dec 19 10:17:00 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.220 2021/12/18 13:23:09 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.221 2021/12/19 10:17:00 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.220 2021/12/18 13:23:09 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.221 2021/12/19 10:17:00 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -94,10 +94,10 @@
  *
  * C99 6.7.8p6, 6.7.8p7
  */
-struct designator {
+typedef struct designator {
        const char      *dr_name;       /* for struct and union */
        size_t          dr_subscript;   /* for array */
-};
+} designator;
 
 /*
  * The path from the "current object" of a brace level to the sub-object that
@@ -106,11 +106,11 @@
  *
  * C99 6.7.8p6, 6.7.8p7
  */
-struct designation {
-       struct designator *dn_items;
+typedef struct designation {
+       designator      *dn_items;
        size_t          dn_len;
        size_t          dn_cap;
-};
+} designation;
 
 /*
  * Everything that happens between a '{' and the corresponding '}' of an
@@ -118,7 +118,7 @@
  *
  * C99 6.7.8p17
  */
-struct brace_level {
+typedef struct brace_level {
        /* The type of the "current object". */
        const type_t    *bl_type;
 
@@ -129,7 +129,7 @@
         * TODO: use this not only for explicit designations but also for
         *  implicit designations, like in C90.
         */
-       struct designation bl_designation;
+       designation     bl_designation;
 
        /*
         * The next member of the struct or union that is to be initialized,
@@ -162,7 +162,7 @@
        bool            bl_confused:1;
 
        struct brace_level *bl_enclosing;
-};
+} brace_level;
 
 /*
  * An ongoing initialization.
@@ -170,12 +170,12 @@
  * In most cases there is only ever a single initialization going on.  See
  * pointer_to_compound_literal in msg_171.c for an exception.
  */
-struct initialization {
+typedef struct initialization {
        /* The symbol that is to be initialized. */
        sym_t           *in_sym;
 
        /* The innermost brace level. */
-       struct brace_level *in_brace_level;
+       brace_level     *in_brace_level;
 
        /*
         * The maximum subscript that has ever be seen for an array of
@@ -192,7 +192,7 @@
        bool            in_err;
 
        struct initialization *in_enclosing;
-};
+} initialization;
 
 
 static void *
@@ -395,7 +395,7 @@
 
 
 static const type_t *
-designator_look_up(const struct designator *dr, const type_t *tp)
+designator_look_up(const designator *dr, const type_t *tp)
 {
        switch (tp->t_tspec) {
        case STRUCT:
@@ -429,7 +429,7 @@
 
 #ifdef DEBUG
 static void
-designation_debug(const struct designation *dn)
+designation_debug(const designation *dn)
 {
        size_t i;
 
@@ -439,7 +439,7 @@
        debug_indent();
        debug_printf("designation: ");
        for (i = 0; i < dn->dn_len; i++) {
-               const struct designator *dr = dn->dn_items + i;
+               const designator *dr = dn->dn_items + i;
                if (dr->dr_name != NULL) {
                        debug_printf(".%s", dr->dr_name);
                        lint_assert(dr->dr_subscript == 0);
@@ -453,7 +453,7 @@
 #endif
 
 static void
-designation_add(struct designation *dn, const char *name, size_t subscript)
+designation_add(designation *dn, const char *name, size_t subscript)
 {
 
        if (dn->dn_len == dn->dn_cap) {
@@ -474,7 +474,7 @@
  * C99 6.7.8p18
  */
 static const type_t *
-designation_look_up(const struct designation *dn, const type_t *tp)
+designation_look_up(const designation *dn, const type_t *tp)
 {
        size_t i;
 
@@ -484,24 +484,24 @@
 }
 
 static void
-designation_reset(struct designation *dn)
+designation_reset(designation *dn)
 {
 
        dn->dn_len = 0;
 }
 
 static void
-designation_free(struct designation *dn)
+designation_free(designation *dn)
 {
 
        free(dn->dn_items);
 }
 
 
-static struct brace_level *
-brace_level_new(const type_t *tp, struct brace_level *enclosing)
+static brace_level *
+brace_level_new(const type_t *tp, brace_level *enclosing)
 {
-       struct brace_level *bl;
+       brace_level *bl;
 
        bl = xcalloc(1, sizeof(*bl));
        bl->bl_type = tp;
@@ -513,7 +513,7 @@
 }
 
 static void
-brace_level_free(struct brace_level *bl)
+brace_level_free(brace_level *bl)
 {
 
        designation_free(&bl->bl_designation);
@@ -522,7 +522,7 @@
 
 #ifdef DEBUG
 static void
-brace_level_debug(const struct brace_level *bl)
+brace_level_debug(const brace_level *bl)
 {
 
        lint_assert(bl->bl_type != NULL);
@@ -543,7 +543,7 @@
 
 /* Return the type of the sub-object that is currently being initialized. */
 static const type_t *
-brace_level_sub_type(const struct brace_level *bl, bool is_string)
+brace_level_sub_type(const brace_level *bl, bool is_string)
 {
 
        if (bl->bl_designation.dn_len > 0)
@@ -585,9 +585,9 @@
 
 /* C99 6.7.8p17 */
 static void
-brace_level_apply_designation(struct brace_level *bl)
+brace_level_apply_designation(brace_level *bl)
 {
-       const struct designator *dr;
+       const designator *dr;
 
        if (bl->bl_designation.dn_len == 0)
                return;
@@ -618,7 +618,7 @@
  * C99 6.7.8p17
  */
 static void
-brace_level_advance(struct brace_level *bl, size_t *max_subscript)
+brace_level_advance(brace_level *bl, size_t *max_subscript)
 {
 
        switch (bl->bl_type->t_tspec) {
@@ -641,10 +641,10 @@
 }
 
 
-static struct initialization *
-initialization_new(sym_t *sym, struct initialization *enclosing)
+static initialization *
+initialization_new(sym_t *sym, initialization *enclosing)
 {
-       struct initialization *in;
+       initialization *in;
 
        in = xcalloc(1, sizeof(*in));
        in->in_sym = sym;
@@ -654,9 +654,9 @@
 }
 
 static void
-initialization_free(struct initialization *in)
+initialization_free(initialization *in)
 {
-       struct brace_level *bl, *next;
+       brace_level *bl, *next;
 
        for (bl = in->in_brace_level; bl != NULL; bl = next) {
                next = bl->bl_enclosing;
@@ -668,10 +668,10 @@
 
 #ifdef DEBUG
 static void
-initialization_debug(const struct initialization *in)
+initialization_debug(const initialization *in)
 {
        size_t i;
-       const struct brace_level *bl;
+       const brace_level *bl;
 
        if (in->in_brace_level == NULL) {
                debug_step("no brace level");
@@ -695,7 +695,7 @@
  * initialized.
  */
 static const type_t *
-initialization_sub_type(struct initialization *in, bool is_string)
+initialization_sub_type(initialization *in, bool is_string)
 {
        const type_t *tp;
 
@@ -708,7 +708,7 @@
 }
 
 static void
-initialization_begin_brace_level(struct initialization *in)
+initialization_begin_brace_level(initialization *in)
 {
        const type_t *tp;
 
@@ -750,7 +750,7 @@
 
 /* C99 6.7.8p22 */
 static void
-initialization_set_size_of_unknown_array(struct initialization *in)
+initialization_set_size_of_unknown_array(initialization *in)
 {
        size_t dim;
 
@@ -766,9 +766,9 @@
 }
 
 static void
-initialization_end_brace_level(struct initialization *in)
+initialization_end_brace_level(initialization *in)
 {
-       struct brace_level *bl;
+       brace_level *bl;
 
        debug_enter();
 
@@ -792,7 +792,7 @@
 }



Home | Main Index | Thread Index | Old Index