Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Use a macro instead of always putting __func__ and ...
details: https://anonhg.NetBSD.org/src/rev/de9ae5aa61d2
branches: trunk
changeset: 330363:de9ae5aa61d2
user: maxv <maxv%NetBSD.org@localhost>
date: Sun Jul 06 15:22:31 2014 +0000
description:
Use a macro instead of always putting __func__ and __LINE__.
diffstat:
sys/kern/subr_kobj.c | 113 ++++++++++++++++++++++++--------------------------
1 files changed, 54 insertions(+), 59 deletions(-)
diffs (truncated from 375 to 300 lines):
diff -r 094a459b1fb1 -r de9ae5aa61d2 sys/kern/subr_kobj.c
--- a/sys/kern/subr_kobj.c Sun Jul 06 15:09:38 2014 +0000
+++ b/sys/kern/subr_kobj.c Sun Jul 06 15:22:31 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_kobj.c,v 1.46 2013/08/09 05:10:14 matt Exp $ */
+/* $NetBSD: subr_kobj.c,v 1.47 2014/07/06 15:22:31 maxv 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.46 2013/08/09 05:10:14 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.47 2014/07/06 15:22:31 maxv Exp $");
#include "opt_modular.h"
@@ -80,9 +80,12 @@
#include <uvm/uvm_extern.h>
+#define kobj_error(_kobj, ...) \
+ kobj_out(__func__, __LINE__, _kobj, __VA_ARGS__)
+
static int kobj_relocate(kobj_t, bool);
static int kobj_checksyms(kobj_t, bool);
-static void kobj_error(const char *, int, kobj_t, const char *, ...)
+static void kobj_out(const char *, int, kobj_t, const char *, ...)
__printflike(4, 5);
static void kobj_jettison(kobj_t);
static void kobj_free(kobj_t, void *, size_t);
@@ -179,25 +182,24 @@
*/
error = ko->ko_read(ko, (void **)&hdr, sizeof(*hdr), 0, true);
if (error != 0) {
- kobj_error(__func__, __LINE__, ko, "read failed %d", error);
+ kobj_error(ko, "read failed %d", error);
goto out;
}
if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) != 0) {
- kobj_error(__func__, __LINE__, ko, "not an ELF object");
+ kobj_error(ko, "not an ELF object");
error = ENOEXEC;
goto out;
}
if (hdr->e_ident[EI_VERSION] != EV_CURRENT ||
hdr->e_version != EV_CURRENT) {
- kobj_error(__func__, __LINE__, ko,
- "unsupported file version %d", hdr->e_ident[EI_VERSION]);
+ kobj_error(ko, "unsupported file version %d",
+ hdr->e_ident[EI_VERSION]);
error = ENOEXEC;
goto out;
}
if (hdr->e_type != ET_REL) {
- kobj_error(__func__, __LINE__, ko, "unsupported file type %d",
- hdr->e_type);
+ kobj_error(ko, "unsupported file type %d", hdr->e_type);
error = ENOEXEC;
goto out;
}
@@ -210,8 +212,7 @@
#error not defined
#endif
default:
- kobj_error(__func__, __LINE__, ko, "unsupported machine %d",
- hdr->e_machine);
+ kobj_error(ko, "unsupported machine %d", hdr->e_machine);
error = ENOEXEC;
goto out;
}
@@ -227,14 +228,14 @@
ko->ko_shdrsz = hdr->e_shnum * hdr->e_shentsize;
if (ko->ko_shdrsz == 0 || hdr->e_shoff == 0 ||
hdr->e_shentsize != sizeof(Elf_Shdr)) {
- kobj_error(__func__, __LINE__, ko, "bad sizes");
+ kobj_error(ko, "bad sizes");
error = ENOEXEC;
goto out;
}
error = ko->ko_read(ko, (void **)&shdr, ko->ko_shdrsz, hdr->e_shoff,
true);
if (error != 0) {
- kobj_error(__func__, __LINE__, ko, "read failed %d", error);
+ kobj_error(ko, "read failed %d", error);
goto out;
}
ko->ko_shdr = shdr;
@@ -271,21 +272,19 @@
}
}
if (ko->ko_nprogtab == 0) {
- kobj_error(__func__, __LINE__, ko, "file has no contents");
+ kobj_error(ko, "file has no contents");
error = ENOEXEC;
goto out;
}
if (nsym != 1) {
/* Only allow one symbol table for now */
- kobj_error(__func__, __LINE__, ko,
- "file has no valid symbol table");
+ kobj_error(ko, "file has no valid symbol table");
error = ENOEXEC;
goto out;
}
if (symstrindex < 0 || symstrindex > hdr->e_shnum ||
shdr[symstrindex].sh_type != SHT_STRTAB) {
- kobj_error(__func__, __LINE__, ko,
- "file has invalid symbol strings");
+ kobj_error(ko, "file has invalid symbol strings");
error = ENOEXEC;
goto out;
}
@@ -298,7 +297,7 @@
sizeof(*ko->ko_progtab), KM_SLEEP);
if (ko->ko_progtab == NULL) {
error = ENOMEM;
- kobj_error(__func__, __LINE__, ko, "out of memory");
+ kobj_error(ko, "out of memory");
goto out;
}
}
@@ -307,7 +306,7 @@
sizeof(*ko->ko_reltab), KM_SLEEP);
if (ko->ko_reltab == NULL) {
error = ENOMEM;
- kobj_error(__func__, __LINE__, ko, "out of memory");
+ kobj_error(ko, "out of memory");
goto out;
}
}
@@ -316,12 +315,12 @@
sizeof(*ko->ko_relatab), KM_SLEEP);
if (ko->ko_relatab == NULL) {
error = ENOMEM;
- kobj_error(__func__, __LINE__, ko, "out of memory");
+ kobj_error(ko, "out of memory");
goto out;
}
}
if (symtabindex == -1) {
- kobj_error(__func__, __LINE__, ko, "lost symbol table index");
+ kobj_error(ko, "lost symbol table index");
goto out;
}
@@ -330,14 +329,14 @@
*/
ko->ko_symcnt = shdr[symtabindex].sh_size / sizeof(Elf_Sym);
if (ko->ko_symcnt == 0) {
- kobj_error(__func__, __LINE__, ko, "no symbol table");
+ kobj_error(ko, "no symbol table");
goto out;
}
error = ko->ko_read(ko, (void **)&ko->ko_symtab,
ko->ko_symcnt * sizeof(Elf_Sym),
shdr[symtabindex].sh_offset, true);
if (error != 0) {
- kobj_error(__func__, __LINE__, ko, "read failed %d", error);
+ kobj_error(ko, "read failed %d", error);
goto out;
}
@@ -346,13 +345,13 @@
*/
ko->ko_strtabsz = shdr[symstrindex].sh_size;
if (ko->ko_strtabsz == 0) {
- kobj_error(__func__, __LINE__, ko, "no symbol strings");
+ kobj_error(ko, "no symbol strings");
goto out;
}
error = ko->ko_read(ko, (void *)&ko->ko_strtab, ko->ko_strtabsz,
shdr[symstrindex].sh_offset, true);
if (error != 0) {
- kobj_error(__func__, __LINE__, ko, "read failed %d", error);
+ kobj_error(ko, "read failed %d", error);
goto out;
}
@@ -362,7 +361,7 @@
error = kobj_renamespace(ko->ko_symtab, ko->ko_symcnt,
&ko->ko_strtab, &ko->ko_strtabsz);
if (error != 0) {
- kobj_error(__func__, __LINE__, ko, "renamespace failed %d",
+ kobj_error(ko, "renamespace failed %d",
error);
goto out;
}
@@ -377,8 +376,7 @@
shdr[hdr->e_shstrndx].sh_size,
shdr[hdr->e_shstrndx].sh_offset, true);
if (error != 0) {
- kobj_error(__func__, __LINE__, ko, "read failed %d",
- error);
+ kobj_error(ko, "read failed %d", error);
goto out;
}
}
@@ -408,7 +406,7 @@
* can get the bounds and gdb can associate offsets with modules.
*/
if (mapsize == 0) {
- kobj_error(__func__, __LINE__, ko, "no text/data/bss");
+ kobj_error(ko, "no text/data/bss");
goto out;
}
if (ko->ko_type == KT_MEMORY) {
@@ -417,7 +415,7 @@
mapbase = uvm_km_alloc(module_map, round_page(mapsize),
0, UVM_KMF_WIRED | UVM_KMF_EXEC);
if (mapbase == 0) {
- kobj_error(__func__, __LINE__, ko, "out of memory");
+ kobj_error(ko, "out of memory");
error = ENOMEM;
goto out;
}
@@ -442,9 +440,8 @@
addr = (void *)(shdr[i].sh_offset +
(vaddr_t)ko->ko_source);
if (((vaddr_t)addr & alignmask) != 0) {
- kobj_error(__func__, __LINE__, ko,
- "section %d not aligned",
- i);
+ kobj_error(ko,
+ "section %d not aligned", i);
goto out;
}
} else {
@@ -459,14 +456,13 @@
error = ko->ko_read(ko, &addr,
shdr[i].sh_size, shdr[i].sh_offset, false);
if (error != 0) {
- kobj_error(__func__, __LINE__, ko,
- "read failed %d", error);
+ kobj_error(ko, "read failed %d",
+ error);
goto out;
}
} else if (ko->ko_type == KT_MEMORY &&
shdr[i].sh_size != 0) {
- kobj_error(__func__, __LINE__, ko,
- "non-loadable BSS "
+ kobj_error(ko, "non-loadable BSS "
"section in pre-loaded module");
error = EINVAL;
goto out;
@@ -506,8 +502,8 @@
ko->ko_reltab[rl].size,
shdr[i].sh_offset, true);
if (error != 0) {
- kobj_error(__func__, __LINE__, ko,
- "read failed %d", error);
+ kobj_error(ko, "read failed %d",
+ error);
goto out;
}
}
@@ -528,8 +524,8 @@
shdr[i].sh_size,
shdr[i].sh_offset, true);
if (error != 0) {
- kobj_error(__func__, __LINE__, ko,
- "read failed %d", error);
+ kobj_error(ko, "read failed %d",
+ error);
goto out;
}
}
@@ -599,8 +595,8 @@
error = kobj_machdep(ko, (void *)ko->ko_address, ko->ko_size,
false);
if (error != 0)
- kobj_error(__func__, __LINE__, ko,
- "machine dependent deinit failed %d", error);
+ kobj_error(ko, "machine dependent deinit failed %d",
+ error);
}
if (ko->ko_address != 0 && ko->ko_type != KT_MEMORY) {
uvm_km_free(module_map, ko->ko_address, round_page(ko->ko_size),
@@ -692,8 +688,8 @@
error = kobj_machdep(ko, (void *)ko->ko_address, ko->ko_size,
true);
if (error != 0)
- kobj_error(__func__, __LINE__, ko,
- "machine dependent init failed %d", error);
+ kobj_error(ko, "machine dependent init failed %d",
+ error);
ko->ko_loaded = true;
}
@@ -800,7 +796,7 @@
switch (ELF_ST_BIND(sym->st_info)) {
case STB_LOCAL:
/* Local, but undefined? huh? */
- kobj_error(__func__, __LINE__, ko, "local symbol undefined");
+ kobj_error(ko, "local symbol undefined");
return 0;
Home |
Main Index |
Thread Index |
Old Index