]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
correct asprintf error checking
authorNathan Lynch <ntl@pobox.com>
Wed, 19 May 2010 20:15:28 +0000 (22:15 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Wed, 19 May 2010 20:15:28 +0000 (22:15 +0200)
asprintf(3) returns -1 (not 0) on error.

Signed-off-by: Nathan Lynch <ntl@pobox.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lxc_execute.c
src/lxc/lxc_restart.c
src/lxc/lxc_start.c

index b9020b40cc87334ae62328eb756508bf4f1067de..669d383050d78cc3ae2fac934fa51887a607129b 100644 (file)
@@ -108,7 +108,10 @@ int main(int argc, char *argv[])
        if (my_args.rcfile)
                rcfile = (char *)my_args.rcfile;
        else {
-               if (!asprintf(&rcfile, LXCPATH "/%s/config", my_args.name)) {
+               int rc;
+
+               rc = asprintf(&rcfile, LXCPATH "/%s/config", my_args.name);
+               if (rc == -1) {
                        SYSERROR("failed to allocate memory");
                        return -1;
                }
index e44bd1b54eee3d13f0dba7d11eee9638bb024059..f715a609d7e4d702080865f668b1f766538dd133 100644 (file)
@@ -126,7 +126,10 @@ int main(int argc, char *argv[])
        if (my_args.rcfile)
                rcfile = (char *)my_args.rcfile;
        else {
-               if (!asprintf(&rcfile, LXCPATH "/%s/config", my_args.name)) {
+               int rc;
+
+               rc = asprintf(&rcfile, LXCPATH "/%s/config", my_args.name);
+               if (rc == -1) {
                        SYSERROR("failed to allocate memory");
                        return -1;
                }
index 5cc03db041e477bcc5fada792c598b902a76c796..7aa17ff61743f64b8f6e00da98241614ae2c5474 100644 (file)
@@ -117,7 +117,10 @@ int main(int argc, char *argv[])
        if (my_args.rcfile)
                rcfile = (char *)my_args.rcfile;
        else {
-               if (!asprintf(&rcfile, LXCPATH "/%s/config", my_args.name)) {
+               int rc;
+
+               rc = asprintf(&rcfile, LXCPATH "/%s/config", my_args.name);
+               if (rc == -1) {
                        SYSERROR("failed to allocate memory");
                        return err;
                }