Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Handle var_uinteger/var_zuinteger and case var_integer/var_zinteger together.
@ 2012-07-18 12:52 Yao Qi
  2012-07-24 12:51 ` [committed]: " Yao Qi
  2012-07-27 17:40 ` Khoo Yit Phang
  0 siblings, 2 replies; 31+ messages in thread
From: Yao Qi @ 2012-07-18 12:52 UTC (permalink / raw)
  To: gdb-patches

Hi,
Similar to previous patch, this patch is also to handle case
var_uinteger/var_zuinteger and case var_integer/var_zinteger together.
This change removes some duplicated code, and applies range checking
to the value of var_zuinteger and var_zinteger.

Note that my following patches will check the change of command
option for some purpose, so better to handle these case statements
as together we we can.

gdb:

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

	* cli/cli-setshow.c (do_setshow_command): Handle case 'var_uinteger'
	and 'var_zuninteger' together.  Handle case 'var_integer' and
	'var_zinteger' together.
---
 gdb/cli/cli-setshow.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 0f854e5..fabc4d7 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -267,20 +267,22 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
 	  }
 	  break;
 	case var_uinteger:
+	case var_zuinteger:
 	  if (arg == NULL)
 	    error_no_arg (_("integer to set it to."));
 	  *(unsigned int *) c->var = parse_and_eval_long (arg);
-	  if (*(unsigned int *) c->var == 0)
+	  if (c->var_type == var_uinteger && *(unsigned int *) c->var == 0)
 	    *(unsigned int *) c->var = UINT_MAX;
 	  break;
 	case var_integer:
+	case var_zinteger:
 	  {
 	    unsigned int val;
 
 	    if (arg == NULL)
 	      error_no_arg (_("integer to set it to."));
 	    val = parse_and_eval_long (arg);
-	    if (val == 0)
+	    if (val == 0 && c->var_type == var_integer)
 	      *(int *) c->var = INT_MAX;
 	    else if (val >= INT_MAX)
 	      error (_("integer %u out of range"), val);
@@ -288,16 +290,6 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
 	      *(int *) c->var = val;
 	    break;
 	  }
-	case var_zinteger:
-	  if (arg == NULL)
-	    error_no_arg (_("integer to set it to."));
-	  *(int *) c->var = parse_and_eval_long (arg);
-	  break;
-	case var_zuinteger:
-	  if (arg == NULL)
-	    error_no_arg (_("integer to set it to."));
-	  *(unsigned int *) c->var = parse_and_eval_long (arg);
-	  break;
 	case var_enum:
 	  {
 	    int i;
-- 
1.7.7.6


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

end of thread, other threads:[~2013-03-27 12:24 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-18 12:52 [PATCH] Handle var_uinteger/var_zuinteger and case var_integer/var_zinteger together Yao Qi
2012-07-24 12:51 ` [committed]: " Yao Qi
2012-07-27 17:40 ` Khoo Yit Phang
2012-07-29 14:25   ` Yao Qi
2012-08-01 13:56   ` [RFC 0/3] New var_types var_zuinteger_unlimited Yao Qi
2012-08-01 13:56     ` [PATCH 3/3] use zuinteger_unlimited for heuristic-fence-post Yao Qi
2012-08-01 13:56     ` [PATCH 2/3] use zuinteger_unlimited for some remote commands Yao Qi
2012-08-01 13:56     ` [PATCH 1/3] var_zuinteger_unlimited and 'set listsize' Yao Qi
2012-08-01 16:14       ` Eli Zaretskii
2012-08-02  8:34       ` Doug Evans
2012-08-02 12:53         ` Yao Qi
2012-08-13 15:28   ` [RFC 0/3] Get rid of var_integer in CLI Yao Qi
2012-08-13 15:28     ` [PATCH 1/3] var_integer -> var_uinteger Yao Qi
2012-08-23 18:20       ` dje
2012-08-24  6:56         ` Yao Qi
2012-08-24 17:06           ` dje
2012-08-27 10:10             ` Yao Qi
2012-08-27 22:14               ` dje
2012-08-28 14:09                 ` [committed]: " Yao Qi
2013-03-25 22:55                   ` Change "set history size" back to signed (Re: [committed]: [PATCH 1/3] var_integer -> var_uinteger) Pedro Alves
2013-03-26 16:48                     ` Yao Qi
2013-03-26 17:48                       ` Pedro Alves
2013-03-27  8:54                         ` Yao Qi
2013-03-27 17:34                           ` Pedro Alves
2012-08-13 15:28     ` [PATCH 2/3] var_integer -> var_zuinteger_unlimited Yao Qi
2012-08-13 17:54       ` Eli Zaretskii
2012-09-14 18:12       ` Tom Tromey
2012-09-17  8:43         ` [committed]: " Yao Qi
2012-08-13 15:28     ` [PATCH 3/3] comments update Yao Qi
2012-09-14 18:13       ` Tom Tromey
2012-08-22 14:30     ` [ping] : [RFC 0/3] Get rid of var_integer in CLI Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox