Commit 56f91edf authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

open_proc: don't print error twice

open_proc* and fopen_proc* are all macros, and they print errors in case
something is wrong (and as they are macros they print correct file:line
info, too). So, there is no need to print another error message
right after calling those.

This fixes double error messages like these:

(00.047295) Error (criu/proc_parse.c:990): Can't open 18472/status on procfs: No such file or directory
(00.047298) Error (criu/proc_parse.c:992): Can't open proc status: No such file or directory

travis-ci: success for Assorted nitpicks
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 7b07ac5f
......@@ -297,10 +297,8 @@ static int autofs_revisit_options(struct mount_info *pm)
}
f = fopen_proc(getpid(), "mountinfo");
if (!f) {
pr_perror("Can't open %d mountinfo", getpid());
if (!f)
goto free_str;
}
while (fgets(str, 1024, f)) {
int mnt_id = -1;
......
......@@ -838,10 +838,8 @@ static int check_autofs_pipe_ino(void)
int ret = -ENOENT;
f = fopen_proc(PROC_SELF, "mountinfo");
if (!f) {
pr_perror("Can't open %d mountinfo", getpid());
if (!f)
return -1;
}
while (fgets(str, sizeof(str), f)) {
if (strstr(str, " autofs ")) {
......
......@@ -901,10 +901,8 @@ static inline int fork_with_pid(struct pstree_item *item)
int len;
ca.fd = open_proc_rw(PROC_GEN, LAST_PID_PATH);
if (ca.fd < 0) {
pr_perror("%d: Can't open %s", pid, LAST_PID_PATH);
if (ca.fd < 0)
goto err;
}
if (flock(ca.fd, LOCK_EX)) {
close(ca.fd);
......@@ -1727,11 +1725,9 @@ static int restore_root_task(struct pstree_item *init)
if (root_ns_mask & CLONE_NEWNS) {
mnt_ns_fd = open_proc(init->pid.real, "ns/mnt");
if (mnt_ns_fd < 0) {
pr_perror("Can't open init's mntns fd");
if (mnt_ns_fd < 0)
goto out_kill;
}
}
ret = run_scripts(ACT_SETUP_NS);
if (ret)
......
......@@ -74,10 +74,8 @@ static int parse_self_maps(unsigned long vm_start, dev_t *device)
char buf[1024];
maps = fopen_proc(PROC_SELF, "maps");
if (maps == NULL) {
pr_perror("Can't open self maps");
if (maps == NULL)
return -1;
}
while (fgets(buf, sizeof(buf), maps) != NULL) {
char *end, *aux;
......
......@@ -225,10 +225,8 @@ int switch_ns(int pid, struct ns_desc *nd, int *rst)
int ret;
nsfd = open_proc(pid, "ns/%s", nd->str);
if (nsfd < 0) {
pr_perror("Can't open ns file");
if (nsfd < 0)
return -1;
}
ret = switch_ns_by_fd(nsfd, nd, rst);
......
......@@ -1152,10 +1152,8 @@ static int restore_one_macvlan(NetDeviceEntry *nde, int nlsk, int criu_nlsk)
extras.link = (int) (unsigned long) val;
my_netns = open_proc(PROC_SELF, "ns/net");
if (my_netns < 0) {
pr_perror("couldn't get my netns");
if (my_netns < 0)
return -1;
}
{
struct newlink_req req;
......
......@@ -423,10 +423,8 @@ int parse_self_maps_lite(struct vm_area_list *vms)
vm_area_list_init(vms);
maps = fopen_proc(PROC_SELF, "maps");
if (maps == NULL) {
pr_perror("Can't open self maps");
if (maps == NULL)
return -1;
}
while (fgets(buf, BUF_SIZE, maps) != NULL) {
struct vma_area *vma;
......@@ -988,10 +986,8 @@ int parse_pid_status(pid_t pid, struct proc_status_creds *cr)
bool parsed_seccomp = false;
f.fd = open_proc(pid, "status");
if (f.fd < 0) {
pr_perror("Can't open proc status");
if (f.fd < 0)
return -1;
}
cr->sigpnd = 0;
cr->shdpnd = 0;
......@@ -1414,10 +1410,8 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump)
FILE *f;
f = fopen_proc(pid, "mountinfo");
if (!f) {
pr_perror("Can't open %d mountinfo", pid);
if (!f)
return NULL;
}
while (fgets(buf, BUF_SIZE, f)) {
struct mount_info *new;
......@@ -1626,10 +1620,8 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type,
int ret, exit_code = -1;;
f.fd = open_proc(pid, "fdinfo/%d", fd);
if (f.fd < 0) {
pr_perror("Can't open fdinfo/%d to parse", fd);
if (f.fd < 0)
return -1;
}
if (bfdopenr(&f))
return -1;
......@@ -2029,10 +2021,8 @@ int parse_file_locks(void)
return 0;
fl_locks = fopen_proc(PROC_GEN, "locks");
if (!fl_locks) {
pr_perror("Can't open file locks file!");
if (!fl_locks)
return -1;
}
while (fgets(buf, BUF_SIZE, fl_locks)) {
is_blocked = strstr(buf, "->") != NULL;
......@@ -2117,10 +2107,8 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args)
args->timer_n = 0;
f.fd = open_proc(pid, "timers");
if (f.fd < 0) {
pr_perror("Can't open posix timers file!");
if (f.fd < 0)
return -1;
}
if (bfdopenr(&f))
return -1;
......@@ -2323,10 +2311,8 @@ int parse_task_cgroup(int pid, struct parasite_dump_cgroup_args *args, struct li
struct cg_ctl *intern, *ext;
f = fopen_proc(pid, "cgroup");
if (!f) {
pr_perror("couldn't open task cgroup file");
if (!f)
return -1;
}
ret = parse_cgroup_file(f, retl, n);
fclose(f);
......
......@@ -273,7 +273,7 @@ static int log_unfrozen_stacks(char *root)
stack = open_proc(pid, "stack");
if (stack < 0) {
pr_perror("couldn't log %d's stack", pid);
pr_err("`- couldn't log %d's stack\n", pid);
fclose(f);
return -1;
}
......
......@@ -448,9 +448,6 @@ static int shmem_wait_and_open(int pid, struct shmem_info *si, VmaEntry *vi)
pr_info("Opening shmem [%s] \n", path);
ret = open_proc_rw(si->pid, "fd/%d", si->fd);
if (ret < 0)
pr_perror(" %d: Can't stat shmem at %s",
si->pid, path);
futex_inc_and_wake(&si->lock);
if (ret < 0)
return -1;
......
......@@ -223,10 +223,8 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
*s = (struct vdso_symtable)VDSO_SYMTABLE_INIT;
maps = fopen_proc(PROC_SELF, "maps");
if (!maps) {
pr_perror("Can't open self-vma");
if (!maps)
return -1;
}
while (fgets(buf, sizeof(buf), maps)) {
unsigned long start, end;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment