This is the mail archive of the gdb-cvs@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]

[binutils-gdb] cli/cli-script.c: Remove some dead NULL checks


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4f8ad951f662864884d4b11315c940c5239a4a89

commit 4f8ad951f662864884d4b11315c940c5239a4a89
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Nov 8 15:26:42 2016 +0000

    cli/cli-script.c: Remove some dead NULL checks
    
    gdb/ChangeLog:
    2016-11-08  Pedro Alves  <palves@redhat.com>
    
    	* cli/cli-script.c (execute_control_command): Assume insert_args
    	never returns NULL.
    	(insert_args): Assume xmalloc never returns NULL.

Diff:
---
 gdb/ChangeLog        |  6 ++++++
 gdb/cli/cli-script.c | 11 -----------
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1b647bb..bc422e5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2016-11-08  Pedro Alves  <palves@redhat.com>
 
+	* cli/cli-script.c (execute_control_command): Assume insert_args
+	never returns NULL.
+	(insert_args): Assume xmalloc never returns NULL.
+
+2016-11-08  Pedro Alves  <palves@redhat.com>
+
 	* Makefile.in (COMMON_OBS): Add utils-selftests.o.
 	* common/common-utils.c (string_printf): New function.
 	* common/common-utils.h: Include <string>.
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 12a976a..e5cf20b 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -458,8 +458,6 @@ execute_control_command (struct command_line *cmd)
     case simple_control:
       /* A simple command, execute it and return.  */
       new_line = insert_args (cmd->line);
-      if (!new_line)
-	break;
       make_cleanup (free_current_contents, &new_line);
       execute_command (new_line, 0);
       ret = cmd->control_type;
@@ -491,8 +489,6 @@ execute_control_command (struct command_line *cmd)
 
 	/* Parse the loop control expression for the while statement.  */
 	new_line = insert_args (cmd->line);
-	if (!new_line)
-	  break;
 	make_cleanup (free_current_contents, &new_line);
 	expr = parse_expression (new_line);
 	make_cleanup (free_current_contents, &expr);
@@ -559,8 +555,6 @@ execute_control_command (struct command_line *cmd)
 	print_command_trace (buffer);
 
 	new_line = insert_args (cmd->line);
-	if (!new_line)
-	  break;
 	make_cleanup (free_current_contents, &new_line);
 	/* Parse the conditional for the if statement.  */
 	expr = parse_expression (new_line);
@@ -604,8 +598,6 @@ execute_control_command (struct command_line *cmd)
 	/* Breakpoint commands list, record the commands in the
 	   breakpoint's command list and return.  */
 	new_line = insert_args (cmd->line);
-	if (!new_line)
-	  break;
 	make_cleanup (free_current_contents, &new_line);
 	ret = commands_from_control_command (new_line, cmd);
 	break;
@@ -831,7 +823,6 @@ insert_args (char *line)
       else if (i >= user_args->count)
 	{
 	  error (_("Missing argument %d in user function."), i);
-	  return NULL;
 	}
       else
 	{
@@ -845,8 +836,6 @@ insert_args (char *line)
 
   /* Allocate space for the new line and fill it in.  */
   new_line = (char *) xmalloc (len + 1);
-  if (new_line == NULL)
-    return NULL;
 
   /* Restore pointer to beginning of old line.  */
   line = save_line;


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