Commit 3f21c114 by Ryousei Takano Committed by Daniel Lezcano

Fix compile warnings

This patch fixes compile warnings: ignoring return value of function, declared with attribute warn_unused_result, and adds error handling. Signed-off-by: 's avatarRyousei Takano <takano-ryousei@aist.go.jp> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent abf424cf
...@@ -133,7 +133,10 @@ int main(int argc, char *argv[]) ...@@ -133,7 +133,10 @@ int main(int argc, char *argv[])
/* read the "stdin" and write that to the master /* read the "stdin" and write that to the master
*/ */
if (pfd[0].revents & POLLIN) { if (pfd[0].revents & POLLIN) {
read(0, &c, 1); if (read(0, &c, 1) < 0) {
lxc_log_syserror("failed to read");
goto out_err;
}
/* we want to exit the console with Ctrl+a q */ /* we want to exit the console with Ctrl+a q */
if (c == 1) { if (c == 1) {
...@@ -145,7 +148,10 @@ int main(int argc, char *argv[]) ...@@ -145,7 +148,10 @@ int main(int argc, char *argv[])
goto out; goto out;
wait4q = 0; wait4q = 0;
write(master, &c, 1); if (write(master, &c, 1) < 0) {
lxc_log_syserror("failed to write");
goto out_err;
}
} }
/* other side has closed the connection */ /* other side has closed the connection */
...@@ -154,7 +160,10 @@ int main(int argc, char *argv[]) ...@@ -154,7 +160,10 @@ int main(int argc, char *argv[])
/* read the master and write to "stdout" */ /* read the master and write to "stdout" */
if (pfd[1].revents & POLLIN) { if (pfd[1].revents & POLLIN) {
read(master, &c, 1); if (read(master, &c, 1) < 0) {
lxc_log_syserror("failed to read");
goto out_err;
}
printf("%c", c); printf("%c", c);
fflush(stdout); fflush(stdout);
} }
......
...@@ -164,8 +164,14 @@ int lxc_restart(const char *name, const char *statefile, ...@@ -164,8 +164,14 @@ int lxc_restart(const char *name, const char *statefile,
goto err_child_failed; goto err_child_failed;
} }
asprintf(&val, "%d\n", pid); if (!asprintf(&val, "%d\n", pid)) {
asprintf(&init, LXCPATH "/%s/init", name); lxc_log_syserror("failed to allocate memory");
goto err_child_failed;
}
if (!asprintf(&init, LXCPATH "/%s/init", name)) {
lxc_log_syserror("failed to allocate memory");
goto err_child_failed;
}
fd = open(init, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR); fd = open(init, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
if (fd < 0) { if (fd < 0) {
lxc_log_syserror("failed to open '%s'", init); lxc_log_syserror("failed to open '%s'", init);
......
...@@ -427,7 +427,10 @@ int lxc_start(const char *name, char *argv[]) ...@@ -427,7 +427,10 @@ int lxc_start(const char *name, char *argv[])
goto err_child_failed; goto err_child_failed;
} }
asprintf(&val, "%d\n", pid); if (!asprintf(&val, "%d\n", pid)) {
lxc_log_syserror("failed to allocate memory");
goto err_child_failed;
}
snprintf(init, MAXPATHLEN, LXCPATH "/%s/init", name); snprintf(init, MAXPATHLEN, LXCPATH "/%s/init", name);
......
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