Fix two warnings from Clang's static analyzer.
[tinc] / src / top.c
index 703391c..4db9304 100644 (file)
--- a/src/top.c
+++ b/src/top.c
@@ -108,7 +108,7 @@ static void update(int fd) {
                                found = ns;
                                break;
                        } else {
-                               found = xmalloc_and_zero(sizeof *found);
+                               found = xzalloc(sizeof *found);
                                found->name = xstrdup(name);
                                list_insert_before(&node_list, node, found);
                                changed = true;
@@ -117,7 +117,7 @@ static void update(int fd) {
                }
 
                if(!found) {
-                       found = xmalloc_and_zero(sizeof *found);
+                       found = xzalloc(sizeof *found);
                        found->name = xstrdup(name);
                        list_insert_tail(&node_list, found);
                        changed = true;
@@ -213,7 +213,8 @@ static void redraw(void) {
        for(int i = 0; i < n; i++)
                sorted[i]->i = i;
 
-       qsort(sorted, n, sizeof *sorted, sortfunc);
+       if(sorted)
+               qsort(sorted, n, sizeof *sorted, sortfunc);
 
        for(int i = 0, row = 3; i < n; i++, row++) {
                nodestats_t *node = sorted[i];