Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Apr 2009 17:29:28 +0530
From:      Channa <channa.kad@gmail.com>
To:        Olivier Houchard <mlfbsd@ci0.org>
Cc:        freebsd-arm@freebsd.org, Gavin Atkinson <gavin@freebsd.org>
Subject:   Re: strncmp issue
Message-ID:  <515c64960904280459p3c2ef8bdu3600157eb0c47bcc@mail.gmail.com>
In-Reply-To: <20090428115510.GA98699@ci0.org>
References:  <515c64960904280252sc9fe2afy24e8db8ab13b13e4@mail.gmail.com> <1240918262.85945.1.camel@buffy.york.ac.uk> <20090428115510.GA98699@ci0.org>

next in thread | previous in thread | raw e-mail | index | archive | help
2009/4/28 Olivier Houchard <mlfbsd@ci0.org>:
>> On Tue, 2009-04-28 at 15:22 +0530, Channa wrote:
>> > Hi,
>> >
>> > I am using the freebsd implementation of strncmp for ARM which is an
>> > assembly implementation.
>> > I have a small doubt, when i tested the strncmp by passing the third a=
rgument:
>> > 'n' as -1 the return values is =A0'0' instead it should '-1'.
>> > When the third argument =A0to strncmp is as below:
>> >
>> > ret =3D strncmp("a","b",-1)
>> >
>> > I think the assembly implementation in
>> > src/lib/libc/arm/string/strncmp.S file needs
>> > to be modified to take care of the above condition.
>> >
>> > In the current implementation
>> > /* if ((len - 1) < 0) return 0 */
>> > =A0 =A0 =A0 =A0 subs =A0 =A0r2, r2, #1
>> > =A0 =A0 =A0 =A0 movmi =A0 r0, #0
>> > =A0 =A0 =A0 =A0 RETc(mi)
>> >
>> > This should be changed to check as below
>> >
>> > /* if ((len ) < 0) return 0 */
>> > /* Assembly code here */
>> >
>> > Could anyone help in solving the above issue.?
>> >
>
> Hi,
>
> This shouldn't be an issue, as the second argument of strncmp is unsigned=
,
> -1 is not a valid value.
>
> Regards,
>
> Olivier
>
Hi,
Thanks for the reply.
True the third argument of strncmp is unsigned but the return value in
the below call to strncmp

ret =3D strncmp("a","b",-1)

is '0' but it should be -1 i suppose.

Please let me know if anything is wrong.

Thanks & Regards,
Channagoud



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?515c64960904280459p3c2ef8bdu3600157eb0c47bcc>