This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[OB PATCH] Rearrange awkwardly-nested conditionals
- From: Gary Benson <gbenson at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 6 Aug 2014 14:04:08 +0100
- Subject: [OB PATCH] Rearrange awkwardly-nested conditionals
- Authentication-results: sourceware.org; auth=none
- References: <1407328928-11952-1-git-send-email-gbenson at redhat dot com>
Sorry, I omitted the "OB" from the subject.
For the record, I pushed this as obvious.
Thanks,
Gary
Gary Benson wrote:
> gdbserver's init_register_cache has some preprocessor conditionals
> awkwardly nested around an if..else block. This commit moves the
> conditionals inside the braces to make the code more readable.
>
> gdb/gdbserver/
> 2014-08-06 Gary Benson <gbenson@redhat.com>
>
> * regcache.c (init_register_cache): Move conditionals inside if.
> ---
> gdb/gdbserver/ChangeLog | 4 ++++
> gdb/gdbserver/regcache.c | 10 ++++------
> 2 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c
> index bed10b4..db99f8c 100644
> --- a/gdb/gdbserver/regcache.c
> +++ b/gdb/gdbserver/regcache.c
> @@ -117,9 +117,9 @@ init_register_cache (struct regcache *regcache,
> const struct target_desc *tdesc,
> unsigned char *regbuf)
> {
> -#ifndef IN_PROCESS_AGENT
> if (regbuf == NULL)
> {
> +#ifndef IN_PROCESS_AGENT
> /* Make sure to zero-initialize the register cache when it is
> created, in case there are registers the target never
> fetches. This way they'll read as zero instead of
> @@ -129,13 +129,11 @@ init_register_cache (struct regcache *regcache,
> regcache->registers_owned = 1;
> regcache->register_status = xcalloc (1, tdesc->num_registers);
> gdb_assert (REG_UNAVAILABLE == 0);
> - }
> - else
> #else
> - if (regbuf == NULL)
> - fatal ("init_register_cache: can't allocate memory from the heap");
> - else
> + fatal ("init_register_cache: can't allocate memory from the heap");
> #endif
> + }
> + else
> {
> regcache->tdesc = tdesc;
> regcache->registers = regbuf;