Commit a22afaa1 authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

cr-check: use pr_* right

In a few cases, such as after open() or access() gave an error,
using pr_perror() is preferable as it gives us errno.

In some cases, use pr_err() instead of pr_msg() -- for consistency.

In cases after sys_* calls, errno is not set but is returned
and so to use pr_perror() we should assign errno manually.
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 63a11487
...@@ -54,12 +54,12 @@ static int check_tty(void) ...@@ -54,12 +54,12 @@ static int check_tty(void)
master = open("/dev/ptmx", O_RDWR); master = open("/dev/ptmx", O_RDWR);
if (master < 0) { if (master < 0) {
pr_msg("Can't open master pty.\n"); pr_perror("Can't open /dev/ptmx");
goto out; goto out;
} }
if (ioctl(master, TIOCSPTLCK, &lock)) { if (ioctl(master, TIOCSPTLCK, &lock)) {
pr_msg("Unable to lock pty device.\n"); pr_perror("Can't lock pty master");
goto out; goto out;
} }
...@@ -67,11 +67,11 @@ static int check_tty(void) ...@@ -67,11 +67,11 @@ static int check_tty(void)
slave = open(slavename, O_RDWR); slave = open(slavename, O_RDWR);
if (slave < 0) { if (slave < 0) {
if (errno != EIO) { if (errno != EIO) {
pr_msg("Unexpected error code on locked pty.\n"); pr_perror("Unexpected error on locked pty");
goto out; goto out;
} }
} else { } else {
pr_msg("Managed to open locked pty.\n"); pr_err("Managed to open locked pty.\n");
goto out; goto out;
} }
...@@ -90,7 +90,7 @@ static int check_map_files(void) ...@@ -90,7 +90,7 @@ static int check_map_files(void)
if (!ret) if (!ret)
return 0; return 0;
pr_msg("/proc/<pid>/map_files directory is missing.\n"); pr_perror("/proc/<pid>/map_files is inaccessible");
return -1; return -1;
} }
...@@ -126,7 +126,7 @@ static int check_ns_last_pid(void) ...@@ -126,7 +126,7 @@ static int check_ns_last_pid(void)
if (!ret) if (!ret)
return 0; return 0;
pr_msg("%s sysctl is missing.\n", LAST_PID_PATH); pr_perror("%s sysctl is inaccessible", LAST_PID_PATH);
return -1; return -1;
} }
...@@ -159,7 +159,8 @@ static int check_kcmp(void) ...@@ -159,7 +159,8 @@ static int check_kcmp(void)
if (ret != -ENOSYS) if (ret != -ENOSYS)
return 0; return 0;
pr_msg("System call kcmp is not supported\n"); errno = -ret;
pr_perror("System call kcmp is not supported");
return -1; return -1;
} }
...@@ -172,7 +173,7 @@ static int check_prctl(void) ...@@ -172,7 +173,7 @@ static int check_prctl(void)
ret = sys_prctl(PR_GET_TID_ADDRESS, (unsigned long)&tid_addr, 0, 0, 0); ret = sys_prctl(PR_GET_TID_ADDRESS, (unsigned long)&tid_addr, 0, 0, 0);
if (ret) { if (ret) {
pr_msg("prctl: PR_GET_TID_ADDRESS is not supported\n"); pr_msg("prctl: PR_GET_TID_ADDRESS is not supported");
return -1; return -1;
} }
...@@ -507,17 +508,20 @@ static int check_ipc(void) ...@@ -507,17 +508,20 @@ static int check_ipc(void)
if (!ret) if (!ret)
return 0; return 0;
pr_msg("/proc/sys/kernel/sem_next_id sysctl is missing.\n"); pr_perror("/proc/sys/kernel/sem_next_id is inaccessible");
return -1; return -1;
} }
static int check_sigqueuinfo() static int check_sigqueuinfo()
{ {
int ret;
siginfo_t info = { .si_code = 1 }; siginfo_t info = { .si_code = 1 };
signal(SIGUSR1, SIG_IGN); signal(SIGUSR1, SIG_IGN);
if (sys_rt_sigqueueinfo(getpid(), SIGUSR1, &info)) { ret = sys_rt_sigqueueinfo(getpid(), SIGUSR1, &info);
if (ret < 0) {
errno = -ret;
pr_perror("Unable to send siginfo with positive si_code to itself"); pr_perror("Unable to send siginfo with positive si_code to itself");
return -1; return -1;
} }
...@@ -836,6 +840,7 @@ static int check_userns(void) ...@@ -836,6 +840,7 @@ static int check_userns(void)
ret = sys_prctl(PR_SET_MM, PR_SET_MM_MAP_SIZE, (unsigned long)&size, 0, 0); ret = sys_prctl(PR_SET_MM, PR_SET_MM_MAP_SIZE, (unsigned long)&size, 0, 0);
if (ret) { if (ret) {
errno = -ret;
pr_perror("No new prctl API"); pr_perror("No new prctl API");
return -1; return -1;
} }
......
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