From owner-svn-src-head@FreeBSD.ORG Wed Feb 20 09:49:51 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id EC1E7999; Wed, 20 Feb 2013 09:49:51 +0000 (UTC) (envelope-from stefan@fafoe.narf.at) Received: from fep15.mx.upcmail.net (fep15.mx.upcmail.net [62.179.121.35]) by mx1.freebsd.org (Postfix) with ESMTP id 6582DFC5; Wed, 20 Feb 2013 09:49:50 +0000 (UTC) Received: from edge03.upcmail.net ([192.168.13.238]) by viefep15-int.chello.at (InterMail vM.8.01.05.05 201-2260-151-110-20120111) with ESMTP id <20130220094943.UUP15686.viefep15-int.chello.at@edge03.upcmail.net>; Wed, 20 Feb 2013 10:49:43 +0100 Received: from mole.fafoe.narf.at ([80.109.55.137]) by edge03.upcmail.net with edge id 2Zpi1l0152xdvHc03ZpiRj; Wed, 20 Feb 2013 10:49:43 +0100 X-SourceIP: 80.109.55.137 Received: by mole.fafoe.narf.at (Postfix, from userid 1001) id 3EFC56D47C; Wed, 20 Feb 2013 10:49:42 +0100 (CET) Date: Wed, 20 Feb 2013 10:49:42 +0100 From: Stefan Farfeleder To: David Chisnall Subject: Re: svn commit: r247014 - head/lib/libc/stdlib Message-ID: <20130220094941.GA1438@mole.fafoe.narf.at> References: <201302192357.r1JNveLq039940@svn.freebsd.org> <79B2F826-6CB5-4CD5-8C7D-8220833403EF@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <79B2F826-6CB5-4CD5-8C7D-8220833403EF@FreeBSD.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.org, mdf@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Giorgos Keramidas X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2013 09:49:52 -0000 On Wed, Feb 20, 2013 at 09:32:43AM +0000, David Chisnall wrote: > On 20 Feb 2013, at 08:25, mdf@FreeBSD.org wrote: > > > These should be declared const int *. And the cast shouldn't be > > needed in C, since void * can be assigned to any other pointer type. > > In fact, the entire function body can be replaced with: > > return (*(int*)p1 - *(int*)p2); > > qsort doesn't require that you return -1, 0, or 1, it requires you return <0, 0, or >0. The subtraction might overflow and give wrong results. It won't for these specific elements, but it would be a bad example, IMHO. Stefan