From a00ef142f8d2ada11ab22a903545845e2cadc858 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Fri, 30 Sep 2011 14:37:12 +0400 Subject: [PATCH] Use pr_err for error printing To follow kernel style Signed-off-by: Cyrill Gorcunov --- cr-dump.c | 44 ++++++++++++++++++++++---------------------- cr-restore.c | 26 +++++++++++++------------- cr-show.c | 4 ++-- crtools.c | 4 ++-- elf.c | 8 ++++---- include/util.h | 20 ++++++++++---------- parasite-syscall.c | 20 ++++++++++---------- util.c | 16 ++++++++-------- 8 files changed, 71 insertions(+), 71 deletions(-) diff --git a/cr-dump.c b/cr-dump.c index 57036d105..59fcf1fd1 100644 --- a/cr-dump.c +++ b/cr-dump.c @@ -91,9 +91,9 @@ err: return ret; err_bogus_mapping: - pr_error("Bogus mapping %lx-%lx\n", - vma_area->vma.start, - vma_area->vma.end); + pr_err("Bogus mapping %lx-%lx\n", + vma_area->vma.start, + vma_area->vma.end); goto err; } @@ -156,7 +156,7 @@ static int dump_pipe_and_data(int lfd, struct pipe_entry *e, pipe_size = fcntl(lfd, F_GETPIPE_SZ); if (pipe_size < 0) { - pr_error("Can't obtain piped data size\n"); + pr_err("Can't obtain piped data size\n"); goto err; } @@ -215,7 +215,7 @@ err: pr_info("Dumped pipe: fd: %8lx pipeid: %8lx flags: %8lx bytes: %8lx\n", e.fd, e.pipeid, e.flags, e.bytes); else - pr_error("Dumping pipe %d/%x flags %x\n", fd, id, flags); + pr_err("Dumping pipe %d/%x flags %x\n", fd, id, flags); return ret; } @@ -273,7 +273,7 @@ static int dump_one_fd(char *pid_fd_dir, int dir, char *fd_name, unsigned long p return 0; } - pr_error("Can't dump file %s of that type [%x]\n", fd_name, st_buf.st_mode); + pr_err("Can't dump file %s of that type [%x]\n", fd_name, st_buf.st_mode); return 1; } @@ -436,7 +436,7 @@ static int dump_task_tls(pid_t pid, struct desc_struct *tls_array, int size) int ret = -1; if (size != GDT_ENTRY_TLS_ENTRIES) { - pr_error("Wrong TLS storage size: %d\n", size); + pr_err("Wrong TLS storage size: %d\n", size); goto err; } @@ -451,12 +451,12 @@ static int dump_task_tls(pid_t pid, struct desc_struct *tls_array, int size) while (fgets(loc_buf, sizeof(loc_buf), file)) { u32 a, b; if (sscanf(loc_buf, "%x %x", &a, &b) != 2) { - pr_error("Can't parse tls entry: %s\n"); + pr_err("Can't parse tls entry: %s\n"); ret = -1; goto err; } if (ret >= GDT_ENTRY_TLS_ENTRIES) { - pr_error("Too many entries in tls\n"); + pr_err("Too many entries in tls\n"); ret = -1; goto err; } @@ -467,7 +467,7 @@ static int dump_task_tls(pid_t pid, struct desc_struct *tls_array, int size) } if (ret != GDT_ENTRY_TLS_ENTRIES) { - pr_error("tls returened %i entries instead of %i\n", + pr_err("tls returened %i entries instead of %i\n", ret, GDT_ENTRY_TLS_ENTRIES); ret = -1; goto err; @@ -606,7 +606,7 @@ static struct pstree_item *find_children(pid_t pid) fclose(file), file = NULL; if (!found) { - pr_error("Children marker is not found\n"); + pr_err("Children marker is not found\n"); goto err; } @@ -842,63 +842,63 @@ static int dump_one_task(pid_t pid, struct cr_fdset *cr_fdset) ret = collect_mappings(pid); if (ret) { - pr_error("Collect mappings (pid: %d) failed with %d\n", pid, ret); + pr_err("Collect mappings (pid: %d) failed with %d\n", pid, ret); goto err; } ret = seize_task(pid); if (ret) { - pr_error("Failed to seize task (pid: %d) with %d\n", - pid, ret); + pr_err("Failed to seize task (pid: %d) with %d\n", + pid, ret); goto err; } ret = dump_task_core_seized(pid, cr_fdset); if (ret) { - pr_error("Dump core (pid: %d) failed with %d\n", pid, ret); + pr_err("Dump core (pid: %d) failed with %d\n", pid, ret); goto err; } parasite_ctl = parasite_infect_seized(pid, NULL, &vma_area_list); if (!parasite_ctl) { - pr_error("Can't infect (pid: %d) with parasite\n", pid); + pr_err("Can't infect (pid: %d) with parasite\n", pid); goto err; } ret = parasite_dump_pages_seized(parasite_ctl, &vma_area_list, cr_fdset, CR_FD_PAGES); if (ret) { - pr_error("Can't dump pages (pid: %d) with parasite\n", pid); + pr_err("Can't dump pages (pid: %d) with parasite\n", pid); goto err; } ret = parasite_cure_seized(¶site_ctl, &vma_area_list); if (ret) { - pr_error("Can't cure (pid: %d) from parasite\n", pid); + pr_err("Can't cure (pid: %d) from parasite\n", pid); goto err; } ret = unseize_task(pid); if (ret) { - pr_error("Can't unsieze (pid: %d) task\n", pid); + pr_err("Can't unsieze (pid: %d) task\n", pid); goto err; } ret = dump_task_files(pid, cr_fdset); if (ret) { - pr_error("Dump files (pid: %d) failed with %d\n", pid, ret); + pr_err("Dump files (pid: %d) failed with %d\n", pid, ret); goto err; } ret = dump_task_mappings(pid, cr_fdset); if (ret) { - pr_error("Dump mappings (pid: %d) failed with %d\n", pid, ret); + pr_err("Dump mappings (pid: %d) failed with %d\n", pid, ret); goto err; } ret = finalize_core(pid, cr_fdset); if (ret) { - pr_error("Finalizing core (pid: %d) failed with %d\n", pid, ret); + pr_err("Finalizing core (pid: %d) failed with %d\n", pid, ret); goto err; } diff --git a/cr-restore.c b/cr-restore.c index 4ccd4d5ec..06cb49585 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -184,7 +184,7 @@ static int collect_shmem(int pid, struct shmem_entry *e) continue; if (shmems[i].end != e->end) { - pr_error("Bogus shmem\n"); + pr_err("Bogus shmem\n"); return 1; } @@ -270,8 +270,8 @@ static int collect_pipe(int pid, struct pipe_entry *e, int p_fd) pipes[nr_pipes].status = PIPE_WRONLY; break; default: - pr_error("%d: Unknown pipe status pipeid %d\n", - pid, e->pipeid); + pr_err("%d: Unknown pipe status pipeid %d\n", + pid, e->pipeid); break; } @@ -437,7 +437,7 @@ static int open_fe_fd(struct fdinfo_entry *fe, int fd) int tmp; if (read(fd, path, fe->len) != fe->len) { - pr_error("Error reading path"); + pr_err("Error reading path"); return -1; } @@ -518,7 +518,7 @@ static int prepare_fds(int pid) read(fdinfo_fd, &mag, 4); if (mag != FDINFO_MAGIC) { - pr_error("Bad file magic number in %s\n", path); + pr_err("Bad file magic number in %s\n", path); return 1; } @@ -538,7 +538,7 @@ static int prepare_fds(int pid) } if (ret != sizeof(fe)) { - pr_error("Corrupted file %s\n", path); + pr_err("Corrupted file %s\n", path); return 1; } @@ -554,7 +554,7 @@ static int prepare_fds(int pid) return 1; break; default: - pr_error("Unknown type in %s\n", path); + pr_err("Unknown type in %s\n", path); return 1; } } @@ -657,7 +657,7 @@ static int try_fixup_shared_map(int pid, struct vma_entry *vi, int fd) pr_info("%d: Search for %016lx shmem %p/%d\n", pid, vi->start, si, si ? si->pid : -1); if (!si) { - pr_error("Can't find my shmem %016lx\n", vi->start); + pr_err("Can't find my shmem %016lx\n", vi->start); return 1; } @@ -755,7 +755,7 @@ static int fixup_pages_data(int pid, int fd) read(shfd, &magic, sizeof(magic)); if (magic != PAGES_MAGIC) { - pr_error("Bad shmem file magic number %s\n", path); + pr_err("Bad shmem file magic number %s\n", path); return 1; } @@ -905,8 +905,8 @@ static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int tmp = splice(pipes_fd, NULL, pfd[1], NULL, e->bytes, 0); if (tmp != e->bytes) { - pr_error("Wanted to restore %d bytes, but got %d\n", - e->bytes, tmp); + pr_err("Wanted to restore %d bytes, but got %d\n", + e->bytes, tmp); if (tmp < 0) perror("Error splicing data"); return 1; @@ -1014,7 +1014,7 @@ static int open_pipe(int pid, struct pipe_entry *e, int *pipes_fd) pi = find_pipe(e->pipeid); if (!pi) { - pr_error("BUG: can't find my pipe %x\n", e->pipeid); + pr_err("BUG: can't find my pipe %x\n", e->pipeid); return 1; } @@ -1132,7 +1132,7 @@ static int restore_task_with_children(int my_pid, char *pstree_path) while (1) { ret = read(fd, &e, sizeof(e)); if (ret != sizeof(e)) { - pr_error("%d: Read returned %d\n", my_pid, ret); + pr_err("%d: Read returned %d\n", my_pid, ret); if (ret < 0) perror("Can't read pstree"); exit(1); diff --git a/cr-show.c b/cr-show.c index dd3128f1d..cfa0d9f74 100644 --- a/cr-show.c +++ b/cr-show.c @@ -318,13 +318,13 @@ static int collect_pstree(pid_t pid, struct cr_fdset *cr_fdset) item->children = xmalloc(size); if (!item->children) { - pr_error("No memory for children pids\n"); + pr_err("No memory for children pids\n"); goto err; } ret = read(fd, item->children, size); if (ret != size) { - pr_error("An error in reading children pids\n"); + pr_err("An error in reading children pids\n"); xfree(item->children); goto err; } diff --git a/crtools.c b/crtools.c index c76ca337e..3dad0a309 100644 --- a/crtools.c +++ b/crtools.c @@ -162,8 +162,8 @@ int prep_cr_fdset_for_restore(struct cr_fdset *cr_fdset, read_ptr_safe(cr_fdset->desc[i].fd, &magic, err); if (magic != cr_fdset->desc[i].tmpl->magic) { - pr_error("Magic doesn't match for %s\n", - cr_fdset->desc[i].name); + pr_err("Magic doesn't match for %s\n", + cr_fdset->desc[i].name); goto err; } diff --git a/elf.c b/elf.c index 91f967abc..44274e67a 100644 --- a/elf.c +++ b/elf.c @@ -107,12 +107,12 @@ int convert_to_elf(char *elf_path, int fd_core) /* Figure out if we're overflowed */ if (e_phnum > ELF_MAX_PHDR) { - pr_error("Too many VMA areas (%li of %li allowed)\n", - e_phnum, ELF_MAX_PHDR); + pr_err("Too many VMA areas (%li of %li allowed)\n", + e_phnum, ELF_MAX_PHDR); goto err_close; } else if (nrpages > ELF_MAX_PAGES) { - pr_error("Too many pages to restore (%li of %li allowed)\n", - nrpages, ELF_MAX_PAGES); + pr_err("Too many pages to restore (%li of %li allowed)\n", + nrpages, ELF_MAX_PAGES); goto err_close; } diff --git a/include/util.h b/include/util.h index ca2f33ea0..e8aaa93d7 100644 --- a/include/util.h +++ b/include/util.h @@ -16,11 +16,11 @@ extern void printk(const char *format, ...); #define pr_info(fmt, ...) printk(fmt, ##__VA_ARGS__) -#define pr_error(fmt, ...) printk("Error (%s:%d): " fmt, __FILE__, __LINE__, ##__VA_ARGS__) +#define pr_err(fmt, ...) printk("Error (%s:%d): " fmt, __FILE__, __LINE__, ##__VA_ARGS__) #define pr_panic(fmt, ...) printk("PANIC (%s:%d): " fmt, __FILE__, __LINE__, ##__VA_ARGS__) #define pr_warning(fmt, ...) printk("Warning: " fmt, ##__VA_ARGS__) -#define pr_error_jmp(label) \ +#define pr_err_jmp(label) \ do { \ printk("EJMP: %s:%d\n", __FILE__, __LINE__); \ goto label; \ @@ -29,20 +29,20 @@ extern void printk(const char *format, ...); #define jerr(code, label) \ do { \ if ((code)) \ - pr_error_jmp(label); \ + pr_err_jmp(label); \ } while (0) #define jerr_cond(code, cond, label) \ do { \ if ((code) cond) \ - pr_error_jmp(label); \ + pr_err_jmp(label); \ } while (0) #define jerr_rc(code, rc, label) \ do { \ rc = (code); \ if (rc) \ - pr_error_jmp(label); \ + pr_err_jmp(label); \ } while (0) #if 0 @@ -65,14 +65,14 @@ extern void printk(const char *format, ...); #define pr_perror(fmt, ...) \ do { \ - pr_error("%s: " fmt, strerror(errno), \ - ##__VA_ARGS__); \ + pr_err("%s: " fmt, strerror(errno), \ + ##__VA_ARGS__); \ } while (0) #define stop_task(pid) kill(pid, SIGSTOP) #define continue_task(pid) kill(pid, SIGCONT) -#define write_ptr(fd, ptr) \ +#define write_ptr(fd, ptr) \ write(fd, (ptr), sizeof(*(ptr))) #define write_ptr_safe(fd, ptr, err) \ @@ -154,8 +154,8 @@ int close_safe(int *fd); ({ \ void *___p = op( __VA_ARGS__ ); \ if (!___p) \ - pr_error("%s: Can't allocate %li bytes\n", \ - __func__, (long)(size)); \ + pr_err("%s: Can't allocate %li bytes\n", \ + __func__, (long)(size)); \ ___p; \ }) diff --git a/parasite-syscall.c b/parasite-syscall.c index 3752a404d..f0d4b9985 100644 --- a/parasite-syscall.c +++ b/parasite-syscall.c @@ -284,7 +284,7 @@ again: if (ptrace_poke_area((long)ctl->pid, (void *)parasite_arg.args, (void *)ctl->addr_args, parasite_arg.args_size)) { - pr_error("Can't setup parasite arguments (pid: %d)\n", ctl->pid); + pr_err("Can't setup parasite arguments (pid: %d)\n", ctl->pid); goto err_restore; } @@ -324,7 +324,7 @@ retry_signal: (void *)(ctl->addr_args + offsetof(parasite_args_cmd_dumppages_t, fd)), sizeof(parasite_dumppages.fd))) { - pr_error("Can't get file descriptor back (pid: %d)\n", ctl->pid); + pr_err("Can't get file descriptor back (pid: %d)\n", ctl->pid); goto err_restore; } } @@ -337,7 +337,7 @@ retry_signal: (void *)(ctl->addr_args + offsetof(parasite_args_cmd_dumppages_t, nrpages_dumped)), sizeof(parasite_dumppages.fd))) { - pr_error("Can't get statistics (pid: %d)\n", ctl->pid); + pr_err("Can't get statistics (pid: %d)\n", ctl->pid); goto err_restore; } pr_info(" (dumped: %16li pages)\n", parasite_dumppages.nrpages_dumped); @@ -409,7 +409,7 @@ int parasite_cure_seized(struct parasite_ctl **p_ctl, vma_area = get_vma_by_ip(vma_area_list, regs.ip); if (!vma_area) { - pr_error("No suitable VMA found to run cure (pid: %d)\n", ctl->pid); + pr_err("No suitable VMA found to run cure (pid: %d)\n", ctl->pid); goto err; } @@ -419,7 +419,7 @@ int parasite_cure_seized(struct parasite_ctl **p_ctl, (void *)ctl->vma_area->vma.start, (size_t)vma_entry_len(&ctl->vma_area->vma)); if (ret) - pr_error("munmap_seized failed (pid: %d)\n", ctl->pid); + pr_err("munmap_seized failed (pid: %d)\n", ctl->pid); if (ptrace(PTRACE_SETREGS, ctl->pid, NULL, ®s_orig)) { ret = -1; @@ -440,7 +440,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l ctl = xzalloc(sizeof(*ctl) + sizeof(*vma_area)); if (!ctl) { - pr_error("Parasite control block allocation failed (pid: %d)\n", pid); + pr_err("Parasite control block allocation failed (pid: %d)\n", pid); goto err; } @@ -449,11 +449,11 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l ctl->vma_area = (struct vma_area *)(char *)&ctl[sizeof(*ctl)]; if (ptrace(PTRACE_GETREGS, pid, NULL, ®s)) - pr_error_jmp(err_free); + pr_err_jmp(err_free); vma_area = get_vma_by_ip(vma_area_list, regs.ip); if (!vma_area) { - pr_error("No suitable VMA found to run parasite " + pr_err("No suitable VMA found to run parasite " "bootstrap code (pid: %d)\n", pid); goto err_free; } @@ -474,7 +474,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l (int)-1, (off_t)0); if (!mmaped || (long)mmaped < 0) { - pr_error("Can't allocate memory for parasite blob (pid: %d)\n", pid); + pr_err("Can't allocate memory for parasite blob (pid: %d)\n", pid); goto err_restore_regs; } @@ -487,7 +487,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, void *addr_hint, struct l ctl->vma_area->vma.end = (u64)(mmaped + parasite_size); if (ptrace_poke_area(pid, parasite_blob, mmaped, parasite_size)) { - pr_error("Can't inject parasite blob (pid: %d)\n", pid); + pr_err("Can't inject parasite blob (pid: %d)\n", pid); goto err_munmap_restore; } diff --git a/util.c b/util.c index 225700b92..9320dabcb 100644 --- a/util.c +++ b/util.c @@ -297,7 +297,7 @@ int parse_maps(pid_t pid, struct list_head *vma_area_list) &start, &end, &r, &w, &x, &s, &pgoff, &dev_maj, &dev_min, &ino); if (ret != 10) { - pr_error("Can't parse: %s", big_buffer); + pr_err("Can't parse: %s", big_buffer); return -1; } @@ -375,10 +375,10 @@ int parse_maps(pid_t pid, struct list_head *vma_area_list) goto err; } if (!S_ISREG(st_buf.st_mode)) { - pr_error("Can't handle non-regular " - "mapping on %s%s\n", - map_files_path, - vma_file_path); + pr_err("Can't handle non-regular " + "mapping on %s%s\n", + map_files_path, + vma_file_path); goto err; } @@ -424,8 +424,8 @@ err: return ret; err_bogus_mapping: - pr_error("Bogus mapping %lx-%lx\n", - vma_area->vma.start, - vma_area->vma.end); + pr_err("Bogus mapping %lx-%lx\n", + vma_area->vma.start, + vma_area->vma.end); goto err; }