From 8e21cf3bcce18579d38f85818e0e172751a04859 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 19 Apr 2015 17:44:29 +0200 Subject: [PATCH] isl_tab_compute_reduced_basis: only print error message on actual non-solution The original assert hints that the error is caused by an unexpected unboundedness, but the called function may also fail due to a failed memory allocation or because the computation has exceeded the maximal number of operations. In these latter cases, no (additional) error message should be printed. Signed-off-by: Sven Verdoolaege --- basis_reduction_tab.c | 5 ++++- basis_reduction_templ.c | 17 ++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/basis_reduction_tab.c b/basis_reduction_tab.c index 112d423d..cd975485 100644 --- a/basis_reduction_tab.c +++ b/basis_reduction_tab.c @@ -181,8 +181,11 @@ static int solve_lp(struct tab_lp *lp) isl_vec_free(sample); } isl_int_divexact_ui(lp->opt_denom, lp->opt_denom, 2); - if (res != isl_lp_ok) + if (res < 0) return -1; + if (res != isl_lp_ok) + isl_die(lp->ctx, isl_error_internal, + "unexpected missing (bounded) solution", return -1); return 0; } diff --git a/basis_reduction_templ.c b/basis_reduction_templ.c index 98d81413..4ce2d789 100644 --- a/basis_reduction_templ.c +++ b/basis_reduction_templ.c @@ -51,7 +51,6 @@ struct isl_tab *isl_tab_compute_reduced_basis(struct isl_tab *tab) unsigned dim; struct isl_ctx *ctx; struct isl_mat *B; - int unbounded; int i; GBR_LP *lp = NULL; GBR_type F_old, alpha, F_new; @@ -133,8 +132,8 @@ struct isl_tab *isl_tab_compute_reduced_basis(struct isl_tab *tab) GBR_lp_set_obj(lp, B->row[1+i]+1, dim); ctx->stats->gbr_solved_lps++; - unbounded = GBR_lp_solve(lp); - isl_assert(ctx, !unbounded, goto error); + if (GBR_lp_solve(lp) < 0) + goto error; GBR_lp_get_obj_val(lp, &F[i]); if (GBR_lt(F[i], one)) { @@ -151,8 +150,8 @@ struct isl_tab *isl_tab_compute_reduced_basis(struct isl_tab *tab) if (i+1 == tab->n_zero) { GBR_lp_set_obj(lp, B->row[1+i+1]+1, dim); ctx->stats->gbr_solved_lps++; - unbounded = GBR_lp_solve(lp); - isl_assert(ctx, !unbounded, goto error); + if (GBR_lp_solve(lp) < 0) + goto error; GBR_lp_get_obj_val(lp, &F_new); fixed = GBR_lp_is_fixed(lp); GBR_set_ui(alpha, 0); @@ -166,8 +165,8 @@ struct isl_tab *isl_tab_compute_reduced_basis(struct isl_tab *tab) row = GBR_lp_add_row(lp, B->row[1+i]+1, dim); GBR_lp_set_obj(lp, B->row[1+i+1]+1, dim); ctx->stats->gbr_solved_lps++; - unbounded = GBR_lp_solve(lp); - isl_assert(ctx, !unbounded, goto error); + if (GBR_lp_solve(lp) < 0) + goto error; GBR_lp_get_obj_val(lp, &F_new); fixed = GBR_lp_is_fixed(lp); @@ -196,8 +195,8 @@ struct isl_tab *isl_tab_compute_reduced_basis(struct isl_tab *tab) tmp, B->row[1+i]+1, dim); GBR_lp_set_obj(lp, b_tmp->el, dim); ctx->stats->gbr_solved_lps++; - unbounded = GBR_lp_solve(lp); - isl_assert(ctx, !unbounded, goto error); + if (GBR_lp_solve(lp) < 0) + goto error; GBR_lp_get_obj_val(lp, &mu_F[j]); mu_fixed[j] = GBR_lp_is_fixed(lp); if (i > 0) -- 2.11.4.GIT