[gnumeric] Cleanup: don't NULL-test before go_format_unref.



commit 8fa0c6e386fb4f2a65bbb768a305ad617ed1049d
Author: Morten Welinder <terra gnome org>
Date:   Thu May 21 15:45:52 2009 -0400

    Cleanup: don't NULL-test before go_format_unref.
---
 plugins/excel/ms-excel-read.c |   10 ++++------
 plugins/xbase/xbase.c         |    3 +--
 src/sheet-autofill.c          |    6 ++----
 src/workbook-view.c           |    3 +--
 tools/ChangeLog               |    4 ++++
 tools/check-gfrees            |    4 ++--
 6 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 0eb834f..7e8cde3 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -2473,10 +2473,9 @@ excel_read_XF_INDEX (BiffQuery *q, ExcelReadSheet *esheet)
 static void
 biff_xf_data_destroy (BiffXFData *xf)
 {
-	if (xf->style_format) {
-		go_format_unref (xf->style_format);
-		xf->style_format = NULL;
-	}
+	go_format_unref (xf->style_format);
+	xf->style_format = NULL;
+
 	if (xf->mstyle) {
 		gnm_style_unref (xf->mstyle);
 		xf->mstyle = NULL;
@@ -3144,8 +3143,7 @@ gnm_xl_importer_free (GnmXLImporter *importer)
 		while (i-- > 0) {
 			if (importer->sst[i].content)
 				gnm_string_unref (importer->sst[i].content);
-			if (importer->sst[i].markup != NULL)
-				go_format_unref (importer->sst[i].markup);
+			go_format_unref (importer->sst[i].markup);
 		}
 		g_free (importer->sst);
 	}
diff --git a/plugins/xbase/xbase.c b/plugins/xbase/xbase.c
index 6ff4c3e..0242cb3 100644
--- a/plugins/xbase/xbase.c
+++ b/plugins/xbase/xbase.c
@@ -336,8 +336,7 @@ xbase_close (XBfile *x)
 
 	for (i = 0; i < x->fields; i++) {
 		XBfield *field = x->format[i];
-		if (field->fmt != NULL)
-			go_format_unref (field->fmt);
+		go_format_unref (field->fmt);
 		g_free (field);
 	}
 	gsf_iconv_close (x->char_map);
diff --git a/src/sheet-autofill.c b/src/sheet-autofill.c
index e94d5f3..3e4044a 100644
--- a/src/sheet-autofill.c
+++ b/src/sheet-autofill.c
@@ -144,8 +144,7 @@ static void
 afa_finalize (AutoFiller *af)
 {
 	AutoFillerArithmetic *afa = (AutoFillerArithmetic *)af;
-	if (afa->format)
-		go_format_unref (afa->format);
+	go_format_unref (afa->format);
 	af_finalize (af);
 }
 
@@ -527,8 +526,7 @@ static void
 afm_finalize (AutoFiller *af)
 {
 	AutoFillerMonth *afm = (AutoFillerMonth *)af;
-	if (afm->format)
-		go_format_unref (afm->format);
+	go_format_unref (afm->format);
 	af_finalize (af);
 }
 
diff --git a/src/workbook-view.c b/src/workbook-view.c
index f1d8621..f1e3543 100644
--- a/src/workbook-view.c
+++ b/src/workbook-view.c
@@ -513,8 +513,7 @@ wb_view_auto_expr_recalc (WorkbookView *wbv)
 		if (format) {
 			format_value_gstring (str, format, v, NULL,
 					      -1, workbook_date_conv (wb_view_get_workbook (wbv)));
-			if (tmp_format)
-				go_format_unref (tmp_format);
+			go_format_unref (tmp_format);
 		} else {
 			g_string_append (str, value_peek_string (v));
 		}
diff --git a/tools/ChangeLog b/tools/ChangeLog
index 5dafa7c..15f71ad 100644
--- a/tools/ChangeLog
+++ b/tools/ChangeLog
@@ -1,3 +1,7 @@
+2009-05-21  Morten Welinder  <terra gnome org>
+
+	* check-gfrees: Check go_format_unref too.
+
 2009-05-06  Morten Welinder <terra gnome org>
 
 	* Release 1.9.7
diff --git a/tools/check-gfrees b/tools/check-gfrees
index 42463bc..76596bd 100644
--- a/tools/check-gfrees
+++ b/tools/check-gfrees
@@ -62,14 +62,14 @@ 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)\s*\(\s*\1\s*\)\s*;/) {
+		    /^\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";
 		    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)\s*\(\s*\1\s*\)\s*;\s*\1\s*=\s*(0|NULL)\s*;\s*}/) {
+		    /^\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*}/) {
 		    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]