From owner-freebsd-current@FreeBSD.ORG Thu Jun 21 17:28:09 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 21D18106564A for ; Thu, 21 Jun 2012 17:28:09 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com [209.85.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id CF7B78FC14 for ; Thu, 21 Jun 2012 17:28:08 +0000 (UTC) Received: by yenl8 with SMTP id l8so841742yen.13 for ; Thu, 21 Jun 2012 10:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=/tVFFuSCRDkRjn/Ju385xBpWS0+YI4b9WPU+4C15MIA=; b=E2DV3m+6pbzlTzAOQ8D9L61Hdy1IVWe/qUgwSbZVsX7s6fP+FrAYYutfW2BlRzf589 bF+b1Sd9bbz3bEka0nEmcocx+gUQoWaeb/EvqJ/6N+csxTTeYAf96RUtiZNntvCCgu2a uozhcyNoij5V50bm8mJUT6jlxgba91WrlypkI9VtXNh/9RLIAYLJXLvGmliO0lfuIHP5 416XWyHNPQ2HrPHFmep2lrk1QQqah6uRzymGN+BCI9qILrOZdpx+r5U5BLDdv5YhDY+f SCZ4JKZ92efVuNjQhQvjYUEumwbiY/xuXPace0HDqwBL/9CRjVvHaO9rcMV+sX4ld6K1 VQpQ== MIME-Version: 1.0 Received: by 10.50.94.166 with SMTP id dd6mr4975513igb.11.1340299681385; Thu, 21 Jun 2012 10:28:01 -0700 (PDT) Received: by 10.64.8.170 with HTTP; Thu, 21 Jun 2012 10:28:01 -0700 (PDT) In-Reply-To: <4FE340FF.80406@gmail.com> References: <4FE315B6.9020102@gmail.com> <4FE340FF.80406@gmail.com> Date: Thu, 21 Jun 2012 21:28:01 +0400 Message-ID: From: Sergey Kandaurov To: David Demelier Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-current@freebsd.org Subject: Re: mbstowcs(3) may not return -1 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 17:28:09 -0000 On 21 June 2012 19:42, David Demelier wrote: > On 21/06/2012 14:55, Sergey Kandaurov wrote: >> >> On 21 June 2012 16:38, David Demelier =A0wrote= : >>> >>> Hello, >>> >>> While reading the manpage of mbstowcs I noticed an error in the RETURN >>> VALUES : >>> >>> =A0 =A0 The mbstowcs() function returns the number of wide characters >>> converted, >>> =A0 =A0 not counting any terminating null wide character, or -1 if an i= nvalid >>> =A0 =A0 multibyte character was encountered. >>> >>> Since size_t is unsigned, it can't returns -1. >> >> >> It returns (size_t)(-1). >> I don't know how is it correct, but this conforms to C spec. >> > > Mm, if I understand well, since it is cast to size_t, I think the return > value will be SIZE_MAX - 1 then, right? No, just SIZE_MAX. There is also remarkable SIZE_T_MAX. It came with 4.4BSD Lite sources under !defined(_POSIX_SOURCE). Later it was converted to be under __POSIX_VISIBLE >=3D 200112 || __XSI_VISIBLE. I hasn't found anything relative in any POSIX editions. I think this was a typo/misunderstanding. Other BSD has put this macro under its corresponding if XBSD_VISIBLE. Therefore I think SIZE_T_MAX should be avoided. --=20 wbr, pluknet