RFA: Fix sim scache handling to use unsigned values.
Mike Frysinger
vapier@gentoo.org
Wed Feb 3 18:55:00 GMT 2016
On 03 Feb 2016 16:25, Nick Clifton wrote:
> A recent bug report on the binutils list pointed out that a construct
> like this:
>
> for (i = 1; i; i <<= 1)
>
> can have undefined behaviour if the loop variable is signed and the
> shift operation moves a 1 into the sign bit:
>
> lists.gnu.org/archive/html/bug-binutils/2016-02/msg00006.html
>
> A quick scan of the simulator sources found one place where this
> happens, in common/cgen-scache.c:scache_option_handler(). Looking at
> the code here it seemed to me that the simplest fix is to switch to
> using an unsigned int for the parsed value of the scache size. (A
> negative scache size does not make any sense right ?) I wondered if
> it would be worth using "unsigned long" instead of "unsigned int",
> since there is no strtou() function, but this seemed like overkill.
>
> So I created the patch below. It builds OK, but I am not sure how to
> test it. Any suggestions ?
seems fine
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20160203/2002152b/attachment.sig>
More information about the Gdb-patches
mailing list