Date: Tue, 28 Apr 2009 08:42:07 -0600 (MDT) From: "M. Warner Losh" <imp@bsdimp.com> To: gavin@freebsd.org Cc: channa.kad@gmail.com, freebsd-arm@freebsd.org Subject: Re: strncmp issue Message-ID: <20090428.084207.-1597329356.imp@bsdimp.com> In-Reply-To: <1240918262.85945.1.camel@buffy.york.ac.uk> References: <515c64960904280252sc9fe2afy24e8db8ab13b13e4@mail.gmail.com> <1240918262.85945.1.camel@buffy.york.ac.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <1240918262.85945.1.camel@buffy.york.ac.uk> Gavin Atkinson <gavin@freebsd.org> writes: : : This probably belongs on the -arm list, which I'm CCing. : : 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 argument: : > 'n' as -1 the return values is '0' instead it should '-1'. : > When the third argument to strncmp is as below: : > : > ret = strncmp("a","b",-1) This is the same as strncnp("a", "b", UMAXINT) because the len argument is "size_t" which is unsigned. : > 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 */ : > subs r2, r2, #1 : > movmi r0, #0 : > 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.? This is a bug in your code not in strncmp. Warner : > Thanks & Regards, : > Channagoud : > _______________________________________________ : > freebsd-current@freebsd.org mailing list : > http://lists.freebsd.org/mailman/listinfo/freebsd-current : > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" : _______________________________________________ : freebsd-arm@freebsd.org mailing list : http://lists.freebsd.org/mailman/listinfo/freebsd-arm : To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" : :
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090428.084207.-1597329356.imp>