]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
correct error reporting for lxc_setstate
authorMichel Normand <normand@fr.ibm.com>
Mon, 18 May 2009 20:27:35 +0000 (22:27 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Mon, 18 May 2009 20:27:35 +0000 (22:27 +0200)
there was a missing init of local variable

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Michel Normand <normand@fr.ibm.com>
src/lxc/state.c

index 0fad79279a8615f2f14d92047949e82b813af324..511b1bfe1447e8f9308114bc3d04120d97e31d3d 100644 (file)
@@ -62,19 +62,19 @@ lxc_state_t lxc_str2state(const char *state)
 
 int lxc_setstate(const char *name, lxc_state_t state)
 {
-       int fd, err;
+       int fd, err = -1;
        char file[MAXPATHLEN];
        const char *str = lxc_state2str(state);
 
        if (!str)
-               return -1;
+               return err;
 
        snprintf(file, MAXPATHLEN, LXCPATH "/%s/state", name);
 
        fd = open(file, O_WRONLY);
        if (fd < 0) {
                SYSERROR("failed to open %s file", file);
-               return -1;
+               return err;
        }
 
        if (flock(fd, LOCK_EX)) {
@@ -98,7 +98,7 @@ out:
 
        lxc_monitor_send_state(name, state);
 
-       return -err;
+       return err;
 }
 
 int lxc_mkstate(const char *name)