Source-Changes-HG archive

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

[src/trunk]: src/sys use Elf_Sym ** instead of casting.



details:   https://anonhg.NetBSD.org/src/rev/a9051301dced
branches:  trunk
changeset: 357304:a9051301dced
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Nov 04 22:17:55 2017 +0000

description:
use Elf_Sym ** instead of casting.

diffstat:

 sys/ddb/db_elf.c      |   7 ++++---
 sys/kern/kern_ksyms.c |  11 +++++------
 sys/kern/subr_kobj.c  |   6 +++---
 sys/sys/ksyms.h       |  10 +++++++---
 4 files changed, 19 insertions(+), 15 deletions(-)

diffs (139 lines):

diff -r 15772079b96f -r a9051301dced sys/ddb/db_elf.c
--- a/sys/ddb/db_elf.c  Sat Nov 04 21:02:37 2017 +0000
+++ b/sys/ddb/db_elf.c  Sat Nov 04 22:17:55 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_elf.c,v 1.27 2009/03/14 15:36:16 dsl Exp $  */
+/*     $NetBSD: db_elf.c,v 1.28 2017/11/04 22:17:55 christos Exp $     */
 
 /*-
  * Copyright (c) 1997, 2009 The NetBSD Foundation, Inc.
@@ -31,14 +31,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_elf.c,v 1.27 2009/03/14 15:36:16 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_elf.c,v 1.28 2017/11/04 22:17:55 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/proc.h>
 
-#include <ddb/ddb.h>
 
+#include <machine/db_machdep.h>
 #include <machine/pmap.h>
 #include <machine/vmparam.h>
 
@@ -50,6 +50,7 @@
 
 #define        ELFSIZE         DB_ELFSIZE
 
+#include <ddb/ddb.h>
 #include <sys/exec_elf.h>
 
 static char    *db_elf_find_strtab(db_symtab_t *);
diff -r 15772079b96f -r a9051301dced sys/kern/kern_ksyms.c
--- a/sys/kern/kern_ksyms.c     Sat Nov 04 21:02:37 2017 +0000
+++ b/sys/kern/kern_ksyms.c     Sat Nov 04 22:17:55 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_ksyms.c,v 1.86 2017/11/03 09:59:07 maxv Exp $     */
+/*     $NetBSD: kern_ksyms.c,v 1.87 2017/11/04 22:17:55 christos Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.86 2017/11/03 09:59:07 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.87 2017/11/04 22:17:55 christos Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_copy_symtab.h"
@@ -566,7 +566,7 @@
  * Call with ksyms_lock, unless known that the symbol table can't change.
  */
 int
-ksyms_getval_unlocked(const char *mod, const char *sym, void **symp,
+ksyms_getval_unlocked(const char *mod, const char *sym, Elf_Sym **symp,
     unsigned long *val, int type)
 {
        struct ksyms_symtab *st;
@@ -574,8 +574,7 @@
 
 #ifdef KSYMS_DEBUG
        if (ksyms_debug & FOLLOW_CALLS)
-               printf("ksyms_getval_unlocked: mod %s sym %s valp %p\n",
-                   mod, sym, val);
+               printf("%s: mod %s sym %s valp %p\n", __func__, mod, sym, val);
 #endif
 
        TAILQ_FOREACH(st, &ksyms_symtabs, sd_queue) {
@@ -586,7 +585,7 @@
                if ((es = findsym(sym, st, type)) != NULL) {
                        *val = es->st_value;
                        if (symp)
-                               *symp = (void *)es;
+                               *symp = es;
                        return 0;
                }
        }
diff -r 15772079b96f -r a9051301dced sys/kern/subr_kobj.c
--- a/sys/kern/subr_kobj.c      Sat Nov 04 21:02:37 2017 +0000
+++ b/sys/kern/subr_kobj.c      Sat Nov 04 22:17:55 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_kobj.c,v 1.64 2017/11/04 12:14:41 martin Exp $    */
+/*     $NetBSD: subr_kobj.c,v 1.65 2017/11/04 22:17:55 christos Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.64 2017/11/04 12:14:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.65 2017/11/04 22:17:55 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_modular.h"
@@ -980,7 +980,7 @@
                 * module_lock).
                 */
                name = ko->ko_strtab + sym->st_name;
-               if (ksyms_getval_unlocked(NULL, name, (void **)&ksym, &rval,
+               if (ksyms_getval_unlocked(NULL, name, &ksym, &rval,
                    KSYMS_EXTERN) != 0) {
                        if (undefined) {
                                kobj_error(ko, "symbol `%s' not found",
diff -r 15772079b96f -r a9051301dced sys/sys/ksyms.h
--- a/sys/sys/ksyms.h   Sat Nov 04 21:02:37 2017 +0000
+++ b/sys/sys/ksyms.h   Sat Nov 04 22:17:55 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ksyms.h,v 1.34 2017/11/03 09:59:07 maxv Exp $  */
+/*     $NetBSD: ksyms.h,v 1.35 2017/11/04 22:17:55 christos Exp $      */
 
 /*
  * Copyright (c) 2001, 2003 Anders Magnusson (ragge%ludd.luth.se@localhost).
@@ -30,8 +30,12 @@
 #ifndef _SYS_KSYMS_H_
 #define _SYS_KSYMS_H_
 
+#ifndef ELFSIZE
+#define ELFSIZE ARCH_ELFSIZE
+#endif
+#include <sys/exec_elf.h>
+
 #ifdef _KSYMS_PRIVATE
-#include <sys/exec_elf.h>
 #include <sys/ioccom.h>
 #include <sys/queue.h>
 
@@ -131,7 +135,7 @@
 
 int ksyms_getname(const char **, const char **, vaddr_t, int);
 int ksyms_getval(const char *, const char *, unsigned long *, int);
-int ksyms_getval_unlocked(const char *, const char *, void **,
+int ksyms_getval_unlocked(const char *, const char *, Elf_Sym **,
     unsigned long *, int);
 struct ksyms_symtab *ksyms_get_mod(const char *);
 int ksyms_mod_foreach(const char *mod, ksyms_callback_t, void *);



Home | Main Index | Thread Index | Old Index