Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys make couple ksym functions' arguments const



details:   https://anonhg.NetBSD.org/src/rev/90168bdb0199
branches:  trunk
changeset: 547007:90168bdb0199
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun May 11 08:23:22 2003 +0000

description:
make couple ksym functions' arguments const

diffstat:

 sys/ddb/db_sym.c      |  15 +++++++++------
 sys/kern/kern_ksyms.c |  27 +++++++++++++++------------
 sys/sys/ksyms.h       |  10 +++++-----
 3 files changed, 29 insertions(+), 23 deletions(-)

diffs (181 lines):

diff -r 33a9cc75463b -r 90168bdb0199 sys/ddb/db_sym.c
--- a/sys/ddb/db_sym.c  Sun May 11 08:06:01 2003 +0000
+++ b/sys/ddb/db_sym.c  Sun May 11 08:23:22 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_sym.c,v 1.38 2003/04/28 15:55:45 ragge Exp $        */
+/*     $NetBSD: db_sym.c,v 1.39 2003/05/11 08:23:23 jdolecek Exp $     */
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_sym.c,v 1.38 2003/04/28 15:55:45 ragge Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_sym.c,v 1.39 2003/05/11 08:23:23 jdolecek Exp $");
 
 #include "opt_ddbparam.h"
 
@@ -199,7 +199,8 @@
        unsigned int diff;
        db_sym_t ret = DB_SYM_NULL;
        db_addr_t naddr;
-       char *mod, *sym;
+       const char *mod;
+       char *sym;
 
 #ifdef DB_AOUT_SYMBOLS
        db_expr_t newdiff;
@@ -233,7 +234,7 @@
 void
 db_symbol_values(db_sym_t sym, char **namep, db_expr_t *valuep)
 {
-       char *mod;
+       const char *mod;
 
        if (sym == DB_SYM_NULL) {
                *namep = 0;
@@ -283,7 +284,8 @@
 void
 db_symstr(char *buf, db_expr_t off, db_strategy_t strategy)
 {
-       char  *name, *mod;
+       char  *name;
+       const char *mod;
        long val;
 
 #ifdef DB_AOUT_SYMBOLS
@@ -347,7 +349,8 @@
 db_printsym(db_expr_t off, db_strategy_t strategy,
     void (*pr)(const char *, ...))
 {
-       char  *name, *mod;
+       char  *name;
+       const char *mod;
        long val;
 #ifdef notyet
        char *filename;
diff -r 33a9cc75463b -r 90168bdb0199 sys/kern/kern_ksyms.c
--- a/sys/kern/kern_ksyms.c     Sun May 11 08:06:01 2003 +0000
+++ b/sys/kern/kern_ksyms.c     Sun May 11 08:23:22 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_ksyms.c,v 1.8 2003/05/07 21:28:16 ragge Exp $     */
+/*     $NetBSD: kern_ksyms.c,v 1.9 2003/05/11 08:23:23 jdolecek Exp $  */
 /*
  * Copyright (c) 2001, 2003 Anders Magnusson (ragge%ludd.luth.se@localhost).
  * All rights reserved.
@@ -115,7 +115,7 @@
  */
 struct symtab {
        CIRCLEQ_ENTRY(symtab) sd_queue;
-       char *sd_name;          /* Name of this table */
+       const char *sd_name;    /* Name of this table */
        Elf_Sym *sd_symstart;   /* Address of symbol table */
        caddr_t sd_strstart;    /* Adderss of corresponding string table */
        int sd_symsize;         /* Size in bytes of symbol table */
@@ -300,7 +300,7 @@
  * This is intended for use when the kernel loader enters the table.
  */
 static void
-addsymtab(char *name, Elf_Ehdr *ehdr, struct symtab *tab)
+addsymtab(const char *name, Elf_Ehdr *ehdr, struct symtab *tab)
 {
        caddr_t start = (caddr_t)ehdr;
        caddr_t send;
@@ -487,7 +487,7 @@
  * Returns 0 if success or ENOENT if no such entry.
  */
 int
-ksyms_getval(char *mod, char *sym, unsigned long *val, int type)
+ksyms_getval(const char *mod, char *sym, unsigned long *val, int type)
 {
        struct symtab *st;
        Elf_Sym *es;
@@ -523,12 +523,13 @@
  * Returns 0 if success or ENOENT if no such entry.
  */
 int
-ksyms_getname(char **mod, char **sym, vaddr_t v, int f)
+ksyms_getname(const char **mod, char **sym, vaddr_t v, int f)
 {
        struct symtab *st;
        Elf_Sym *les, *es = NULL;
        vaddr_t laddr = 0;
-       char *lmod, *stable;
+       const char *lmod;
+       char *stable;
        int type, i, sz;
 
        if (ksymsinited == 0)
@@ -638,14 +639,14 @@
  * Returns 0 if success and EEXIST if the module name is in use.
  */
 int
-ksyms_addsymtab(char *mod, void *symstart, vsize_t symsize,
+ksyms_addsymtab(const char *mod, void *symstart, vsize_t symsize,
     char *strstart, vsize_t strsize)
 {
        Elf_Sym *sym = symstart;
        struct symtab *st;
        long rval;
        int i;
-       char *str;
+       char *str, *name;
 
 #ifdef KSYMS_DEBUG
        if (ksyms_debug & FOLLOW_CALLS)
@@ -704,8 +705,9 @@
        memcpy(str, symnames, curnamep);
 
        st = malloc(sizeof(struct symtab), M_DEVBUF, M_WAITOK);
-       st->sd_name = malloc(strlen(mod)+1, M_DEVBUF, M_WAITOK);
-       strcpy(st->sd_name, mod);
+       name = malloc(strlen(mod)+1, M_DEVBUF, M_WAITOK);
+       strcpy(name, mod);
+       st->sd_name = name;
        st->sd_symnmoff = malloc(sizeof(int)*cursyms, M_DEVBUF, M_WAITOK);
        memcpy(st->sd_symnmoff, symnmoff, sizeof(int)*cursyms);
        st->sd_symstart = sym;
@@ -730,7 +732,7 @@
  * Returns 0 if success, EBUSY if device open and ENOENT if no such name.
  */
 int
-ksyms_delsymtab(char *mod)
+ksyms_delsymtab(const char *mod)
 {
        struct symtab *st;
        int found = 0;
@@ -756,7 +758,8 @@
        free(st->sd_symstart, M_DEVBUF);
        free(st->sd_strstart, M_DEVBUF);
        free(st->sd_symnmoff, M_DEVBUF);
-       free(st->sd_name, M_DEVBUF);
+       /* LINTED - const castaway */
+       free((void *)st->sd_name, M_DEVBUF);
        free(st, M_DEVBUF);
 #if NKSYMS
        ksyms_sizes_calc();
diff -r 33a9cc75463b -r 90168bdb0199 sys/sys/ksyms.h
--- a/sys/sys/ksyms.h   Sun May 11 08:06:01 2003 +0000
+++ b/sys/sys/ksyms.h   Sun May 11 08:23:22 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ksyms.h,v 1.4 2003/05/01 20:46:20 ragge Exp $  */
+/*     $NetBSD: ksyms.h,v 1.5 2003/05/11 08:23:22 jdolecek Exp $       */
 /*
  * Copyright (c) 2001, 2003 Anders Magnusson (ragge%ludd.luth.se@localhost).
  * All rights reserved.
@@ -59,10 +59,10 @@
 /*
  * Prototypes
  */
-int ksyms_getname(char **, char **, vaddr_t, int);
-int ksyms_getval(char *, char *, unsigned long *, int);
-int ksyms_addsymtab(char *, void *, vsize_t, char *, vsize_t);
-int ksyms_delsymtab(char *);
+int ksyms_getname(const char **, char **, vaddr_t, int);
+int ksyms_getval(const char *, char *, unsigned long *, int);
+int ksyms_addsymtab(const char *, void *, vsize_t, char *, vsize_t);
+int ksyms_delsymtab(const char *);
 void ksyms_init(int, void *, void *);
 #ifdef DDB
 int ksyms_sift(char *mod, char *sym, int mode);



Home | Main Index | Thread Index | Old Index