This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] gdb/hppa-tdep.c: Fix a logical typo bug found by compiler warning
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Chen Gang <gang dot chen dot 5i5j at gmail dot com>
- Cc: Andreas Schwab <schwab at linux-m68k dot org>, gdb-patches at sourceware dot org
- Date: Wed, 15 Oct 2014 08:00:49 -0700
- Subject: Re: [PATCH] gdb/hppa-tdep.c: Fix a logical typo bug found by compiler warning
- Authentication-results: sourceware.org; auth=none
- References: <543D93DD dot 5000906 at gmail dot com> <87d29uxrvg dot fsf at igel dot home> <543D98F3 dot 2030009 at gmail dot com>
> On 10/15/2014 05:29 AM, Andreas Schwab wrote:
> > Chen Gang <gang.chen.5i5j@gmail.com> writes:
> >
> >> && (((inst >> 6) & 0xf) == 0x8
> >> - || (inst >> 6) & 0xf) == 0x9))
> >> + || ((inst >> 6) & 0xf) == 0x9)))
> >
> > ((inst >> 6) & 0xe) == 8
> >
> > Andreas.
> >
>
> I guess, your fixing may like below, which will be a different logical
> working flow.
I think Andreas is telling you that...
((inst >> 6) & 0xf) == 0x8
|| ((inst >> 6) & 0xf) == 0x9
... is logically equivalent to ...
((inst >> 6) & 0xe) == 8
In other word, if it does not matter if bit 7 is set or not
(the difference between 0x8 and 0x9) all you have to do is mask it.
That way, you test both conditions with one comparison instead of 2.
--
Joel