all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jim Meyering <jim@meyering.net>
To: Emacs development discussions <emacs-devel@gnu.org>
Subject: Remove useless if-before-free and if-before-xfree tests
Date: Mon, 29 Jun 2009 07:30:59 +0200	[thread overview]
Message-ID: <87d48nvc6k.fsf@meyering.net> (raw)

I removed a bunch of these last year.
Since then, a few have snuck back in, so here's another round.
I've just committed the following two change sets:

From 946385f7a7a6ae08fe37cfeac4e872279a51ce15 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Mon, 29 Jun 2009 07:26:05 +0200
Subject: [PATCH 1/2] Remove useless if-before-free test.

* make-docfile.c (scan_lisp_file): Remove useless test.
---
 lib-src/ChangeLog      |    5 +++++
 lib-src/make-docfile.c |    3 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 2d2956f..590af76 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,8 @@
+2009-06-29  Jim Meyering  <meyering@redhat.com>
+
+	Remove useless if-before-free test.
+	* make-docfile.c (scan_lisp_file): Remove useless test.
+
 2009-06-23  Dan Nicolaescu  <dann@ics.uci.edu>

 	* Makefile.in (movemail.o): Don't pass -Demacs, unused.
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 219e9d2..ad366bb 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -907,8 +907,7 @@ scan_lisp_file (filename, mode)
 	      length--;

 	      /* Read in the contents.  */
-	      if (saved_string != 0)
-		free (saved_string);
+	      free (saved_string);
 	      saved_string = (char *) xmalloc (length);
 	      for (i = 0; i < length; i++)
 		saved_string[i] = getc (infile);
--
1.6.3.3.420.gd4b46


From bf3fe8cb2fd3fba21d99ee9fa35a3f07f3485dc7 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Mon, 29 Jun 2009 07:26:09 +0200
Subject: [PATCH 2/2] Remove useless if-before-xfree test.

* nsfont.m (nsfont_close): Remove useless test.
* term.c (delete_tty): Likewise.
* w32.c (system_process_attributes): Likewise.
* w32font.c (w32font_close): Likewise.
* xfaces.c (x_free_gc): Likewise.
* xselect.c (buffer): Likewise.
---
 src/ChangeLog |   10 ++++++++++
 src/nsfont.m  |    6 ++----
 src/term.c    |    6 ++----
 src/w32.c     |    3 +--
 src/w32font.c |    3 +--
 src/xfaces.c  |    3 +--
 src/xselect.c |    3 +--
 7 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 010f993..d6099ee 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
+2009-06-29  Jim Meyering  <meyering@redhat.com>
+
+	Remove useless if-before-xfree test.
+	* nsfont.m (nsfont_close): Remove useless test.
+	* term.c (delete_tty): Likewise.
+	* w32.c (system_process_attributes): Likewise.
+	* w32font.c (w32font_close): Likewise.
+	* xfaces.c (x_free_gc): Likewise.
+	* xselect.c (buffer): Likewise.
+
 2009-06-28  Andreas Schwab  <schwab@linux-m68k.org>

 	* process.c (send_process): Keep decoded string in a local
diff --git a/src/nsfont.m b/src/nsfont.m
index 68ed1e6..7241af3 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -868,10 +868,8 @@ nsfont_close (FRAME_PTR f, struct font *font)

   for (i =0; i<0x100; i++)
     {
-      if (font_info->glyphs[i])
-        xfree (font_info->glyphs[i]);
-      if (font_info->metrics[i])
-        xfree (font_info->metrics[i]);
+      xfree (font_info->glyphs[i]);
+      xfree (font_info->metrics[i]);
     }
   [font_info->nsfont release];
 #ifdef NS_IMPL_COCOA
diff --git a/src/term.c b/src/term.c
index fc77801..5176214 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4018,10 +4018,8 @@ delete_tty (struct terminal *terminal)

   xfree (tty->old_tty);
   xfree (tty->Wcm);
-  if (tty->termcap_strings_buffer)
-    xfree (tty->termcap_strings_buffer);
-  if (tty->termcap_term_buffer)
-    xfree (tty->termcap_term_buffer);
+  xfree (tty->termcap_strings_buffer);
+  xfree (tty->termcap_term_buffer);

   bzero (tty, sizeof (struct tty_display_info));
   xfree (tty);
diff --git a/src/w32.c b/src/w32.c
index cd95f60..23da0ba 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -3995,8 +3995,7 @@ system_process_attributes (pid)
 		}
 	    }
 	}
-      if (buf)
-	xfree (buf);
+      xfree (buf);
     }
   if (!result)
     {
diff --git a/src/w32font.c b/src/w32font.c
index 4148e87..995500a 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -289,8 +289,7 @@ w32font_close (f, font)
     {
       for (i = 0; i < w32_font->n_cache_blocks; i++)
         {
-          if (w32_font->cached_metrics[i])
-            xfree (w32_font->cached_metrics[i]);
+          xfree (w32_font->cached_metrics[i]);
         }
       xfree (w32_font->cached_metrics);
       w32_font->cached_metrics = NULL;
diff --git a/src/xfaces.c b/src/xfaces.c
index 704d7a9..3faaf24 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -785,8 +785,7 @@ x_free_gc (f, gc)
      struct frame *f;
      GC gc;
 {
-  if (gc)
-      xfree (gc);
+  xfree (gc);
 }
 #endif  /* HAVE_NS */

diff --git a/src/xselect.c b/src/xselect.c
index b9b8e0c..5cf4f74 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2395,8 +2395,7 @@ DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal,

   if (!data || !format)
     {
-      if (data)
-	xfree (data);
+      xfree (data);
       return Qnil;
     }

--
1.6.3.3.420.gd4b46




             reply	other threads:[~2009-06-29  5:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-29  5:30 Jim Meyering [this message]
2009-06-29  7:52 ` Remove useless if-before-free and if-before-xfree tests Kim F. Storm
2009-06-29  8:06   ` Jim Meyering
2009-06-29 23:43     ` Stephen J. Turnbull

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d48nvc6k.fsf@meyering.net \
    --to=jim@meyering.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.