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

zdtm: introduce and use pr_err()

Sometimes pr_perror() is used in places that don't have errno set.
In such places, pr_perror() should not be used as it will print
some nonsense.

Introduce and use pr_err() for such cases.

Now, I see sometimes fail() is used in such cases but I think
it is reserved for places where test fails (rather than there is
something that prevents the test from working).

Also, sometimes test_msg() is used but it doesn't print source
file name and line number.

If there will be a need, we can unify pr_err() with say fail(),
it will be easier to do after this patch.
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Acked-by: 's avatarAndrew Vagin <avagin@gmail.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 036d4053
...@@ -27,7 +27,7 @@ int main(int argc, char **argv) ...@@ -27,7 +27,7 @@ int main(int argc, char **argv)
test_init(argc, argv); test_init(argc, argv);
if ((fd_s = tcp_init_server(ZDTM_FAMILY, &port)) < 0) { if ((fd_s = tcp_init_server(ZDTM_FAMILY, &port)) < 0) {
pr_perror("initializing server failed"); pr_err("initializing server failed\n");
return 1; return 1;
} }
...@@ -40,7 +40,7 @@ int main(int argc, char **argv) ...@@ -40,7 +40,7 @@ int main(int argc, char **argv)
*/ */
fd = tcp_accept_server(fd_s); fd = tcp_accept_server(fd_s);
if (fd < 0) { if (fd < 0) {
pr_perror("can't accept client connection %m"); pr_err("can't accept client connection\n");
return 1; return 1;
} }
close(fd_s); close(fd_s);
......
...@@ -118,7 +118,7 @@ int main(int argc, char **argv) ...@@ -118,7 +118,7 @@ int main(int argc, char **argv)
test_init(argc, argv); test_init(argc, argv);
if ((fd_s = tcp_init_server(ZDTM_FAMILY, &port)) < 0) { if ((fd_s = tcp_init_server(ZDTM_FAMILY, &port)) < 0) {
pr_perror("initializing server failed"); pr_err("initializing server failed\n");
return 1; return 1;
} }
...@@ -134,7 +134,7 @@ int main(int argc, char **argv) ...@@ -134,7 +134,7 @@ int main(int argc, char **argv)
*/ */
fd = tcp_accept_server(fd_s); fd = tcp_accept_server(fd_s);
if (fd < 0) { if (fd < 0) {
pr_perror("can't accept client connection %m"); pr_err("can't accept client connection\n");
return 1; return 1;
} }
......
...@@ -212,7 +212,7 @@ int main(int argc, char **argv) ...@@ -212,7 +212,7 @@ int main(int argc, char **argv)
#endif #endif
if ((fd_s = tcp_init_server(ZDTM_FAMILY, &port)) < 0) { if ((fd_s = tcp_init_server(ZDTM_FAMILY, &port)) < 0) {
pr_perror("initializing server failed"); pr_err("initializing server failed\n");
return 1; return 1;
} }
...@@ -225,13 +225,13 @@ int main(int argc, char **argv) ...@@ -225,13 +225,13 @@ int main(int argc, char **argv)
*/ */
fd = tcp_accept_server(fd_s); fd = tcp_accept_server(fd_s);
if (fd < 0) { if (fd < 0) {
pr_perror("can't accept client connection %m"); pr_err("can't accept client connection\n");
return 1; return 1;
} }
ctl_fd = tcp_accept_server(fd_s); ctl_fd = tcp_accept_server(fd_s);
if (ctl_fd < 0) { if (ctl_fd < 0) {
pr_perror("can't accept client connection %m"); pr_err("can't accept client connection\n");
return 1; return 1;
} }
......
...@@ -36,7 +36,7 @@ int main(int argc, char **argv) ...@@ -36,7 +36,7 @@ int main(int argc, char **argv)
test_init(argc, argv); test_init(argc, argv);
if ((fd_s = tcp_init_server(AF_INET, &port)) < 0) { if ((fd_s = tcp_init_server(AF_INET, &port)) < 0) {
pr_perror("initializing server failed"); pr_err("initializing server failed\n");
return 1; return 1;
} }
...@@ -86,7 +86,7 @@ again: ...@@ -86,7 +86,7 @@ again:
goto again; goto again;
} }
if (ret != 0) { if (ret != 0) {
pr_perror("Error at aio_error() %s", strerror(ret)); pr_err("Error at aio_error(): %s\n", strerror(ret));
res = 1; res = 1;
} }
...@@ -105,7 +105,7 @@ again: ...@@ -105,7 +105,7 @@ again:
fd = tcp_accept_server(fd_s); fd = tcp_accept_server(fd_s);
close(fd_s); close(fd_s);
if (fd < 0) { if (fd < 0) {
pr_perror("can't accept client connection %m"); pr_err("can't accept client connection\n");
goto error; goto error;
} }
...@@ -125,7 +125,7 @@ again: ...@@ -125,7 +125,7 @@ again:
} }
if (WIFEXITED(status) && WEXITSTATUS(status) != 0) { if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
pr_perror("chiled failed. Return %d", WEXITSTATUS(status)); pr_err("child failed with exit code %d\n", WEXITSTATUS(status));
return 1; return 1;
} }
......
...@@ -44,7 +44,7 @@ int main(int argc, char **argv) ...@@ -44,7 +44,7 @@ int main(int argc, char **argv)
test_init(argc, argv); test_init(argc, argv);
if ((fd_s = tcp_init_server(ZDTM_FAMILY, &port)) < 0) { if ((fd_s = tcp_init_server(ZDTM_FAMILY, &port)) < 0) {
pr_perror("initializing server failed"); pr_err("initializing server failed\n");
return 1; return 1;
} }
...@@ -87,7 +87,7 @@ int main(int argc, char **argv) ...@@ -87,7 +87,7 @@ int main(int argc, char **argv)
fd = tcp_accept_server(fd_s); fd = tcp_accept_server(fd_s);
close(fd_s); close(fd_s);
if (fd < 0) { if (fd < 0) {
pr_perror("can't accept client connection %m"); pr_err("can't accept client connection\n");
goto error; goto error;
} }
...@@ -105,7 +105,7 @@ int main(int argc, char **argv) ...@@ -105,7 +105,7 @@ int main(int argc, char **argv)
} }
if (WIFEXITED(status) && WEXITSTATUS(status) != 0) { if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
pr_perror("chiled failed. Return %d", WEXITSTATUS(status)); pr_err("child failed with exit code %d\n", WEXITSTATUS(status));
return 1; return 1;
} }
......
...@@ -45,7 +45,7 @@ int main(int argc, char **argv) ...@@ -45,7 +45,7 @@ int main(int argc, char **argv)
for (i = 0; i < PROCS_DEF; i++) { for (i = 0; i < PROCS_DEF; i++) {
file_path = path[i]; file_path = path[i];
if (snprintf(file_path, BUF_SIZE, "%s-%02d", filename, i) >= BUF_SIZE) { if (snprintf(file_path, BUF_SIZE, "%s-%02d", filename, i) >= BUF_SIZE) {
pr_perror("filename %s is too long\n", filename); pr_err("filename %s is too long\n", filename);
exit(1); exit(1);
} }
if (mkfifo(file_path, mode)) { if (mkfifo(file_path, mode)) {
...@@ -113,7 +113,7 @@ int main(int argc, char **argv) ...@@ -113,7 +113,7 @@ int main(int argc, char **argv)
} }
if (num_exited) { if (num_exited) {
pr_perror("Some children died unexpectedly\n"); pr_err("Some children died unexpectedly\n");
kill(0, SIGKILL); kill(0, SIGKILL);
exit(1); exit(1);
} }
......
...@@ -80,7 +80,7 @@ again: ...@@ -80,7 +80,7 @@ again:
goto again; goto again;
} }
if (ret != 0) { if (ret != 0) {
pr_perror("Error at aio_error() %s", strerror(ret)); pr_err("Error at aio_error(): %s\n", strerror(ret));
return 1; return 1;
} }
......
...@@ -163,7 +163,7 @@ int recv_reply() ...@@ -163,7 +163,7 @@ int recv_reply()
} }
if (rtn == 0) { if (rtn == 0) {
pr_perror("EOF on netlink\n"); pr_err("EOF on netlink\n");
return -1; return -1;
} }
......
...@@ -38,7 +38,7 @@ int main(int argc, char **argv) ...@@ -38,7 +38,7 @@ int main(int argc, char **argv)
test_init(argc, argv); test_init(argc, argv);
if (num_procs > PROCS_MAX) { if (num_procs > PROCS_MAX) {
pr_perror("%d processes is too many: max = %d\n", num_procs, PROCS_MAX); pr_err("%d processes is too many: max = %d\n", num_procs, PROCS_MAX);
exit(1); exit(1);
} }
...@@ -96,7 +96,7 @@ int main(int argc, char **argv) ...@@ -96,7 +96,7 @@ int main(int argc, char **argv)
} }
if (num_exited) { if (num_exited) {
pr_perror("Some children died unexpectedly\n"); pr_err("Some children died unexpectedly\n");
kill(0, SIGKILL); kill(0, SIGKILL);
exit(1); exit(1);
} }
......
...@@ -39,7 +39,7 @@ int main(int argc, char **argv) ...@@ -39,7 +39,7 @@ int main(int argc, char **argv)
test_init(argc, argv); test_init(argc, argv);
if (num_procs > PROCS_MAX) { if (num_procs > PROCS_MAX) {
pr_perror("%d processes is too many: max = %d\n", num_procs, PROCS_MAX); pr_err("%d processes is too many: max = %d\n", num_procs, PROCS_MAX);
exit(1); exit(1);
} }
...@@ -91,7 +91,7 @@ int main(int argc, char **argv) ...@@ -91,7 +91,7 @@ int main(int argc, char **argv)
close(pipes[0]); close(pipes[0]);
if (num_exited) { if (num_exited) {
pr_perror("Some children died unexpectedly\n"); pr_err("Some children died unexpectedly\n");
kill(0, SIGKILL); kill(0, SIGKILL);
exit(1); exit(1);
} }
......
...@@ -39,7 +39,7 @@ int main(int argc, char **argv) ...@@ -39,7 +39,7 @@ int main(int argc, char **argv)
test_init(argc, argv); test_init(argc, argv);
if (num_procs > PROCS_MAX) { if (num_procs > PROCS_MAX) {
pr_perror("%d processes is too many: max = %d\n", num_procs, PROCS_MAX); pr_err("%d processes is too many: max = %d\n", num_procs, PROCS_MAX);
exit(1); exit(1);
} }
...@@ -98,7 +98,7 @@ int main(int argc, char **argv) ...@@ -98,7 +98,7 @@ int main(int argc, char **argv)
} }
if (num_exited) { if (num_exited) {
pr_perror("Some children died unexpectedly\n"); pr_err("Some children died unexpectedly\n");
kill(0, SIGKILL); kill(0, SIGKILL);
exit(1); exit(1);
} }
......
...@@ -44,7 +44,7 @@ static int setup_srv_sock(void) ...@@ -44,7 +44,7 @@ static int setup_srv_sock(void)
int sock; int sock;
if (fill_sock_name(&name, filename) < 0) { if (fill_sock_name(&name, filename) < 0) {
pr_perror("filename \"%s\" is too long", filename); pr_err("filename \"%s\" is too long\n", filename);
return -1; return -1;
} }
...@@ -90,7 +90,7 @@ static int accept_one_conn(int sock) ...@@ -90,7 +90,7 @@ static int accept_one_conn(int sock)
case 1: case 1:
break; break;
case 0: case 0:
pr_perror("timeout accepting a connection"); pr_err("timeout accepting a connection\n");
return -1; return -1;
default: default:
pr_perror("error while waiting for a connection"); pr_perror("error while waiting for a connection");
...@@ -110,7 +110,7 @@ static int setup_clnt_sock(void) ...@@ -110,7 +110,7 @@ static int setup_clnt_sock(void)
int ret = 0; int ret = 0;
if (fill_sock_name(&name, filename) < 0) { if (fill_sock_name(&name, filename) < 0) {
pr_perror("filename \"%s\" is too long", filename); pr_err("filename \"%s\" is too long\n", filename);
return -1; return -1;
} }
...@@ -181,7 +181,7 @@ int main(int argc, char **argv) ...@@ -181,7 +181,7 @@ int main(int argc, char **argv)
test_init(argc, argv); test_init(argc, argv);
if (num_procs > PROCS_MAX) { if (num_procs > PROCS_MAX) {
pr_perror("%d processes is too many: max = %d\n", num_procs, PROCS_MAX); pr_err("%d processes is too many: max = %d\n", num_procs, PROCS_MAX);
exit(1); exit(1);
} }
......
...@@ -106,7 +106,7 @@ int main(int argc, char **argv) ...@@ -106,7 +106,7 @@ int main(int argc, char **argv)
test_init(argc, argv); test_init(argc, argv);
if (scale > MAX_SCALE) { if (scale > MAX_SCALE) {
pr_perror("Too many children specified\n"); pr_err("Too many children specified\n");
exit(1); exit(1);
} }
......
...@@ -187,7 +187,7 @@ int main(int argc, char **argv) ...@@ -187,7 +187,7 @@ int main(int argc, char **argv)
test_init(argc, argv); test_init(argc, argv);
if (scale > MAX_SCALE) { if (scale > MAX_SCALE) {
pr_perror("Too many children specified\n"); pr_err("Too many children specified\n");
exit(-1); exit(-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