From owner-freebsd-arm@FreeBSD.ORG Tue Apr 28 18:26:24 2009 Return-Path: Delivered-To: freebsd-arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 583F9106566B for ; Tue, 28 Apr 2009 18:26:24 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from asmtpout020.mac.com (asmtpout020.mac.com [17.148.16.95]) by mx1.freebsd.org (Postfix) with ESMTP id 44C068FC12 for ; Tue, 28 Apr 2009 18:26:24 +0000 (UTC) (envelope-from cswiger@mac.com) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Received: from cswiger1.apple.com ([17.227.140.124]) by asmtp020.mac.com (Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008; 32bit)) with ESMTPSA id <0KIT009GRN2WB360@asmtp020.mac.com>; Tue, 28 Apr 2009 10:25:44 -0700 (PDT) Message-id: From: Chuck Swiger To: Channa In-reply-to: <515c64960904280252sc9fe2afy24e8db8ab13b13e4@mail.gmail.com> Date: Tue, 28 Apr 2009 10:25:43 -0700 References: <515c64960904280252sc9fe2afy24e8db8ab13b13e4@mail.gmail.com> X-Mailer: Apple Mail (2.930.3) Cc: freebsd-arm@FreeBSD.org, FreeBSD Current Subject: Re: strncmp issue X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2009 18:26:24 -0000 Hi, Channa-- On Apr 28, 2009, at 2:52 AM, Channa wrote: > 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) Thanks for the thought, but strncmp() is defined to take a size_t as the third argument, which is unsigned (ie, uint32_t or uint64_t). Presumably when you tell it to compare with length of -1, that will be converted to UINT_MAX or ULONG_MAX, and strncmp() will run until it finds a null somewhere in one the strings and then return the comparison result. (Or get a segfault, perhaps, if you run off the end into unallocated address space.) Regards, -- -Chuck