Commit-ID: 29b2ad1a15a909ae2dffd6f92b52a1b03cae9f51 Gitweb: http://git.kernel.org/tip/29b2ad1a15a909ae2dffd6f92b52a1b03cae9f51 Author: Cyrill Gorcunov <gorcunov@xxxxxxxxxx> AuthorDate: Wed, 1 Feb 2012 12:41:05 +0400 Committer: Pekka Enberg <penberg@xxxxxxxxxx> CommitDate: Wed, 1 Feb 2012 11:08:36 +0200 kvm tools: Cleanup BDF searching code - drop double underscopes in names - a variable which return integer error code should be either 'ret' either 'err' Signed-off-by: Cyrill Gorcunov <gorcunov@xxxxxxxxx> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx> --- tools/kvm/builtin-run.c | 8 ++++---- tools/kvm/include/kvm/symbol.h | 16 ++++++++++------ tools/kvm/symbol.c | 38 +++++++++++++++++++------------------- tools/kvm/x86/kvm-cpu.c | 4 ++-- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index 5517aca..71edf5f4 100644 --- a/tools/kvm/builtin-run.c +++ b/tools/kvm/builtin-run.c @@ -1111,9 +1111,9 @@ static int kvm_cmd_run_init(int argc, const char **argv) die("unable to load kernel %s", kernel_filename); kvm->vmlinux = vmlinux_filename; - r = symbol__init(kvm); + r = symbol_init(kvm); if (r < 0) - pr_err("symbol__init() failed with error %d\n", r); + pr_err("symbol_init() failed with error %d\n", r); ioport__setup_arch(); @@ -1268,9 +1268,9 @@ static void kvm_cmd_run_exit(int guest_ret) compat__print_all_messages(); - r = symbol__exit(kvm); + r = symbol_exit(kvm); if (r < 0) - pr_warning("symbol__exit() failed with error %d\n", r); + pr_warning("symbol_exit() failed with error %d\n", r); r = irq__exit(kvm); if (r < 0) diff --git a/tools/kvm/include/kvm/symbol.h b/tools/kvm/include/kvm/symbol.h index 9cc3f95..725bbaf 100644 --- a/tools/kvm/include/kvm/symbol.h +++ b/tools/kvm/include/kvm/symbol.h @@ -9,18 +9,22 @@ struct kvm; #define SYMBOL_DEFAULT_UNKNOWN "<unknown>" #ifdef CONFIG_HAS_BFD -int symbol__init(struct kvm *kvm); -int symbol__exit(struct kvm *kvm); -char *symbol__lookup(struct kvm *kvm, unsigned long addr, char *sym, size_t size); + +int symbol_init(struct kvm *kvm); +int symbol_exit(struct kvm *kvm); +char *symbol_lookup(struct kvm *kvm, unsigned long addr, char *sym, size_t size); + #else -static inline int symbol__init(struct kvm *kvm) { return 0; } -static inline char *symbol__lookup(struct kvm *kvm, unsigned long addr, char *sym, size_t size) + +static inline int symbol_init(struct kvm *kvm) { return 0; } +static inline char *symbol_lookup(struct kvm *kvm, unsigned long addr, char *sym, size_t size) { char *s = strncpy(sym, SYMBOL_DEFAULT_UNKNOWN, size); sym[size - 1] = '\0'; return s; } -static inline int symbol__exit(struct kvm *kvm) { return 0; } +static inline int symbol_exit(struct kvm *kvm) { return 0; } + #endif #endif /* KVM__SYMBOL_H */ diff --git a/tools/kvm/symbol.c b/tools/kvm/symbol.c index 00a6fe2..b76d98b 100644 --- a/tools/kvm/symbol.c +++ b/tools/kvm/symbol.c @@ -10,9 +10,9 @@ static bfd *abfd; -int symbol__init(struct kvm *kvm) +int symbol_init(struct kvm *kvm) { - int r = 0; + int ret = 0; if (!kvm->vmlinux) return -EINVAL; @@ -25,25 +25,25 @@ int symbol__init(struct kvm *kvm) switch (err) { case bfd_error_no_memory: - r = -ENOMEM; + ret = -ENOMEM; break; case bfd_error_invalid_target: - r = -EINVAL; + ret = -EINVAL; break; default: - r = -EFAULT; + ret = -EFAULT; break; } } - return r; + return ret; } static asymbol *lookup(asymbol **symbols, int nr_symbols, const char *symbol_name) { - int i, r; + int i, ret; - r = -ENOENT; + ret = -ENOENT; for (i = 0; i < nr_symbols; i++) { asymbol *symbol = symbols[i]; @@ -52,10 +52,10 @@ static asymbol *lookup(asymbol **symbols, int nr_symbols, const char *symbol_nam return symbol; } - return ERR_PTR(r); + return ERR_PTR(ret); } -char *symbol__lookup(struct kvm *kvm, unsigned long addr, char *sym, size_t size) +char *symbol_lookup(struct kvm *kvm, unsigned long addr, char *sym, size_t size) { const char *filename; bfd_vma sym_offset; @@ -66,9 +66,9 @@ char *symbol__lookup(struct kvm *kvm, unsigned long addr, char *sym, size_t size long symtab_size; asymbol *symbol; asymbol **syms; - int nr_syms, r; + int nr_syms, ret; - r = -ENOENT; + ret = -ENOENT; if (!abfd) goto not_found; @@ -79,14 +79,14 @@ char *symbol__lookup(struct kvm *kvm, unsigned long addr, char *sym, size_t size if (!symtab_size) goto not_found; - r = -ENOMEM; + ret = -ENOMEM; syms = malloc(symtab_size); if (!syms) goto not_found; nr_syms = bfd_canonicalize_symtab(abfd, syms); - r = -ENOENT; + ret = -ENOENT; section = bfd_get_section_by_name(abfd, ".debug_aranges"); if (!section) goto not_found; @@ -114,17 +114,17 @@ char *symbol__lookup(struct kvm *kvm, unsigned long addr, char *sym, size_t size return sym; not_found: - return ERR_PTR(r); + return ERR_PTR(ret); } -int symbol__exit(struct kvm *kvm) +int symbol_exit(struct kvm *kvm) { - bfd_boolean r = TRUE; + bfd_boolean ret = TRUE; if (abfd) - r = bfd_close(abfd); + ret = bfd_close(abfd); - if (r == TRUE) + if (ret == TRUE) return 0; return -EFAULT; diff --git a/tools/kvm/x86/kvm-cpu.c b/tools/kvm/x86/kvm-cpu.c index 4aa1b9a..2b3d973 100644 --- a/tools/kvm/x86/kvm-cpu.c +++ b/tools/kvm/x86/kvm-cpu.c @@ -340,10 +340,10 @@ void kvm_cpu__show_code(struct kvm_cpu *vcpu) dprintf(debug_fd, "\n Code:\n"); dprintf(debug_fd, " -----\n"); - psym = symbol__lookup(vcpu->kvm, vcpu->regs.rip, sym, MAX_SYM_LEN); + psym = symbol_lookup(vcpu->kvm, vcpu->regs.rip, sym, MAX_SYM_LEN); if (IS_ERR(psym)) dprintf(debug_fd, - "Warning: symbol__lookup() failed to find symbol " + "Warning: symbol_lookup() failed to find symbol " "with error: %ld\n", PTR_ERR(psym)); dprintf(debug_fd, " rip: [<%016lx>] %s\n\n", (unsigned long) vcpu->regs.rip, sym); -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html