]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tree-wide: Sic semper assertis! 1376/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 4 Jan 2017 09:28:25 +0000 (10:28 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 4 Jan 2017 14:19:46 +0000 (15:19 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/console.c
src/lxc/criu.c
src/lxc/log.c
src/lxc/lxccontainer.c
src/lxc/tools/lxc_attach.c
src/lxc/utils.c

index 052512eb53506a9e02450362e9b112a3567d752a..908ead0af134342db4be2f0632f6baebb3bc79bb 100644 (file)
@@ -21,7 +21,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
@@ -577,7 +576,9 @@ int lxc_console_cb_tty_stdin(int fd, uint32_t events, void *cbdata,
        struct lxc_tty_state *ts = cbdata;
        char c;
 
-       assert(fd == ts->stdinfd);
+       if (fd != ts->stdinfd)
+               return 1;
+
        if (lxc_read_nointr(ts->stdinfd, &c, 1) <= 0)
                return 1;
 
@@ -607,7 +608,9 @@ int lxc_console_cb_tty_master(int fd, uint32_t events, void *cbdata,
        char buf[1024];
        int r, w;
 
-       assert(fd == ts->masterfd);
+       if (fd != ts->masterfd)
+               return 1;
+
        r = lxc_read_nointr(fd, buf, sizeof(buf));
        if (r <= 0)
                return 1;
index 125e67428dab8f0a8ee220bd89e1f082049707e6..53c368b2a34a85cff97e5cfabe7fb141c335a10f 100644 (file)
@@ -21,7 +21,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #define _GNU_SOURCE
-#include <assert.h>
 #include <inttypes.h>
 #include <linux/limits.h>
 #include <sched.h>
index 48c78b3d2961aa434a9af66b56d4cc3c788bb7e4..cdeec9f393630d09d5047b1f289dfe4484bac546 100644 (file)
@@ -23,7 +23,6 @@
 
 #define _GNU_SOURCE
 #define __STDC_FORMAT_MACROS /* Required for PRIu64 to work. */
-#include <assert.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <errno.h>
@@ -470,7 +469,8 @@ static int __lxc_log_set_file(const char *fname, int create_dirs)
                lxc_log_close();
        }
 
-       assert(fname != NULL);
+       if (!fname)
+               return -1;
 
        if (strlen(fname) == 0) {
                log_fname = NULL;
index d96d23eeddbe1d8bdef17904313f8e28c5137a92..2a376eb3c2aa212c4f17cdc09b60fe65e2cc08c0 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 #define _GNU_SOURCE
-#include <assert.h>
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -4319,7 +4318,7 @@ int list_active_containers(const char *lxcpath, char ***nret,
        char *line = NULL;
        char **ct_name = NULL;
        size_t len = 0;
-       struct lxc_container *c;
+       struct lxc_container *c = NULL;
        bool is_hashed;
 
        if (!lxcpath)
@@ -4402,7 +4401,12 @@ int list_active_containers(const char *lxcpath, char ***nret,
                cret_cnt++;
        }
 
-       assert(!nret || !cret || cret_cnt == ct_name_cnt);
+       if (nret && cret && cret_cnt != ct_name_cnt) {
+               if (c)
+                       lxc_container_put(c);
+               goto free_cret_list;
+       }
+
        ret = ct_name_cnt;
        if (nret)
                *nret = ct_name;
index 4dd38839ad3489477bfe232fea3c6d6f0db44e63..acc3dcfa2589d43e385c35c692e212f09d540a78 100644 (file)
@@ -23,7 +23,6 @@
 
 #include "config.h"
 
-#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
@@ -83,7 +82,8 @@ static int add_to_simple_array(char ***array, ssize_t *capacity, char *value)
 {
        ssize_t count = 0;
 
-       assert(array);
+       if (!array)
+               return -1;
 
        if (*array)
                for (; (*array)[count]; count++);
@@ -99,7 +99,8 @@ static int add_to_simple_array(char ***array, ssize_t *capacity, char *value)
                *capacity = new_capacity;
        }
 
-       assert(*array);
+       if (!(*array))
+               return -1;
 
        (*array)[count] = value;
        return 0;
index 7c2098e1a7df421d4e9c76c02a0b3f19fe8f1ea8..2a0f05a55806c43778c444af0ed34e27682426ca 100644 (file)
@@ -23,7 +23,6 @@
 
 #include "config.h"
 
-#include <assert.h>
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -639,10 +638,16 @@ char *lxc_string_replace(const char *needle, const char *replacement, const char
        /* make sure we did the same thing twice,
         * once for calculating length, the other
         * time for copying data */
-       assert(saved_len == len);
+       if (saved_len != len) {
+               free(result);
+               return NULL;
+       }
        /* make sure we didn't overwrite any buffer,
         * due to calloc the string should be 0-terminated */
-       assert(result[len] == '\0');
+       if (result[len] != '\0') {
+               free(result);
+               return NULL;
+       }
 
        return result;
 }