diff mbox

[3/7] gdb: Small code restructure for list_command.

Message ID 1c3dd6d5b28b0bb19a0d0b94e83c9182306722ab.1448411121.git.andrew.burgess@embecosm.com
State New
Headers show

Commit Message

Andrew Burgess Nov. 25, 2015, 12:34 a.m. UTC
Move handling of special +/- arguments to the list_command function
inside a single if block, this helps group all related functionality
together.  There should be no user visible changes after this commit.

gdb/ChangeLog:

	* cli/cli-cmds.c (list_command): Move all handling of +/-
	arguments into a single if block.
---
 gdb/ChangeLog      |  5 +++++
 gdb/cli/cli-cmds.c | 34 +++++++++++++++++-----------------
 2 files changed, 22 insertions(+), 17 deletions(-)

Comments

Pedro Alves Nov. 26, 2015, 12:37 p.m. UTC | #1
On 11/25/2015 12:34 AM, Andrew Burgess wrote:
> Move handling of special +/- arguments to the list_command function
> inside a single if block, this helps group all related functionality
> together.  There should be no user visible changes after this commit.
> 
> gdb/ChangeLog:
> 
> 	* cli/cli-cmds.c (list_command): Move all handling of +/-
> 	arguments into a single if block.

OK.

> +      if (arg == NULL || strcmp (arg, "+") == 0)
> +	{
> +	  print_source_lines (cursal.symtab, cursal.line,
> +			      cursal.line + get_lines_to_list (), 0);
> +	  return;
> +	}
>  

...

> +      if (strcmp (arg, "-") == 0)
> +	{
> +	  print_source_lines (cursal.symtab,
> +			      max (get_first_line_listed ()
> +				   - get_lines_to_list (), 1),
> +			      get_first_line_listed (), 0);
> +	  return;
> +	}
>      }

(Seems to me you could hoist the returns out now.)

Thanks,
Pedro Alves
diff mbox

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9c22a9a..a19ed49 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@ 
 2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
 
+	* cli/cli-cmds.c (list_command): Move all handling of +/-
+	arguments into a single if block.
+
+2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
+
 	* cli/cli-cmds.c (list_command): Use NULL instead of 0 when
 	checking pointers.
 
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 841fc55..c47526f 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -932,26 +932,26 @@  list_command (char *arg, int from_tty)
 			      first + get_lines_to_list (), 0);
 	  return;
 	}
-    }
 
-  /* "l" or "l +" lists next ten lines.  */
+      /* "l" or "l +" lists next ten lines.  */
 
-  if (arg == NULL || strcmp (arg, "+") == 0)
-    {
-      print_source_lines (cursal.symtab, cursal.line,
-			  cursal.line + get_lines_to_list (), 0);
-      return;
-    }
+      if (arg == NULL || strcmp (arg, "+") == 0)
+	{
+	  print_source_lines (cursal.symtab, cursal.line,
+			      cursal.line + get_lines_to_list (), 0);
+	  return;
+	}
 
-  /* "l -" lists previous ten lines, the ones before the ten just
-     listed.  */
-  if (strcmp (arg, "-") == 0)
-    {
-      print_source_lines (cursal.symtab,
-			  max (get_first_line_listed () 
-			       - get_lines_to_list (), 1),
-			  get_first_line_listed (), 0);
-      return;
+      /* "l -" lists previous ten lines, the ones before the ten just
+	 listed.  */
+      if (strcmp (arg, "-") == 0)
+	{
+	  print_source_lines (cursal.symtab,
+			      max (get_first_line_listed ()
+				   - get_lines_to_list (), 1),
+			      get_first_line_listed (), 0);
+	  return;
+	}
     }
 
   /* Now if there is only one argument, decode it in SAL