This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 3/4] Handle parse number error in goto_bookmark_command
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Yao Qi <yao at codesourcery dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 5 Mar 2014 06:38:13 -0800
- Subject: Re: [PATCH 3/4] Handle parse number error in goto_bookmark_command
- Authentication-results: sourceware.org; auth=none
- References: <1394023608-10761-1-git-send-email-yao at codesourcery dot com> <1394023608-10761-4-git-send-email-yao at codesourcery dot com>
> (gdb) goto-bookmark 1.1
> goto-bookmark: no bookmark found for '1.1'.
I would use "invalid bookmark number"...
> 2014-03-05 Yao Qi <yao@codesourcery.com>
>
> * reverse.c (goto_bookmark_command): Add local 'p'. Emit error
> early if get_number returns zero. Use 'p' instead of 'args'.
Otherwise, LGTM.
> ---
> gdb/reverse.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/gdb/reverse.c b/gdb/reverse.c
> index 582252c..0ceecf9 100644
> --- a/gdb/reverse.c
> +++ b/gdb/reverse.c
> @@ -250,6 +250,7 @@ goto_bookmark_command (char *args, int from_tty)
> {
> struct bookmark *b;
> unsigned long num;
> + char *p = args;
>
> if (args == NULL || args[0] == '\0')
> error (_("Command requires an argument."));
> @@ -274,6 +275,10 @@ goto_bookmark_command (char *args, int from_tty)
>
> /* General case. Bookmark identified by bookmark number. */
> num = get_number (&args);
> +
> + if (num == 0)
> + error (_("goto-bookmark: no bookmark found for '%s'."), p);
> +
> ALL_BOOKMARKS (b)
> if (b->number == num)
> break;
> @@ -285,7 +290,7 @@ goto_bookmark_command (char *args, int from_tty)
> return;
> }
> /* Not found. */
> - error (_("goto-bookmark: no bookmark found for '%s'."), args);
> + error (_("goto-bookmark: no bookmark found for '%s'."), p);
> }
>
> static int
> --
> 1.7.7.6
--
Joel