isl_convex_hull.c: uset_convex_hull_wrap_bounded: fix error handling
[platform/upstream/isl.git] / isl_coalesce.c
index 0a04a14..84a5a4b 100644 (file)
@@ -26,6 +26,7 @@ static int status_in(isl_int *ineq, struct isl_tab *tab)
 {
        enum isl_ineq_type type = isl_tab_ineq_type(tab, ineq);
        switch (type) {
+       default:
        case isl_ineq_error:            return STATUS_ERROR;
        case isl_ineq_redundant:        return STATUS_VALID;
        case isl_ineq_separate:         return STATUS_SEPARATE;
@@ -269,7 +270,8 @@ static int check_facets(struct isl_map *map, int i, int j,
        for (k = 0; k < map->p[i]->n_ineq; ++k) {
                if (ineq_i[k] != STATUS_CUT)
                        continue;
-               tabs[i] = isl_tab_select_facet(tabs[i], n_eq + k);
+               if (isl_tab_select_facet(tabs[i], n_eq + k) < 0)
+                       return -1;
                for (l = 0; l < map->p[j]->n_ineq; ++l) {
                        int stat;
                        if (ineq_j[l] != STATUS_CUT)
@@ -394,7 +396,8 @@ static int is_extension(struct isl_map *map, int i, int j, int k,
        snap = isl_tab_snap(tabs[i]);
        tabs[i] = isl_tab_relax(tabs[i], n_eq + k);
        snap2 = isl_tab_snap(tabs[i]);
-       tabs[i] = isl_tab_select_facet(tabs[i], n_eq + k);
+       if (isl_tab_select_facet(tabs[i], n_eq + k) < 0)
+               return -1;
        super = contains(map, j, ineq_j, tabs[i]);
        if (super) {
                if (isl_tab_rollback(tabs[i], snap2) < 0)
@@ -581,7 +584,8 @@ static int can_wrap_in_facet(struct isl_map *map, int i, int j, int k,
 
        snap = isl_tab_snap(tabs[i]);
 
-       tabs[i] = isl_tab_select_facet(tabs[i], map->p[i]->n_eq + k);
+       if (isl_tab_select_facet(tabs[i], map->p[i]->n_eq + k) < 0)
+               goto error;
        if (isl_tab_detect_redundant(tabs[i]) < 0)
                goto error;
 
@@ -699,8 +703,8 @@ static int wrap_in_facets(struct isl_map *map, int i, int j,
        wraps->n_row = 0;
 
        for (k = 0; k < n; ++k) {
-               tabs[i] = isl_tab_select_facet(tabs[i],
-                                               map->p[i]->n_eq + cuts[k]);
+               if (isl_tab_select_facet(tabs[i], map->p[i]->n_eq + cuts[k]) < 0)
+                       goto error;
                if (isl_tab_detect_redundant(tabs[i]) < 0)
                        goto error;
                set_is_redundant(tabs[i], map->p[i]->n_eq, cuts, n, k, 1);
@@ -718,7 +722,8 @@ static int wrap_in_facets(struct isl_map *map, int i, int j,
 
                isl_seq_cpy(bound->el, map->p[i]->ineq[cuts[k]], 1 + total);
                isl_int_add_ui(bound->el[0], bound->el[0], 1);
-               tabs[j] = isl_tab_add_eq(tabs[j], bound->el);
+               if (isl_tab_add_eq(tabs[j], bound->el) < 0)
+                       goto error;
                if (isl_tab_detect_redundant(tabs[j]) < 0)
                        goto error;
 
@@ -812,9 +817,7 @@ static int can_wrap_in_set(struct isl_map *map, int i, int j,
        struct isl_tab **tabs, int *eq_i, int *ineq_i, int *eq_j, int *ineq_j)
 {
        int changed = 0;
-       int k, l, m;
-       unsigned total = isl_basic_map_total_dim(map->p[i]);
-       struct isl_tab_undo *snap;
+       int k, m;
        int n;
        int *cuts = NULL;
 
@@ -1131,7 +1134,8 @@ struct isl_map *isl_map_coalesce(struct isl_map *map)
                if (!tabs[i])
                        goto error;
                if (!ISL_F_ISSET(map->p[i], ISL_BASIC_MAP_NO_IMPLICIT))
-                       tabs[i] = isl_tab_detect_implicit_equalities(tabs[i]);
+                       if (isl_tab_detect_implicit_equalities(tabs[i]) < 0)
+                               goto error;
                if (!ISL_F_ISSET(map->p[i], ISL_BASIC_MAP_NO_REDUNDANT))
                        if (isl_tab_detect_redundant(tabs[i]) < 0)
                                goto error;