This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[obv] don't check pointer is NULL for xfree.


Hi,
We don't have to check the pointer is NULL for xfree, so this patch is to
remove these checks that I find.  b.t.w, looks c->var will never be NULL,
so some other checks can be removed as well.  Committed.

gdb:

2012-07-20  Yao Qi  <yao@codesourcery.com>

	* cli/cli-setshow.c (do_setshow_command): Don't check pointer is
	NULL for xfree.
---
 gdb/cli/cli-setshow.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 2c2f51a..f5b044b 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -171,16 +171,14 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
 #endif
 	    *q++ = '\0';
 	    new = (char *) xrealloc (new, q - new);
-	    if (*(char **) c->var != NULL)
-	      xfree (*(char **) c->var);
+	    xfree (*(char **) c->var);
 	    *(char **) c->var = new;
 	  }
 	  break;
 	case var_string_noescape:
 	  if (arg == NULL)
 	    arg = "";
-	  if (*(char **) c->var != NULL)
-	    xfree (*(char **) c->var);
+	  xfree (*(char **) c->var);
 	  *(char **) c->var = xstrdup (arg);
 	  break;
 	case var_filename:
@@ -188,8 +186,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
 	    error_no_arg (_("filename to set it to."));
 	  /* FALLTHROUGH */
 	case var_optional_filename:
-	  if (*(char **) c->var != NULL)
-	    xfree (*(char **) c->var);
+	  xfree (*(char **) c->var);
 
 	  if (arg != NULL)
 	    {
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]