public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: remove unnecessary NULL checks before xfree
@ 2020-06-16 19:32 gdb-buildbot
  2020-06-16 19:32 ` Failures on Fedora-x86_64-cc-with-index, branch master gdb-buildbot
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gdb-buildbot @ 2020-06-16 19:32 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT 84d53fa9d281f057af5916f8663bc9a2872c5f6e ***

commit 84d53fa9d281f057af5916f8663bc9a2872c5f6e
Author:     Simon Marchi <simon.marchi@efficios.com>
AuthorDate: Thu May 21 13:12:29 2020 -0400
Commit:     Simon Marchi <simon.marchi@efficios.com>
CommitDate: Thu May 21 13:12:29 2020 -0400

    gdb: remove unnecessary NULL checks before xfree
    
    I was inspired by a series of patches merged by Alan Modra in the other
    projects, so I did the same in GDB with a bit of Coccinelle and grep.
    
    This patch removes the unnecessary NULL checks before calls to xfree.
    They are unnecessary because xfree already does a NULL check.  Since
    free is supposed to handle NULL values correctly, the NULL check in
    xfree itself is also questionable, but I've left it there for now.
    
    gdb/ChangeLog:
    
            * coffread.c (patch_type): Remove NULL check before xfree.
            * corefile.c (set_gnutarget): Likewise.
            * cp-abi.c (set_cp_abi_as_auto_default): Likewise.
            * exec.c (build_section_table): Likewise.
            * remote.c (remote_target::pass_signals): Likewise.
            * utils.c (n_spaces): Likewise.
            * cli/cli-script.c (document_command): Likewise.
            * i386-windows-tdep.c (core_process_module_section): Likewise.
            * linux-fork.c (struct fork_info) <~fork_info>: Likewise.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 38d1897611..4574440578 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2020-05-21  Simon Marchi  <simon.marchi@efficios.com>
+
+	* coffread.c (patch_type): Remove NULL check before xfree.
+	* corefile.c (set_gnutarget): Likewise.
+	* cp-abi.c (set_cp_abi_as_auto_default): Likewise.
+	* exec.c (build_section_table): Likewise.
+	* remote.c (remote_target::pass_signals): Likewise.
+	* utils.c (n_spaces): Likewise.
+	* cli/cli-script.c (document_command): Likewise.
+	* i386-windows-tdep.c (core_process_module_section): Likewise.
+	* linux-fork.c (struct fork_info) <~fork_info>: Likewise.
+
 2020-05-20  Simon Marchi  <simon.marchi@efficios.com>
 
 	* symfile.c (reread_symbols): Clear objfile's section_offsets
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index c9d2378906..90ee67a5f3 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1528,8 +1528,7 @@ document_command (const char *comname, int from_tty)
   counted_command_line doclines = read_command_lines (prompt.c_str (),
 						      from_tty, 0, 0);
 
-  if (c->doc)
-    xfree ((char *) c->doc);
+  xfree ((char *) c->doc);
 
   {
     struct command_line *cl1;
diff --git a/gdb/coffread.c b/gdb/coffread.c
index fc44e53cc4..0f7a6e3e5a 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1467,8 +1467,7 @@ patch_type (struct type *type, struct type *real_type)
     {
       /* The previous copy of TYPE_NAME is allocated by
 	 process_coff_symbol.  */
-      if (target->name ())
-	xfree ((char*) target->name ());
+      xfree ((char *) target->name ());
       target->set_name (xstrdup (real_target->name ()));
     }
 }
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 4ce1bb78f2..996e5301b2 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -472,8 +472,7 @@ complete_set_gnutarget (struct cmd_list_element *cmd,
 void
 set_gnutarget (const char *newtarget)
 {
-  if (gnutarget_string != NULL)
-    xfree (gnutarget_string);
+  xfree (gnutarget_string);
   gnutarget_string = xstrdup (newtarget);
   set_gnutarget_command (NULL, 0, NULL);
 }
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index 6997a7bdbe..3e2edad45c 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -273,10 +273,8 @@ set_cp_abi_as_auto_default (const char *short_name)
 		    _("Cannot find C++ ABI \"%s\" to set it as auto default."),
 		    short_name);
 
-  if (auto_cp_abi.longname != NULL)
-    xfree ((char *) auto_cp_abi.longname);
-  if (auto_cp_abi.doc != NULL)
-    xfree ((char *) auto_cp_abi.doc);
+  xfree ((char *) auto_cp_abi.longname);
+  xfree ((char *) auto_cp_abi.doc);
 
   auto_cp_abi = *abi;
 
diff --git a/gdb/exec.c b/gdb/exec.c
index 93dd157e58..14c77495a3 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -648,8 +648,7 @@ build_section_table (struct bfd *some_bfd, struct target_section **start,
   unsigned count;
 
   count = bfd_count_sections (some_bfd);
-  if (*start)
-    xfree (* start);
+  xfree (*start);
   *start = XNEWVEC (struct target_section, count);
   *end = *start;
   bfd_map_over_sections (some_bfd, add_to_section_table, (char *) end);
diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c
index 7233b1f28f..f5965399ab 100644
--- a/gdb/i386-windows-tdep.c
+++ b/gdb/i386-windows-tdep.c
@@ -142,8 +142,7 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
   data->module_count++;
 
 out:
-  if (buf)
-    xfree (buf);
+  xfree (buf);
   return;
 }
 
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 2233d4429c..e232d9c263 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -61,8 +61,8 @@ struct fork_info
 
     if (savedregs)
       delete savedregs;
-    if (filepos)
-      xfree (filepos);
+
+    xfree (filepos);
   }
 
   ptid_t ptid = null_ptid;
diff --git a/gdb/remote.c b/gdb/remote.c
index 312a03c8fb..c73eb6e9e1 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2615,8 +2615,7 @@ remote_target::pass_signals (gdb::array_view<const unsigned char> pass_signals)
 	  putpkt (pass_packet);
 	  getpkt (&rs->buf, 0);
 	  packet_ok (rs->buf, &remote_protocol_packets[PACKET_QPassSignals]);
-	  if (rs->last_pass_packet)
-	    xfree (rs->last_pass_packet);
+	  xfree (rs->last_pass_packet);
 	  rs->last_pass_packet = pass_packet;
 	}
       else
diff --git a/gdb/symfile.c b/gdb/symfile.c
index b02a923566..b29f864b37 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3404,8 +3404,7 @@ enum ovly_index
 static void
 simple_free_overlay_table (void)
 {
-  if (cache_ovly_table)
-    xfree (cache_ovly_table);
+  xfree (cache_ovly_table);
   cache_novlys = 0;
   cache_ovly_table = NULL;
   cache_ovly_table_base = 0;
diff --git a/gdb/utils.c b/gdb/utils.c
index 989b13d0e0..d2290c30a7 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2260,8 +2260,7 @@ n_spaces (int n)
 
   if (n > max_spaces)
     {
-      if (spaces)
-	xfree (spaces);
+      xfree (spaces);
       spaces = (char *) xmalloc (n + 1);
       for (t = spaces + n; t != spaces;)
 	*--t = ' ';


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-06-16 21:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16 19:32 [binutils-gdb] gdb: remove unnecessary NULL checks before xfree gdb-buildbot
2020-06-16 19:32 ` Failures on Fedora-x86_64-cc-with-index, branch master gdb-buildbot
2020-06-16 19:42 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2020-06-16 20:07 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-06-16 20:26 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2020-06-16 20:54 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-06-16 21:01 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2020-06-16 21:31 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).