[CRIU] [PATCH 9/9] criu/*: annual pr_perror() usage sanitization
Kir Kolyshkin
kir at openvz.org
Mon Nov 7 13:37:53 PST 2016
When using pr_perror(), we should not end the message with \n,
as it is added automatically.
Unfortunately, I still can't figure a way to check this at compile
time, so here's the annual patch.
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
criu/cgroup-props.c | 6 +++---
criu/image.c | 2 +-
criu/mount.c | 8 ++++----
criu/proc_parse.c | 2 +-
criu/sk-unix.c | 2 +-
criu/tty.c | 8 ++++----
6 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/criu/cgroup-props.c b/criu/cgroup-props.c
index 489801f..251c463 100644
--- a/criu/cgroup-props.c
+++ b/criu/cgroup-props.c
@@ -371,18 +371,18 @@ static int cgp_parse_file(char *path)
fd = open(path, O_RDONLY);
if (fd < 0) {
- pr_perror("Can't open file %s\n", path);
+ pr_perror("Can't open file %s", path);
goto err;
}
if (fstat(fd, &st)) {
- pr_perror("Can't stat file %s\n", path);
+ pr_perror("Can't stat file %s", path);
goto err;
}
mem = mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE, fd, 0);
if (mem == MAP_FAILED) {
- pr_perror("Can't mmap file %s\n", path);
+ pr_perror("Can't mmap file %s", path);
goto err;
}
diff --git a/criu/image.c b/criu/image.c
index 7d8bc7a..5d3b56e 100644
--- a/criu/image.c
+++ b/criu/image.c
@@ -589,7 +589,7 @@ off_t img_raw_size(struct cr_img *img)
struct stat stat;
if (fstat(img->_x.fd, &stat)) {
- pr_perror("Failed to get image stats\n");
+ pr_perror("Failed to get image stats");
return -1;
}
diff --git a/criu/mount.c b/criu/mount.c
index 37cfdd4..d80ae59 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -1204,7 +1204,7 @@ static __maybe_unused int mount_cr_time_mount(struct ns_id *ns, unsigned int *s_
goto restore_ns;
} else {
if (stat(target, &st) < 0) {
- pr_perror("Can't stat on %s\n", target);
+ pr_perror("Can't stat %s", target);
exit_code = 0;
} else {
*s_dev = MKKDEV(major(st.st_dev), minor(st.st_dev));
@@ -1740,7 +1740,7 @@ static int do_new_mount(struct mount_info *mi)
if (mi->mnt_id == CRTIME_MNT_ID) {
/* C-r time mountpoint, umount it */
if (umount(mi->mountpoint) < 0) {
- pr_perror("Can't umount %s\n", mi->mountpoint);
+ pr_perror("Can't umount %s", mi->mountpoint);
return -1;
}
goto out;
@@ -1751,7 +1751,7 @@ static int do_new_mount(struct mount_info *mi)
fd = open(mi->mountpoint, O_PATH);
if (fd < 0) {
- pr_perror("Unable to open %s\n", mi->mountpoint);
+ pr_perror("Unable to open %s", mi->mountpoint);
return -1;
}
@@ -3215,7 +3215,7 @@ void clean_cr_time_mounts(void)
}
if (umount(mi->mountpoint) < 0)
- pr_perror("Can't umount forced mount %s\n", mi->mountpoint);
+ pr_perror("Can't umount forced mount %s", mi->mountpoint);
if (restore_ns(mnt_fd, &mnt_ns_desc)) {
pr_err("cleanup_forced_mounts exiting with wrong mnt_ns\n");
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index c00e7da..3f84cda 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -2328,7 +2328,7 @@ int parse_task_cgroup(int pid, struct parasite_dump_cgroup_args *args, struct li
f = fmemopen(args->contents, strlen(args->contents), "r");
if (!f) {
- pr_perror("couldn't fmemopen cgroup buffer:\n%s", args->contents);
+ pr_perror("couldn't fmemopen cgroup buffer %s", args->contents);
return -1;
}
diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 6a1a532..202228d 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -1019,7 +1019,7 @@ static int bind_unix_sk(int sk, struct unix_sk_info *ui)
}
if (ui->ue->deleted && unlink((char *)ui->ue->name.data) < 0) {
- pr_perror("failed to unlink %s\n", ui->ue->name.data);
+ pr_perror("failed to unlink %s", ui->ue->name.data);
goto done;
}
}
diff --git a/criu/tty.c b/criu/tty.c
index a9e4930..7822a4f 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -841,7 +841,7 @@ static int restore_tty_params(int fd, struct tty_info *info)
if (info->tie->has_uid && info->tie->has_gid) {
if (fchown(fd, info->tie->uid, info->tie->gid)) {
- pr_perror("Can't setup uid %d gid %d on %x\n",
+ pr_perror("Can't setup uid %d gid %d on %x",
(int)info->tie->uid,
(int)info->tie->gid,
info->tfe->id);
@@ -1872,7 +1872,7 @@ static int tty_reblock(int id, int lfd, int flags)
if ((flags & fmask) != fmask) {
if (fcntl(lfd, F_SETFL, flags)) {
ret = -errno;
- pr_perror("Can't revert mode back to %o on (%#x)\n", fmask, id);
+ pr_perror("Can't revert mode back to %o on (%#x)", fmask, id);
return ret;
}
}
@@ -1888,7 +1888,7 @@ static int tty_unblock(int id, int lfd, int flags)
if ((flags & fmask) != fmask) {
if (fcntl(lfd, F_SETFL, fmask)) {
ret = -errno;
- pr_perror("Can't change mode to %o on (%#x)\n", fmask, id);
+ pr_perror("Can't change mode to %o on (%#x)", fmask, id);
return ret;
}
}
@@ -1972,7 +1972,7 @@ static void __tty_do_writeback_queued_data(struct tty_dump_info *dinfo)
if (dinfo->tty_data) {
if (write(dinfo->link->lfd, dinfo->tty_data,
dinfo->tty_data_size) != dinfo->tty_data_size)
- pr_perror("Can't writeback to tty (%#x)\n", dinfo->id);
+ pr_perror("Can't writeback to tty (%#x)", dinfo->id);
}
tty_reblock(dinfo->link->id, dinfo->link->lfd, dinfo->link->flags);
}
--
2.7.4
More information about the CRIU
mailing list