From owner-svn-src-stable@FreeBSD.ORG Mon Mar 19 02:59:18 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 59D771065679 for ; Mon, 19 Mar 2012 02:59:18 +0000 (UTC) (envelope-from jhellenthal@dataix.net) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id B89CB8FC1A for ; Mon, 19 Mar 2012 02:59:17 +0000 (UTC) Received: by iahk25 with SMTP id k25so12287722iah.13 for ; Sun, 18 Mar 2012 19:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dataix.net; s=rsa; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to; bh=dfFFFyIlffruE/gLmNJmiSGkmnLlf456JEu319OSom8=; b=eTLdhvQvjY0G6GW/AI0AoLV+H0fKcQmGRkuFGVyGEPvy8OjNyumM1NLxl4x0ZuPpS+ qktXArG/zwdThdmiH+xmqjSx+qJ+zsQ0NHdWGxs09yRU+sRKruaJcSqf8zJulsK6ZRUK U0p1JsE0CLiFxl9Bv6VrJO/+U2UH3qW6j8Edo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:x-gm-message-state; bh=dfFFFyIlffruE/gLmNJmiSGkmnLlf456JEu319OSom8=; b=V2UO7wHItvg6t98ihMTDI0dScD8cATG+b92flUN1s0+bIlMtE28MJeNsqkACfik2fN N3iiK2/0ScUsmQgbTiMjLTSjSRXT6EqL8AiAkfeRVo/zVLmiTXIT7l7u5gWZgkP4TeJX +uvaQhPwkZXA+dVUWAIxRtBf4smsZtpiLBBm7p4E1qBASqrZGUbMtY/rZFI2ik+8LXgN 0BhHxY4P51d14aXTXCDNZoYAG9KJnE+57bN6B36Pbbyei2ihEHnCOwhVlCNu1S7WVBCT NkEq+okPZmlFNPeZyio3mUvxUpKB/8klyyYxIlz+bb1VT1Q/PQrl5TeFpoOf9dah19MT qRag== Received: by 10.50.106.132 with SMTP id gu4mr4904409igb.59.1332125957139; Sun, 18 Mar 2012 19:59:17 -0700 (PDT) Received: from DataIX.net (adsl-99-112-214-41.dsl.klmzmi.sbcglobal.net. [99.112.214.41]) by mx.google.com with ESMTPS id ba4sm7458438igb.14.2012.03.18.19.59.15 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 18 Mar 2012 19:59:16 -0700 (PDT) Received: from DataIX.net (localhost [127.0.0.1]) by DataIX.net (8.14.5/8.14.5) with ESMTP id q2J2xDvV079731 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 18 Mar 2012 22:59:14 -0400 (EDT) (envelope-from jhellenthal@DataIX.net) Received: (from jhellenthal@localhost) by DataIX.net (8.14.5/8.14.5/Submit) id q2J2xD13079708; Sun, 18 Mar 2012 22:59:13 -0400 (EDT) (envelope-from jhellenthal@DataIX.net) Date: Sun, 18 Mar 2012 22:59:13 -0400 From: Jason Hellenthal To: Tim Kientzle Message-ID: <20120319025913.GA29610@DataIX.net> References: <201203190127.q2J1RtgB044557@svn.freebsd.org> <20120319015203.GB13456@DataIX.net> <20120319021724.GC13456@DataIX.net> <264991E4-B083-4E61-9337-E5882DED66C3@kientzle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <264991E4-B083-4E61-9337-E5882DED66C3@kientzle.com> X-Gm-Message-State: ALoCoQkpVDfjFxF/9swnoA3iw6Ri+Vwy4WYCLl78OhTvfYBsqY6pCFRr87B3xvHCaY7OHdAaaC3O Cc: svn-src-stable@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Eitan Adler , svn-src-stable-8@FreeBSD.org Subject: Re: svn commit: r233147 - stable/8/lib/libc/string X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Mar 2012 02:59:18 -0000 On Sun, Mar 18, 2012 at 07:32:04PM -0700, Tim Kientzle wrote: > > On Mar 18, 2012, at 7:17 PM, Jason Hellenthal wrote: > > > > > > > On Sun, Mar 18, 2012 at 09:58:12PM -0400, Eitan Adler wrote: > >> On Sun, Mar 18, 2012 at 9:52 PM, Jason Hellenthal > >> wrote: > >>> > >>> > >>> On Mon, Mar 19, 2012 at 01:27:55AM +0000, Eitan Adler wrote: > >>>> Author: eadler > >>>> Date: Mon Mar 19 01:27:55 2012 > >>>> New Revision: 233147 > >>>> URL: http://svn.freebsd.org/changeset/base/233147 > >>>> > >>>> Log: > >>>> MFC r232503: > >>>> POSIX mandates that swab do nothing when len < 0 > >>>> > >>>> PR: 140690 > >>>> Approved by: cperciva > >>>> > >>>> Modified: stable/8/lib/libc/string/swab.c > >>>> ============================================================================== > >>>> --- stable/8/lib/libc/string/swab.c Mon Mar 19 01:27:30 2012 (r233146) > >>>> +++ stable/8/lib/libc/string/swab.c Mon Mar 19 01:27:55 2012 (r233147) > >>>> @@ -45,6 +45,8 @@ swab(const void * __restrict from, void > >>>> int n; > >>>> char *fp, *tp; > >>>> > >>>> + if (len <= 0) > >>>> + return; > >>> > >>> Does this not test to see if it is also equal to 0(zero) ? > >>> > >>> If I understand the above statement "POSIX mandates that swab do nothing > >>> when len < 0" then the above code should be exactly that ... and not > >>> testing whether it is equal to zero... > >> > >> If the code doesn't check for len <= 0 then it will do something. > >> > > > > To my understanding of the specification it should only return if len is > > negative... 0 is not a negative number. > > >From POSIX: > > The swab() function shall copy nbytes bytes… > > This implies that it does nothing when the argument is zero. > The check for <= 0 is a performance optimization; > otherwise the code will do nothing in a more expensive > fashion. > > > If nbytes is negative, swab() does nothing. > > This states that it does nothing when the argument is less than zero. > > So the change is correct; it covers both cases. > Yes. My point being though the description of this change does not adequately describe both cases. It just simply points to POSIX and saying it should return if negative. IMHO calling things what they are and making that very same change causes less grief. Also the man page specifies len "must be an even number" and by the posix spec it can be an odd number and copies and exchanges nbytes-1 and the disposition of the last byte is unspecified. Sorry but irregular documentation is a pet peeve of mine. -- ;s =;