[gnumeric] compilation: avoid more NULL-checks before functions that handle NULL fine.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] compilation: avoid more NULL-checks before functions that handle NULL fine.
- Date: Mon, 2 Nov 2009 19:31:15 +0000 (UTC)
commit 97a7a11f476d63b4e9f0c604c579c36a7cef14fb
Author: Morten Welinder <terra gnome org>
Date: Mon Nov 2 14:30:41 2009 -0500
compilation: avoid more NULL-checks before functions that handle NULL fine.
plugins/excel/ms-excel-read.c | 2 +-
plugins/excel/xlsx-read.c | 6 +---
plugins/fn-eng/functions.c | 6 +---
plugins/fn-lookup/functions.c | 7 ++---
plugins/fn-string/functions.c | 3 +-
plugins/fn-tsa/functions.c | 15 ++++---------
plugins/openoffice/openoffice-read.c | 6 +---
plugins/plan-perfect/pln.c | 3 +-
src/cell.c | 9 ++-----
src/clipboard.c | 7 ++---
src/collect.c | 5 +--
src/commands.c | 2 +-
src/dialogs/dialog-analysis-tools.c | 17 ++++++---------
src/dialogs/dialog-cell-sort.c | 9 ++-----
src/dialogs/dialog-goal-seek.c | 13 +++--------
src/dialogs/dialog-random-generator.c | 2 +-
src/dialogs/dialog-solver.c | 3 +-
src/expr.c | 27 ++++++++----------------
src/func-builtin.c | 3 +-
src/graph.c | 36 +++++++++++----------------------
src/preview-grid.c | 6 +---
src/sheet-filter.c | 12 ++++------
src/sheet.c | 5 +--
src/tools/analysis-anova.c | 3 +-
src/tools/analysis-chi-squared.c | 3 +-
src/tools/analysis-kaplan-meier.c | 6 +---
src/tools/analysis-tools.c | 6 +---
src/tools/random-generator-cor.c | 3 +-
src/tools/random-generator.c | 3 +-
src/value.c | 9 ++-----
src/wbc-gtk-edit.c | 6 ++--
src/widgets/gnumeric-expr-entry.c | 2 +-
tools/check-gfrees | 17 +++++++++++----
33 files changed, 100 insertions(+), 162 deletions(-)
---
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index b4831ef..b22550b 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -5690,7 +5690,7 @@ excel_read_AUTOFILTER (BiffQuery *q, ExcelReadSheet *esheet)
if (op1 == GNM_FILTER_UNUSED) {
cond = gnm_filter_condition_new_single (op0, v0);
- if (v1 != NULL) value_release (v1); /* paranoia */
+ value_release (v1); /* paranoia */
} else {
/* NOTE : Docs are backwards */
cond = gnm_filter_condition_new_double (
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 2b0b8ab..ec8ad32 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -2666,8 +2666,7 @@ xlsx_cell_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
if (NULL == cell) {
xlsx_warning (xin, _("Invalid cell %s"),
cellpos_as_string (&state->pos));
- if (NULL != state->val)
- value_release (state->val);
+ value_release (state->val);
if (NULL != state->texpr)
gnm_expr_top_unref (state->texpr);
} else if (NULL != state->texpr) {
@@ -5168,8 +5167,7 @@ xlsx_file_open (GOFileOpener const *fo, GOIOContext *context,
while (i-- > 0) {
entry = &g_array_index (state.sst, XLSXStr, i);
go_string_unref (entry->str);
- if (NULL != entry->markup)
- go_format_unref (entry->markup);
+ go_format_unref (entry->markup);
}
g_array_free (state.sst, TRUE);
}
diff --git a/plugins/fn-eng/functions.c b/plugins/fn-eng/functions.c
index bbcee98..5b7f1a5 100644
--- a/plugins/fn-eng/functions.c
+++ b/plugins/fn-eng/functions.c
@@ -96,8 +96,7 @@ val_to_base (GnmFuncEvalInfo *ei,
(value_peek_string (value), NULL,
workbook_date_conv (ei->pos->sheet->workbook));
if (!vstring || !VALUE_IS_FLOAT (vstring)) {
- if (vstring)
- value_release (vstring);
+ value_release (vstring);
return value_new_error_VALUE (ei->pos);
}
} else {
@@ -142,8 +141,7 @@ val_to_base (GnmFuncEvalInfo *ei,
char buf[GNM_MANT_DIG + 10];
char *err;
- if (vstring)
- value_release (vstring);
+ value_release (vstring);
if (val < min_value || val > max_value)
return value_new_error_NUM (ei->pos);
diff --git a/plugins/fn-lookup/functions.c b/plugins/fn-lookup/functions.c
index 4b84b8e..3a3e568 100644
--- a/plugins/fn-lookup/functions.c
+++ b/plugins/fn-lookup/functions.c
@@ -334,7 +334,7 @@ get_linear_lookup_cache (GnmFuncEvalInfo *ei,
(GEqualFunc)gnm_float_equal);
if (!key_copy) key_copy = value_dup (key);
g_hash_table_insert (*cache, key_copy, h);
- } else if (key_copy)
+ } else
value_release (key_copy);
return h;
@@ -403,7 +403,7 @@ get_bisection_lookup_cache (GnmFuncEvalInfo *ei,
h = g_new0 (LookupBisectionCacheItem, 1);
if (!key_copy) key_copy = value_dup (key);
g_hash_table_insert (*cache, key_copy, h);
- } else if (key_copy)
+ } else
value_release (key_copy);
return h;
@@ -1124,8 +1124,7 @@ gnumeric_lookup (GnmFuncEvalInfo *ei, GnmValue const * const *args)
} else
result = value_new_error_NA (ei->pos);
- if (xlookup)
- value_release (xlookup);
+ value_release (xlookup);
return result;
}
diff --git a/plugins/fn-string/functions.c b/plugins/fn-string/functions.c
index 819bc20..b2730b7 100644
--- a/plugins/fn-string/functions.c
+++ b/plugins/fn-string/functions.c
@@ -956,8 +956,7 @@ gnumeric_text (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
res = value_new_error_VALUE (ei->pos);
}
- if (match != NULL)
- value_release (match);
+ value_release (match);
return res;
}
diff --git a/plugins/fn-tsa/functions.c b/plugins/fn-tsa/functions.c
index 7b7b30d..c8a17e7 100644
--- a/plugins/fn-tsa/functions.c
+++ b/plugins/fn-tsa/functions.c
@@ -524,10 +524,8 @@ gnumeric_interpolation (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
g_slist_free (missing1);
g_free (vals0);
g_free (vals1);
- for (i = 0; i < nb; i++) {
- if (values[i])
- value_release (values[i]);
- }
+ for (i = 0; i < nb; i++)
+ value_release (values[i]);
return value_new_error_VALUE (ei->pos);
}
} else
@@ -560,8 +558,7 @@ gnumeric_interpolation (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (n0 != n1 || n0 == 0 || n2 <= 0) {
res = value_new_error_std (ei->pos, GNM_ERROR_VALUE);
for (i = 0; i < nb; i++)
- if (values[i])
- value_release (values[i]);
+ value_release (values[i]);
} else {
if (missing0 || missing1) {
GSList *missing ;
@@ -597,8 +594,7 @@ gnumeric_interpolation (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (!go_range_increasing (vals0, n0) || n2==0) {
res = value_new_error_std (ei->pos, GNM_ERROR_VALUE);
for (i = 0; i < nb; i++)
- if (values[i])
- value_release (values[i]);
+ value_release (values[i]);
g_free (values);
g_free (vals0);
g_free (vals1);
@@ -624,8 +620,7 @@ gnumeric_interpolation (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
for( r = 0 ; r < nb; ++r)
res->v_array.vals[0][r] = value_new_error_std (ei->pos, GNM_ERROR_VALUE);
for (i = 0; i < nb; i++)
- if (values[i])
- value_release (values[i]);
+ value_release (values[i]);
}
}
g_free (values);
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index ab38d7a..967df6a 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1260,8 +1260,7 @@ oo_cell_start (GsfXMLIn *xin, xmlChar const **attrs)
state->pos.eval.row >= max_rows) {
if (texpr)
gnm_expr_top_unref (texpr);
- if (val)
- value_release (val);
+ value_release (val);
if (style)
gnm_style_unref (style);
return;
@@ -3174,8 +3173,7 @@ oo_filter_cond (GsfXMLIn *xin, xmlChar const **attrs)
v->v_float.val);
break;
}
- if (NULL != v)
- value_release (v);
+ value_release (v);
if (NULL != cond)
gnm_filter_set_condition (state->filter, field_num, cond, FALSE);
}
diff --git a/plugins/plan-perfect/pln.c b/plugins/plan-perfect/pln.c
index 01633ad..293402f 100644
--- a/plugins/plan-perfect/pln.c
+++ b/plugins/plan-perfect/pln.c
@@ -630,8 +630,7 @@ pln_parse_sheet (GsfInput *input, PlanPerfectImport *state)
gnm_conventions_default,
NULL);
if (texpr == NULL) {
- if (v != NULL)
- value_release (v);
+ value_release (v);
v = value_new_string_nocopy (expr_txt);
} else
g_free (expr_txt);
diff --git a/src/cell.c b/src/cell.c
index 0b643a9..9f2bc77 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -58,10 +58,8 @@ gnm_cell_cleanout (GnmCell *cell)
cell->base.texpr = NULL;
}
- if (cell->value != NULL) {
- value_release (cell->value);
- cell->value = NULL;
- }
+ value_release (cell->value);
+ cell->value = NULL;
gnm_cell_unrender (cell);
@@ -130,8 +128,7 @@ gnm_cell_assign_value (GnmCell *cell, GnmValue *v)
g_return_if_fail (cell);
g_return_if_fail (v);
- if (cell->value != NULL)
- value_release (cell->value);
+ value_release (cell->value);
cell->value = v;
}
diff --git a/src/clipboard.c b/src/clipboard.c
index 6853e13..db889ce 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -996,10 +996,9 @@ gnm_cell_copy_free (GnmCellCopy *cc)
gnm_expr_top_unref (cc->texpr);
cc->texpr = NULL;
}
- if (cc->val) {
- value_release (cc->val);
- cc->val = NULL;
- }
+ value_release (cc->val);
+ cc->val = NULL;
+
CHUNK_FREE (cell_copy_pool, cc);
}
diff --git a/src/collect.c b/src/collect.c
index 3ae8d40..415d470 100644
--- a/src/collect.c
+++ b/src/collect.c
@@ -41,8 +41,7 @@ static void
single_floats_cache_entry_free (SingleFloatsCacheEntry *entry)
{
value_release (entry->value);
- if (entry->error)
- value_release (entry->error);
+ value_release (entry->error);
g_free (entry->data);
g_free (entry);
}
@@ -419,7 +418,7 @@ collect_floats (int argc, GnmExprConstPtr const *argv,
ce->value = key;
ce->flags = keyflags;
ce->n = *n;
- ce->error = *error ? value_dup (*error) : NULL;
+ ce->error = value_dup (*error);
if (cl.data == NULL)
ce->data = NULL;
else if (constp) {
diff --git a/src/commands.c b/src/commands.c
index 548ee9e..7aa60f4 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -3955,7 +3955,7 @@ cmd_search_replace_do_cell (CmdSearchReplace *me, GnmEvalPos *ep,
*/
err = val && gnm_expr_char_start_p (cell_res.new_text);
- if (val) value_release (val);
+ value_release (val);
if (texpr) gnm_expr_top_unref (texpr);
if (err) {
diff --git a/src/dialogs/dialog-analysis-tools.c b/src/dialogs/dialog-analysis-tools.c
index 7d4c7e0..1d2352e 100644
--- a/src/dialogs/dialog-analysis-tools.c
+++ b/src/dialogs/dialog-analysis-tools.c
@@ -1405,8 +1405,8 @@ ttest_update_sensitivity_cb (G_GNUC_UNUSED GtkWidget *dummy,
input_2_ready = ((state->base.input_entry_2 == NULL) || (input_range_2 != NULL));
output_ready = gnm_dao_is_ready (GNM_DAO (state->base.gdao));
- if (input_range != NULL) value_release (input_range);
- if (input_range_2 != NULL) value_release (input_range_2);
+ value_release (input_range);
+ value_release (input_range_2);
ready = input_1_ready && input_2_ready && output_ready && alpha_ready && mean_diff_ready;
gtk_widget_set_sensitive (state->base.ok_button, ready);
@@ -1725,8 +1725,8 @@ ftest_update_sensitivity_cb (G_GNUC_UNUSED GtkWidget *dummy,
input_2_ready = ((state->base.input_entry_2 == NULL) || (input_range_2 != NULL));
output_ready = gnm_dao_is_ready (GNM_DAO (state->base.gdao));
- if (input_range != NULL) value_release (input_range);
- if (input_range_2 != NULL) value_release (input_range_2);
+ value_release (input_range);
+ value_release (input_range_2);
ready = input_1_ready && input_2_ready && output_ready && alpha_ready;
gtk_widget_set_sensitive (state->base.ok_button, ready);
@@ -2155,10 +2155,8 @@ regression_tool_ok_clicked_cb (G_GNUC_UNUSED GtkWidget *button,
GTK_WIDGET (state->base.input_entry), text);
g_free (text);
- if (data->base.range_1)
- value_release (data->base.range_1);
- if (data->base.range_2)
- value_release (data->base.range_2);
+ value_release (data->base.range_1);
+ value_release (data->base.range_2);
g_free (dao);
g_free (data);
} else
@@ -3508,8 +3506,7 @@ anova_two_factor_tool_ok_clicked_cb (G_GNUC_UNUSED GtkWidget *button,
g_free (text);
break;
}
- if (data->input)
- value_release (data->input);
+ value_release (data->input);
g_free (dao);
g_free (data);
} else
diff --git a/src/dialogs/dialog-cell-sort.c b/src/dialogs/dialog-cell-sort.c
index 81ca96f..475fbaa 100644
--- a/src/dialogs/dialog-cell-sort.c
+++ b/src/dialogs/dialog-cell-sort.c
@@ -389,8 +389,7 @@ translate_range (GnmValue *range, SortFlowState *state)
state->header = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (state->cell_sort_header_check));
- if (state->sel != NULL)
- value_release (state->sel);
+ value_release (state->sel);
state->sel = range;
load_model_data(state);
}
@@ -431,10 +430,8 @@ cb_update_sensitivity (SortFlowState *state)
static void
cb_dialog_destroy (SortFlowState *state)
{
- if (state->sel) {
- value_release (state->sel);
- state->sel = NULL;
- }
+ value_release (state->sel);
+ state->sel = NULL;
if (state->model != NULL)
g_object_unref (G_OBJECT (state->model));
diff --git a/src/dialogs/dialog-goal-seek.c b/src/dialogs/dialog-goal-seek.c
index 401e2e3..d5536f8 100644
--- a/src/dialogs/dialog-goal-seek.c
+++ b/src/dialogs/dialog-goal-seek.c
@@ -270,8 +270,7 @@ cb_dialog_destroy (GoalSeekState *state)
state->old_value = NULL;
}
- if (state->old_value != NULL)
- value_release (state->old_value);
+ value_release (state->old_value);
if (state->gui != NULL)
g_object_unref (G_OBJECT (state->gui));
@@ -403,8 +402,7 @@ cb_dialog_apply_clicked (G_GNUC_UNUSED GtkWidget *button,
state->old_value = NULL;
}
state->old_cell = state->change_cell;
- state->old_value = state->change_cell->value ?
- value_dup (state->change_cell->value) : NULL;
+ state->old_value = value_dup (state->change_cell->value);
status = gnumeric_goal_seek (state);
@@ -613,9 +611,7 @@ dialog_goal_seek_test (Sheet *sheet, const GnmRange *range)
state.set_cell = sheet_cell_fetch (sheet, c + 0, r);
state.change_cell = sheet_cell_fetch (sheet, c + 1, r);
- state.old_value = state.change_cell->value
- ? value_dup (state.change_cell->value)
- : NULL;
+ state.old_value = value_dup (state.change_cell->value);
cell = sheet_cell_fetch (sheet, c + 2, r);
state.target_value = value_get_as_float (cell->value);
@@ -638,8 +634,7 @@ dialog_goal_seek_test (Sheet *sheet, const GnmRange *range)
value_new_error_VALUE (NULL));
}
- if (state.old_value)
- value_release (state.old_value);
+ value_release (state.old_value);
}
/**
diff --git a/src/dialogs/dialog-random-generator.c b/src/dialogs/dialog-random-generator.c
index 4e71cf7..1e350c0 100644
--- a/src/dialogs/dialog-random-generator.c
+++ b/src/dialogs/dialog-random-generator.c
@@ -398,7 +398,7 @@ random_tool_update_sensitivity_cb (G_GNUC_UNUSED GtkWidget *dummy,
disc_prob_range = gnm_expr_entry_parse_as_value
(GNM_EXPR_ENTRY (state->par1_expr_entry), state->base.sheet);
ready = ready && disc_prob_range != NULL;
- if (disc_prob_range != NULL) value_release (disc_prob_range);
+ value_release (disc_prob_range);
break;
case UniformIntDistribution:
ready = ready &&
diff --git a/src/dialogs/dialog-solver.c b/src/dialogs/dialog-solver.c
index 2371c82..d765777 100644
--- a/src/dialogs/dialog-solver.c
+++ b/src/dialogs/dialog-solver.c
@@ -608,8 +608,7 @@ solver_add_scenario (SolverState *state, SolverResults *res, gchar const *name)
value_peek_string (gnm_solver_param_get_input (param)),
comment, state->sheet, &scenario);
scenario_add (state->sheet, scenario);
- if (input_range != NULL)
- value_release (input_range);
+ value_release (input_range);
}
/**
diff --git a/src/expr.c b/src/expr.c
index b52ec5b..7541795 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -492,8 +492,7 @@ gnm_expr_free (GnmExpr const *expr)
break;
case GNM_EXPR_OP_ARRAY_CORNER:
- if (expr->array_corner.value)
- value_release (expr->array_corner.value);
+ value_release (expr->array_corner.value);
gnm_expr_free (expr->array_corner.expr);
CHUNK_FREE (expression_pool_big, (gpointer)expr);
break;
@@ -1008,8 +1007,7 @@ bin_array_iter_a (GnmEvalPos const *ep,
}
value_release (a);
- if (b != NULL)
- value_release (b);
+ value_release (b);
return iter_info.res;
}
@@ -1041,8 +1039,7 @@ bin_array_iter_b (GnmEvalPos const *ep,
value_area_get_height (b, ep));
value_area_foreach (b, ep, CELL_ITER_ALL,
(GnmValueIterFunc) cb_implicit_iter_b_to_scalar_a, &iter_info);
- if (a != NULL)
- value_release (a);
+ value_release (a);
value_release (b);
return iter_info.res;
@@ -1114,8 +1111,7 @@ cb_iter_percentage (GnmValueIter const *v_iter, GnmValue *res)
} else
tmp = value_new_error_VALUE (v_iter->ep);
- if (conv != NULL)
- value_release (conv);
+ value_release (conv);
}
res->v_array.vals[v_iter->x][v_iter->y] = tmp;
@@ -1212,8 +1208,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
b = gnm_expr_eval (expr->binary.value_b, pos, flags);
if (b != NULL) {
if (VALUE_IS_ERROR (b)) {
- if (a != NULL)
- value_release (a);
+ value_release (a);
return b;
}
if (b->type == VALUE_CELLRANGE || b->type == VALUE_ARRAY)
@@ -1223,10 +1218,8 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
}
res = bin_cmp (GNM_EXPR_GET_OPER (expr), value_compare (a, b, FALSE), pos);
- if (a != NULL)
- value_release (a);
- if (b != NULL)
- value_release (b);
+ value_release (a);
+ value_release (b);
return res;
case GNM_EXPR_OP_ADD:
@@ -1372,8 +1365,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
b = gnm_expr_eval (expr->binary.value_b, pos, flags);
if (b != NULL) {
if (VALUE_IS_ERROR (b)) {
- if (a != NULL)
- value_release (a);
+ value_release (a);
return b;
}
if (b->type == VALUE_CELLRANGE || b->type == VALUE_ARRAY)
@@ -1468,8 +1460,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
a = gnm_expr_eval (expr->array_corner.expr, &range_pos,
flags | GNM_EXPR_EVAL_PERMIT_NON_SCALAR);
- if (expr->array_corner.value)
- value_release (expr->array_corner.value);
+ value_release (expr->array_corner.value);
/* Store real result (cast away const)*/
((GnmExpr*)expr)->array_corner.value = a;
diff --git a/src/func-builtin.c b/src/func-builtin.c
index d8b38df..3cd174d 100644
--- a/src/func-builtin.c
+++ b/src/func-builtin.c
@@ -326,8 +326,7 @@ gnumeric_if2 (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
res = gnumeric_if (ei, (GnmValue const * const *)args);
for (i = 0; i <= 2; i++)
- if (args[i])
- value_release (args[i]);
+ value_release (args[i]);
return res;
}
diff --git a/src/graph.c b/src/graph.c
index b826955..3478ac2 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -334,10 +334,8 @@ gnm_go_data_scalar_eval (GnmDependent *dep)
{
GnmGODataScalar *scalar = DEP_TO_SCALAR (dep);
- if (scalar->val != NULL) {
- value_release (scalar->val);
- scalar->val = NULL;
- }
+ value_release (scalar->val);
+ scalar->val = NULL;
g_free (scalar->val_str);
scalar->val_str = NULL;
go_data_emit_changed (GO_DATA (scalar));
@@ -349,10 +347,8 @@ gnm_go_data_scalar_finalize (GObject *obj)
GnmGODataScalar *scalar = (GnmGODataScalar *)obj;
dependent_set_expr (&scalar->dep, NULL);
- if (scalar->val != NULL) {
- value_release (scalar->val);
- scalar->val = NULL;
- }
+ value_release (scalar->val);
+ scalar->val = NULL;
g_free (scalar->val_str);
scalar->val_str = NULL;
@@ -446,10 +442,8 @@ gnm_go_data_vector_eval (GnmDependent *dep)
{
GnmGODataVector *vec = DEP_TO_VECTOR (dep);
- if (vec->val != NULL) {
- value_release (vec->val);
- vec->val = NULL;
- }
+ value_release (vec->val);
+ vec->val = NULL;
go_data_emit_changed (GO_DATA (vec));
}
@@ -459,10 +453,8 @@ gnm_go_data_vector_finalize (GObject *obj)
GnmGODataVector *vec = (GnmGODataVector *)obj;
dependent_set_expr (&vec->dep, NULL);
- if (vec->val != NULL) {
- value_release (vec->val);
- vec->val = NULL;
- }
+ value_release (vec->val);
+ vec->val = NULL;
g_free (vec->base.values);
vec->base.values = NULL;
@@ -801,10 +793,8 @@ gnm_go_data_matrix_eval (GnmDependent *dep)
{
GnmGODataMatrix *mat = DEP_TO_MATRIX (dep);
- if (mat->val != NULL) {
- value_release (mat->val);
- mat->val = NULL;
- }
+ value_release (mat->val);
+ mat->val = NULL;
go_data_emit_changed (GO_DATA (mat));
}
@@ -814,10 +804,8 @@ gnm_go_data_matrix_finalize (GObject *obj)
GnmGODataMatrix *mat = (GnmGODataMatrix *)obj;
dependent_set_expr (&mat->dep, NULL);
- if (mat->val != NULL) {
- value_release (mat->val);
- mat->val = NULL;
- }
+ value_release (mat->val);
+ mat->val = NULL;
g_free (mat->base.values);
mat->base.values = NULL;
diff --git a/src/preview-grid.c b/src/preview-grid.c
index 03694c3..00224a6 100644
--- a/src/preview-grid.c
+++ b/src/preview-grid.c
@@ -355,10 +355,8 @@ preview_grid_dispose (GObject *obj)
gnm_style_unref (pg->defaults.style);
pg->defaults.style = NULL;
}
- if (pg->defaults.value != NULL) {
- value_release (pg->defaults.value);
- pg->defaults.value = NULL;
- }
+ value_release (pg->defaults.value);
+ pg->defaults.value = NULL;
if (pg->sheet) {
g_object_unref (pg->sheet);
diff --git a/src/sheet-filter.c b/src/sheet-filter.c
index 69ffc8e..9514794 100644
--- a/src/sheet-filter.c
+++ b/src/sheet-filter.c
@@ -117,10 +117,8 @@ gnm_filter_condition_free (GnmFilterCondition *cond)
if (cond == NULL)
return;
- if (cond->value[0] != NULL)
- value_release (cond->value[0]);
- if (cond->value[1] != NULL)
- value_release (cond->value[1]);
+ value_release (cond->value[0]);
+ value_release (cond->value[1]);
g_free (cond);
}
@@ -163,10 +161,10 @@ filter_expr_init (FilterExpr *fexpr, unsigned i,
static void
filter_expr_release (FilterExpr *fexpr, unsigned i)
{
- if (fexpr->val[i] != NULL)
- value_release (fexpr->val[i]);
- else
+ if (fexpr->val[i] == NULL)
go_regfree (fexpr->regexp + i);
+ else
+ value_release (fexpr->val[i]);
}
static gboolean
diff --git a/src/sheet.c b/src/sheet.c
index 38b3a16..cda4327 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -2460,9 +2460,8 @@ sheet_range_set_text (GnmParsePos const *pos, GnmRange const *r, char const *str
sheet_region_queue_recalc (pos->sheet, r);
- if (closure.val)
- value_release (closure.val);
- else
+ value_release (closure.val);
+ if (closure.texpr)
gnm_expr_top_unref (closure.texpr);
sheet_flag_status_update_range (pos->sheet, r);
diff --git a/src/tools/analysis-anova.c b/src/tools/analysis-anova.c
index 069f9ee..1a1e527 100644
--- a/src/tools/analysis-anova.c
+++ b/src/tools/analysis-anova.c
@@ -817,8 +817,7 @@ analysis_tool_anova_two_factor_engine_clean (G_GNUC_UNUSED data_analysis_output_
{
analysis_tools_data_anova_two_factor_t *info = specs;
- if (info->input)
- value_release (info->input);
+ value_release (info->input);
info->input = NULL;
return FALSE;
diff --git a/src/tools/analysis-chi-squared.c b/src/tools/analysis-chi-squared.c
index 14825ef..4d7c9f5 100644
--- a/src/tools/analysis-chi-squared.c
+++ b/src/tools/analysis-chi-squared.c
@@ -163,8 +163,7 @@ analysis_tool_chi_squared_clean (gpointer specs)
{
analysis_tools_data_chi_squared_t *info = specs;
- if (info->input)
- value_release (info->input);
+ value_release (info->input);
info->input = NULL;
return FALSE;
diff --git a/src/tools/analysis-kaplan-meier.c b/src/tools/analysis-kaplan-meier.c
index c1388e6..4274ce2 100644
--- a/src/tools/analysis-kaplan-meier.c
+++ b/src/tools/analysis-kaplan-meier.c
@@ -667,10 +667,8 @@ analysis_tool_kaplan_meier_engine (data_analysis_output_t *dao, gpointer specs,
- info->base.range_1->v_range.cell.a.row + 3);
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
- if (info->range_3) {
- value_release (info->range_3);
- info->range_3 = NULL;
- }
+ value_release (info->range_3);
+ info->range_3 = NULL;
g_slist_foreach (info->group_list, analysis_tool_kaplan_meier_clear_gl_cb, NULL);
g_slist_free (info->group_list);
info->group_list = NULL;
diff --git a/src/tools/analysis-tools.c b/src/tools/analysis-tools.c
index d817fba..14a83a9 100644
--- a/src/tools/analysis-tools.c
+++ b/src/tools/analysis-tools.c
@@ -3214,10 +3214,8 @@ analysis_tool_regression_engine_run (data_analysis_output_t *dao,
value_release (val_1);
value_release (val_2);
- if (val_1_cp)
- value_release (val_1_cp);
- if (val_2_cp)
- value_release (val_2_cp);
+ value_release (val_1_cp);
+ value_release (val_2_cp);
gnm_func_unref (fd_linest);
gnm_func_unref (fd_index);
diff --git a/src/tools/random-generator-cor.c b/src/tools/random-generator-cor.c
index 35f7968..cbd0f6e 100644
--- a/src/tools/random-generator-cor.c
+++ b/src/tools/random-generator-cor.c
@@ -124,8 +124,7 @@ tool_random_cor_clean (gpointer specs)
{
tools_data_random_cor_t *info = specs;
- if (info->matrix)
- value_release (info->matrix);
+ value_release (info->matrix);
info->matrix = NULL;
return FALSE;
diff --git a/src/tools/random-generator.c b/src/tools/random-generator.c
index da88268..5ca7819 100644
--- a/src/tools/random-generator.c
+++ b/src/tools/random-generator.c
@@ -67,8 +67,7 @@ tool_random_engine_run_discrete_clear_continuity (discrete_random_tool_local_t *
gint i;
for (i = 0; i < data->n; i++)
- if (data->values[i])
- value_release (data->values[i]);
+ value_release (data->values[i]);
g_free (data->cumul_p);
g_free (data->values);
g_free (data);
diff --git a/src/value.c b/src/value.c
index 14bef23..5be8d94 100644
--- a/src/value.c
+++ b/src/value.c
@@ -570,10 +570,8 @@ value_release (GnmValue *value)
int x, y;
for (x = 0; x < v->x; x++) {
- for (y = 0; y < v->y; y++) {
- if (v->vals[x][y])
- value_release (v->vals[x][y]);
- }
+ for (y = 0; y < v->y; y++)
+ value_release (v->vals[x][y]);
g_free (v->vals[x]);
}
@@ -1126,8 +1124,7 @@ value_array_set (GnmValue *array, int col, int row, GnmValue *v)
g_return_if_fail (array->v_array.y > row);
g_return_if_fail (array->v_array.x > col);
- if (array->v_array.vals[col][row] != NULL)
- value_release (array->v_array.vals[col][row]);
+ value_release (array->v_array.vals[col][row]);
array->v_array.vals[col][row] = v;
}
diff --git a/src/wbc-gtk-edit.c b/src/wbc-gtk-edit.c
index 11b70c5..4caeb20 100644
--- a/src/wbc-gtk-edit.c
+++ b/src/wbc-gtk-edit.c
@@ -138,10 +138,10 @@ wbcg_edit_finish (WBCGtk *wbcg, WBCEditResult result,
GnmValue *value = format_match (txt, fmt,
workbook_date_conv (sheet->workbook));
- if (value != NULL)
- value_release (value);
- else
+ if (value == NULL)
expr_txt = gnm_expr_char_start_p (txt);
+ else
+ value_release (value);
/* NOTE : do not modify gnm_expr_char_start_p to exclude "-"
* it _can_ start an expression, which is required for rangesel
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 26760e0..de35606 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -828,7 +828,7 @@ gee_data_editor_set_format (GogDataEditor *deditor, GOFormat const *fmt)
g_free (txt);
}
- if (v) value_release (v);
+ value_release (v);
}
static void
diff --git a/tools/check-gfrees b/tools/check-gfrees
index 76596bd..fb6ccf0 100644
--- a/tools/check-gfrees
+++ b/tools/check-gfrees
@@ -62,22 +62,29 @@ my %exceptions =
if ($lineno >= 2 &&
($lines[-2] . $lines[-1]) =~
- /^\s*if\s*\(\s*([^ ()]+)\s*(!=\s*NULL\s*)?\)\s*(g_free|g_list_free|g_slist_free|go_list_free_custom|go_slist_free_custom|go_format_unref)\s*\(\s*\1\s*\)\s*;/) {
- print STDERR "$0: Checked $3 at $filename:$lineno\n";
+ /^\s*if\s*\(\s*(NULL\s*!=\s*)?([^ ()]+)\s*(!=\s*NULL\s*)?\)\s*(g_free|g_list_free|g_slist_free|go_list_free_custom|go_slist_free_custom|go_format_unref|value_release)\s*\(\s*\2\s*\)\s*;/) {
+ print STDERR "$0: Checked $4 at $filename:$lineno\n";
next LINE;
}
if ($lineno >= 4 &&
($lines[-4] . $lines[-3] . $lines[-2] . $lines[-1] ) =~
- /^\s*if\s*\(\s*([^ ()]+)\s*(!=\s*NULL\s*)?\)\s*{\s*(g_free|g_list_free|g_slist_free|go_list_free_custom|go_slist_free_custom|go_format_unref)\s*\(\s*\1\s*\)\s*;\s*\1\s*=\s*(0|NULL)\s*;\s*}/) {
+ /^\s*if\s*\(\s*(NULL\s*!=\s*)?([^ ()]+)\s*(!=\s*NULL\s*)?\)\s*{\s*(g_free|g_list_free|g_slist_free|go_list_free_custom|go_slist_free_custom|go_format_unref|value_release)\s*\(\s*\2\s*\)\s*;\s*\2\s*=\s*(0|NULL)\s*;\s*}/) {
+ print STDERR "$0: Checked $4 at $filename:$lineno\n";
+ next LINE;
+ }
+
+ if ($lineno >= 3 &&
+ ($lines[-3] . $lines[-2] . $lines[-1]) =~
+ /^[^\n]*([^ ()]+)(\s*!=\s*NULL)?\s*\?\s*(g_strdup|value_dup)\s*\(\s*\1\s*\)\s*:\s*NULL/) {
print STDERR "$0: Checked $3 at $filename:$lineno\n";
next LINE;
}
if ($lineno >= 3 &&
($lines[-3] . $lines[-2] . $lines[-1]) =~
- /^[^\n]*([^ ()]+)\s*\?\s*g_strdup\s*\(\s*\1\s*\)\s*:\s*NULL/) {
- print STDERR "$0: Checked g_strdup at $filename:$lineno\n";
+ /^[^\n]*(\s*NULL\s*!=\s*)([^ ()]+)\s*\?\s*(g_strdup|value_dup)\s*\(\s*\2\s*\)\s*:\s*NULL/) {
+ print STDERR "$0: Checked $3 at $filename:$lineno\n";
next LINE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]