This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: catch bug
- To: james chen <james_ch1 at sina dot com>
- Subject: Re: [ECOS] catch bug
- From: Gary Thomas <gthomas at redhat dot com>
- Date: 24 Oct 2001 13:14:13 +0900
- Cc: eCos Discussion <ecos-discuss at sources dot redhat dot com>
- References: <000701c15c3d$8437e2a0$c408aa0a@inc.inventec>
On Wed, 2001-10-24 at 12:39, james chen wrote:
> Hi,
> I have caught a bug in hal/arm/arch/current/src/hal_misc.c. I think that
> it haven't been found because nobody called it. change 'i++' to 'i--", is it
> right?
> Best Regards,
> james
>
> -------------------------------------
> int
> hal_msbindex(int mask)
> {
> int i;
> for (i = 32; i >= 0; i++) {
> ^^^^^^
> ==> i--
> if (mask & (1<<i)) return (i);
> }
> return (-1);
> }
>
Close. Indeed, this function must not get used because it was
quite wrong (two errors!) It will be corrected as:
Index: hal/arm/arch/current/src/hal_misc.c
===================================================================
RCS file: /home/cvs/ecc/ecc/hal/arm/arch/current/src/hal_misc.c,v
retrieving revision 1.40
diff -u -5 -p -r1.40 hal_misc.c
--- hal/arm/arch/current/src/hal_misc.c 16 Jul 2001 13:15:36 -0000 1.40
+++ hal/arm/arch/current/src/hal_misc.c 24 Oct 2001 04:12:32 -0000
@@ -250,11 +250,11 @@ hal_lsbindex(int mask)
int
hal_msbindex(int mask)
{
int i;
- for (i = 32; i >= 0; i++) {
+ for (i = 31; i >= 0; i--) {
if (mask & (1<<i)) return (i);
}
return (-1);
}