From 7ea20e8f5a533a2458b53b14749d36e1194ac47c Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 22 Apr 2021 17:43:47 -0700 Subject: [PATCH] criu: make sure to use pr_perror to show errno In cases where we need to print errno, it is better to use pr_perror. Signed-off-by: Kir Kolyshkin --- criu/arch/x86/kerndat.c | 2 +- criu/cgroup.c | 2 +- criu/cr-check.c | 12 ++++++------ criu/cr-restore.c | 2 +- criu/kerndat.c | 2 +- criu/shmem.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/criu/arch/x86/kerndat.c b/criu/arch/x86/kerndat.c index cb7a2aa05..ac627ac00 100644 --- a/criu/arch/x86/kerndat.c +++ b/criu/arch/x86/kerndat.c @@ -110,7 +110,7 @@ static void mmap_bug_test(void) } if (munmap(map1, PAGE_SIZE)) { - pr_err("Failed to unmap() 32-bit mapping: %m\n"); + pr_perror("Failed to unmap() 32-bit mapping"); exit(1); } diff --git a/criu/cgroup.c b/criu/cgroup.c index 8576ee2f1..d0761e8e7 100644 --- a/criu/cgroup.c +++ b/criu/cgroup.c @@ -311,7 +311,7 @@ static int read_cgroup_prop(struct cgroup_prop *property, const char *fullpath) ret = read(fd, buf, sizeof(buf) - 1); if (ret == -1) { - pr_err("Failed scanning %s\n", fullpath); + pr_perror("Failed scanning %s", fullpath); close(fd); return -1; } diff --git a/criu/cr-check.c b/criu/cr-check.c index 57b6316c2..2fdc4408a 100644 --- a/criu/cr-check.c +++ b/criu/cr-check.c @@ -190,7 +190,7 @@ static int check_prctl_cat1(void) ret = prctl(PR_GET_TID_ADDRESS, (unsigned long)&tid_addr, 0, 0, 0); if (ret < 0) { - pr_msg("prctl: PR_GET_TID_ADDRESS is not supported: %m"); + pr_perror("prctl: PR_GET_TID_ADDRESS is not supported"); return -1; } @@ -206,19 +206,19 @@ static int check_prctl_cat1(void) if (errno == EPERM) pr_msg("prctl: One needs CAP_SYS_RESOURCE capability to perform testing\n"); else - pr_msg("prctl: PR_SET_MM_BRK is not supported: %m\n"); + pr_perror("prctl: PR_SET_MM_BRK is not supported"); return -1; } ret = prctl(PR_SET_MM, PR_SET_MM_EXE_FILE, -1, 0, 0); if (ret < 0 && errno != EBADF) { - pr_msg("prctl: PR_SET_MM_EXE_FILE is not supported: %m\n"); + pr_perror("prctl: PR_SET_MM_EXE_FILE is not supported"); return -1; } ret = prctl(PR_SET_MM, PR_SET_MM_AUXV, (long)&user_auxv, sizeof(user_auxv), 0); if (ret < 0) { - pr_msg("prctl: PR_SET_MM_AUXV is not supported: %m\n"); + pr_perror("prctl: PR_SET_MM_AUXV is not supported"); return -1; } } @@ -908,7 +908,7 @@ static int check_aio_remap(void) int r; if (syscall(SYS_io_setup, 16, &ctx) < 0) { - pr_err("No AIO syscall: %m\n"); + pr_perror("No AIO syscall"); return -1; } @@ -930,7 +930,7 @@ static int check_aio_remap(void) ctx = (aio_context_t)naddr; r = syscall(SYS_io_getevents, ctx, 0, 1, NULL, NULL); if (r < 0) { - pr_err("AIO remap doesn't work properly: %m\n"); + pr_perror("AIO remap doesn't work properly"); return -1; } diff --git a/criu/cr-restore.c b/criu/cr-restore.c index 6da80f031..53cae3509 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -3614,7 +3614,7 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns /* VMA we need for stacks and sigframes for threads */ if (mmap(mem, memzone_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, 0, 0) != mem) { - pr_err("Can't mmap section for restore code\n"); + pr_perror("Can't mmap section for restore code"); goto err; } diff --git a/criu/kerndat.c b/criu/kerndat.c index 21fcb620d..2327a8e25 100644 --- a/criu/kerndat.c +++ b/criu/kerndat.c @@ -417,7 +417,7 @@ static bool kerndat_has_memfd_create(void) else if (ret == -1 && errno == EFAULT) kdat.has_memfd = true; else { - pr_err("Unexpected error from memfd_create(NULL, 0): %m\n"); + pr_perror("Unexpected error from memfd_create(NULL, 0)"); return -1; } diff --git a/criu/shmem.c b/criu/shmem.c index 29383e79a..3de7170b8 100644 --- a/criu/shmem.c +++ b/criu/shmem.c @@ -591,7 +591,7 @@ static int open_shmem(int pid, struct vma_area *vma) */ addr = mmap(NULL, si->size, PROT_WRITE | PROT_READ, flags, f, 0); if (addr == MAP_FAILED) { - pr_err("Can't mmap shmid=0x%"PRIx64" size=%ld\n", + pr_perror("Can't mmap shmid=0x%"PRIx64" size=%ld", vi->shmid, si->size); goto err; }