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: sprinkle a few const modifiers thr...



details:   https://anonhg.NetBSD.org/src/rev/94a2d7b4bba0
branches:  trunk
changeset: 958584:94a2d7b4bba0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jan 11 19:29:49 2021 +0000

description:
lint: sprinkle a few const modifiers throughout the code

diffstat:

 usr.bin/xlint/lint1/decl.c     |   23 +++---
 usr.bin/xlint/lint1/emit1.c    |   21 +++---
 usr.bin/xlint/lint1/externs1.h |   28 ++++----
 usr.bin/xlint/lint1/tree.c     |  132 ++++++++++++++++++++++------------------
 4 files changed, 109 insertions(+), 95 deletions(-)

diffs (truncated from 619 to 300 lines):

diff -r 20ef3e5ccf71 -r 94a2d7b4bba0 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Mon Jan 11 17:18:51 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Mon Jan 11 19:29:49 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.120 2021/01/10 18:22:52 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.121 2021/01/11 19:29:49 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.120 2021/01/10 18:22:52 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.121 2021/01/11 19:29:49 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -67,8 +67,8 @@
 static tspec_t merge_type_specifiers(tspec_t, tspec_t);
 static void    align(int, int);
 static sym_t   *newtag(sym_t *, scl_t, int, int);
-static int     eqargs(type_t *, type_t *, int *);
-static int     mnoarg(type_t *, int *);
+static int     eqargs(const type_t *, const type_t *, int *);
+static int     mnoarg(const type_t *, int *);
 static int     check_old_style_definition(sym_t *, sym_t *);
 static int     check_prototype_declaration(sym_t *, sym_t *);
 static sym_t   *new_style_function(sym_t *, sym_t *);
@@ -172,7 +172,7 @@
  * struct, union or enum type.
  */
 int
-incompl(type_t *tp)
+incompl(const type_t *tp)
 {
        tspec_t t;
 
@@ -882,7 +882,7 @@
  * if name is not NULL.
  */
 int
-length(type_t *tp, const char *name)
+length(const type_t *tp, const char *name)
 {
        int     elem, elsz;
 
@@ -926,7 +926,7 @@
  * Get the alignment of the given Type in bits.
  */
 int
-getbound(type_t *tp)
+getbound(const type_t *tp)
 {
        size_t  a;
        tspec_t t;
@@ -2108,7 +2108,8 @@
  *             compatible with a prototype
  */
 int
-eqtype(type_t *tp1, type_t *tp2, int ignqual, int promot, int *dowarn)
+eqtype(const type_t *tp1, const type_t *tp2,
+       int ignqual, int promot, int *dowarn)
 {
        tspec_t t;
 
@@ -2171,7 +2172,7 @@
  * Compares the parameter types of two prototypes.
  */
 static int
-eqargs(type_t *tp1, type_t *tp2, int *dowarn)
+eqargs(const type_t *tp1, const type_t *tp2, int *dowarn)
 {
        sym_t   *a1, *a2;
 
@@ -2205,7 +2206,7 @@
  *        is applied on it
  */
 static int
-mnoarg(type_t *tp, int *dowarn)
+mnoarg(const type_t *tp, int *dowarn)
 {
        sym_t   *arg;
        tspec_t t;
@@ -3213,7 +3214,7 @@
  * Prints information about location of previous definition/declaration.
  */
 void
-print_previous_declaration(int msg, sym_t *psym)
+print_previous_declaration(int msg, const sym_t *psym)
 {
        pos_t   cpos;
 
diff -r 20ef3e5ccf71 -r 94a2d7b4bba0 usr.bin/xlint/lint1/emit1.c
--- a/usr.bin/xlint/lint1/emit1.c       Mon Jan 11 17:18:51 2021 +0000
+++ b/usr.bin/xlint/lint1/emit1.c       Mon Jan 11 19:29:49 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.35 2021/01/10 00:05:46 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.36 2021/01/11 19:29:49 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: emit1.c,v 1.35 2021/01/10 00:05:46 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.36 2021/01/11 19:29:49 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -92,7 +92,7 @@
  * and 'v' (for volatile)
  */
 void
-outtype(type_t *tp)
+outtype(const type_t *tp)
 {
        int     t, s, na;
        sym_t   *arg;
@@ -166,7 +166,7 @@
  * it uses its own output buffer for conversion
  */
 const char *
-ttos(type_t *tp)
+ttos(const type_t *tp)
 {
        static  ob_t    tob;
        ob_t    tmp;
@@ -226,7 +226,7 @@
  * not here
  */
 void
-outsym(sym_t *sym, scl_t sc, def_t def)
+outsym(const sym_t *sym, scl_t sc, def_t def)
 {
 
        /*
@@ -301,10 +301,11 @@
  * they are called with proper argument types
  */
 void
-outfdef(sym_t *fsym, pos_t *posp, int rval, int osdef, sym_t *args)
+outfdef(const sym_t *fsym, const pos_t *posp, int rval, int osdef,
+       const sym_t *args)
 {
-       int     narg;
-       sym_t   *arg;
+       int narg;
+       const sym_t *arg;
 
        /* reset the buffer */
        outclr();
@@ -406,7 +407,7 @@
  * (casted to void)
  */
 void
-outcall(tnode_t *tn, int rvused, int rvdisc)
+outcall(const tnode_t *tn, int rvused, int rvdisc)
 {
        tnode_t *args, *arg;
        int     narg, n, i;
@@ -591,7 +592,7 @@
  * writes a record if sym was used
  */
 void
-outusg(sym_t *sym)
+outusg(const sym_t *sym)
 {
        /* reset buffer */
        outclr();
diff -r 20ef3e5ccf71 -r 94a2d7b4bba0 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Mon Jan 11 17:18:51 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Mon Jan 11 19:29:49 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.53 2021/01/10 14:09:57 rillig Exp $     */
+/*     $NetBSD: externs1.h,v 1.54 2021/01/11 19:29:49 rillig Exp $     */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -141,7 +141,7 @@
 extern type_t  *gettyp(tspec_t);
 extern type_t  *duptyp(const type_t *);
 extern type_t  *tduptyp(const type_t *);
-extern int     incompl(type_t *);
+extern int     incompl(const type_t *);
 extern void    setcomplete(type_t *, int);
 extern void    add_storage_class(scl_t);
 extern void    add_type(type_t *);
@@ -153,8 +153,8 @@
 extern void    setasm(void);
 extern void    clrtyp(void);
 extern void    deftyp(void);
-extern int     length(type_t *, const char *);
-extern int     getbound(type_t *);
+extern int     length(const type_t *, const char *);
+extern int     getbound(const type_t *);
 extern sym_t   *lnklst(sym_t *, sym_t *);
 extern void    check_type(sym_t *);
 extern sym_t   *declarator_1_struct_union(sym_t *);
@@ -175,7 +175,7 @@
 extern void    copy_usage_info(sym_t *, sym_t *);
 extern int     check_redeclaration(sym_t *, int *);
 extern bool    eqptrtype(const type_t *, const type_t *, int);
-extern int     eqtype(type_t *, type_t *, int, int, int *);
+extern int     eqtype(const type_t *, const type_t *, int, int, int *);
 extern void    complete_type(sym_t *, sym_t *);
 extern sym_t   *declare_argument(sym_t *, int);
 extern void    check_func_lint_directives(void);
@@ -191,7 +191,7 @@
 extern void    check_usage(dinfo_t *);
 extern void    check_usage_sym(int, sym_t *);
 extern void    check_global_symbols(void);
-extern void    print_previous_declaration(int, sym_t *);
+extern void    print_previous_declaration(int, const sym_t *);
 
 /*
  * tree.c
@@ -204,7 +204,7 @@
 extern sym_t   *struct_or_union_member(tnode_t *, op_t, sym_t *);
 extern tnode_t *build(op_t, tnode_t *, tnode_t *);
 extern tnode_t *cconv(tnode_t *);
-extern bool    typeok(op_t, int, tnode_t *, tnode_t *);
+extern bool    typeok(op_t, int, const tnode_t *, const tnode_t *);
 extern tnode_t *promote(op_t, int, tnode_t *);
 extern tnode_t *convert(op_t, int, type_t *, tnode_t *);
 extern void    convert_constant(op_t, int, type_t *, val_t *, val_t *);
@@ -216,7 +216,7 @@
 extern tnode_t *new_function_call_node(tnode_t *, tnode_t *);
 extern val_t   *constant(tnode_t *, int);
 extern void    expr(tnode_t *, int, int, int);
-extern void    check_expr_misc(tnode_t *, int, int, int, int, int, int);
+extern void    check_expr_misc(const tnode_t *, int, int, int, int, int, int);
 extern int     conaddr(tnode_t *, sym_t **, ptrdiff_t *);
 extern strg_t  *cat_strings(strg_t *, strg_t *);
 extern  int64_t tsize(type_t *);
@@ -296,12 +296,12 @@
 /*
  * emit.c
  */
-extern void    outtype(type_t *);
-extern const   char *ttos(type_t *);
-extern void    outsym(sym_t *, scl_t, def_t);
-extern void    outfdef(sym_t *, pos_t *, int, int, sym_t *);
-extern void    outcall(tnode_t *, int, int);
-extern void    outusg(sym_t *);
+extern void    outtype(const type_t *);
+extern const   char *ttos(const type_t *);
+extern void    outsym(const sym_t *, scl_t, def_t);
+extern void    outfdef(const sym_t *, const pos_t *, int, int, const sym_t *);
+extern void    outcall(const tnode_t *, int, int);
+extern void    outusg(const sym_t *);
 
 /*
  * print.c
diff -r 20ef3e5ccf71 -r 94a2d7b4bba0 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Mon Jan 11 17:18:51 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Mon Jan 11 19:29:49 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.148 2021/01/10 12:46:38 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.149 2021/01/11 19:29:49 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.148 2021/01/10 12:46:38 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.149 2021/01/11 19:29:49 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -51,17 +51,23 @@
 #include "cgram.h"
 
 static tnode_t *new_integer_constant_node(tspec_t, int64_t);
-static void    check_pointer_comparison(op_t, tnode_t *, tnode_t *);
-static int     check_assign_types_compatible(op_t, int, tnode_t *, tnode_t *);
-static void    check_bad_enum_operation(op_t, tnode_t *, tnode_t *);
-static void    check_enum_type_mismatch(op_t, int, tnode_t *, tnode_t *);
-static void    check_enum_int_mismatch(op_t, int, tnode_t *, tnode_t *);
+static void    check_pointer_comparison(op_t,
+                                        const tnode_t *, const tnode_t *);
+static int     check_assign_types_compatible(op_t, int,
+                                             const tnode_t *, const tnode_t *);
+static void    check_bad_enum_operation(op_t,
+                                        const tnode_t *, const tnode_t *);
+static void    check_enum_type_mismatch(op_t, int,
+                                        const tnode_t *, const tnode_t *);
+static void    check_enum_int_mismatch(op_t, int,
+                                       const tnode_t *, const tnode_t *);
 static tnode_t *new_tnode(op_t, type_t *, tnode_t *, tnode_t *);
 static void    balance(op_t, tnode_t **, tnode_t **);
 static void    warn_incompatible_types(op_t, tspec_t, tspec_t);
-static void    warn_incompatible_pointers(mod_t *, type_t *, type_t *);
+static void    warn_incompatible_pointers(const mod_t *,
+                                          const type_t *, const type_t *);
 static void    merge_qualifiers(type_t **, type_t *, type_t *);
-static int     has_constant_member(type_t *);



Home | Main Index | Thread Index | Old Index