[4/6] Remove some dead code from handle_search_memory

Message ID 20200723201216.3932150-5-tromey@adacore.com
State New
Headers show
Series
  • Share memory searching code between gdb and gdbserver
Related show

Commit Message

Tom Tromey July 23, 2020, 8:12 p.m.
handle_search_memory had some code after a call to error.  This code
is dead, and this patch removes it.

2020-07-23  Tom Tromey  <tromey@adacore.com>

	* server.cc (handle_search_memory): Remove dead code.
---
 gdbserver/ChangeLog | 4 ++++
 gdbserver/server.cc | 8 +-------
 2 files changed, 5 insertions(+), 7 deletions(-)

-- 
2.26.2

Comments

Simon Marchi July 30, 2020, 1:04 p.m. | #1
On 2020-07-23 4:12 p.m., Tom Tromey wrote:
> handle_search_memory had some code after a call to error.  This code

> is dead, and this patch removes it.

> 

> 2020-07-23  Tom Tromey  <tromey@adacore.com>

> 

> 	* server.cc (handle_search_memory): Remove dead code.

> ---

>  gdbserver/ChangeLog | 4 ++++

>  gdbserver/server.cc | 8 +-------

>  2 files changed, 5 insertions(+), 7 deletions(-)

> 

> diff --git a/gdbserver/server.cc b/gdbserver/server.cc

> index b050a1d8653..9af747cc0b7 100644

> --- a/gdbserver/server.cc

> +++ b/gdbserver/server.cc

> @@ -1053,11 +1053,7 @@ handle_search_memory (char *own_buf, int packet_len)

>  

>    pattern = (gdb_byte *) malloc (packet_len);

>    if (pattern == NULL)

> -    {

> -      error ("Unable to allocate memory to perform the search");

> -      strcpy (own_buf, "E00");

> -      return;

> -    }

> +    error ("Unable to allocate memory to perform the search");


Would you mind adding an empty line after this to visually separate it from the next block?

Or, can we use xmalloc/gdb::byte_vector and just not have this check?

Simon

Patch

diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index b050a1d8653..9af747cc0b7 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1053,11 +1053,7 @@  handle_search_memory (char *own_buf, int packet_len)
 
   pattern = (gdb_byte *) malloc (packet_len);
   if (pattern == NULL)
-    {
-      error ("Unable to allocate memory to perform the search");
-      strcpy (own_buf, "E00");
-      return;
-    }
+    error ("Unable to allocate memory to perform the search");
   if (decode_search_memory_packet (own_buf + cmd_name_len,
 				   packet_len - cmd_name_len,
 				   &start_addr, &search_space_len,
@@ -1065,8 +1061,6 @@  handle_search_memory (char *own_buf, int packet_len)
     {
       free (pattern);
       error ("Error in parsing qSearch:memory packet");
-      strcpy (own_buf, "E00");
-      return;
     }
 
   auto read_memory = [=] (CORE_ADDR addr, gdb_byte *result, size_t len)