]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Fix compile warnings
authorRyousei Takano <takano-ryousei@aist.go.jp>
Tue, 31 Mar 2009 01:14:04 +0000 (10:14 +0900)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 31 Mar 2009 11:55:18 +0000 (13:55 +0200)
This patch fixes compile warnings: ignoring return value of function,
declared with attribute warn_unused_result, and adds error handling.

Signed-off-by: Ryousei Takano <takano-ryousei@aist.go.jp>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lxc_console.c
src/lxc/restart.c
src/lxc/start.c

index 6d5aef0aee82f7148975329b318579e5ad935018..c838bd26825401e4057564405561d44baa054e14 100644 (file)
@@ -133,7 +133,10 @@ int main(int argc, char *argv[])
                /* read the "stdin" and write that to the master
                 */
                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 */
                        if (c == 1) {
@@ -145,7 +148,10 @@ int main(int argc, char *argv[])
                                goto out;
 
                        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 */
@@ -154,7 +160,10 @@ int main(int argc, char *argv[])
 
                /* read the master and write to "stdout" */
                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);
                        fflush(stdout);
                }
index bc2329312c430739c679cfd611c44d49484caf8b..7508cf042db8214f4d61d5b8a2281ed4ab4cb263 100644 (file)
@@ -164,8 +164,14 @@ int lxc_restart(const char *name, const char *statefile,
                goto err_child_failed;
        }
 
-       asprintf(&val, "%d\n", pid);
-       asprintf(&init, LXCPATH "/%s/init", name);
+       if (!asprintf(&val, "%d\n", pid)) {
+               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);
        if (fd < 0) {
                lxc_log_syserror("failed to open '%s'", init);
index 051e70c2463e0e3fc3b67d201df917ed95394820..de355af632bb4361ebb6f1eb17e31618083ef1d4 100644 (file)
@@ -427,7 +427,10 @@ int lxc_start(const char *name, char *argv[])
                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);