From owner-svn-src-all@FreeBSD.ORG Wed Feb 20 09:49:44 2013 Return-Path: Delivered-To: svn-src-all@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 C0700843; Wed, 20 Feb 2013 09:49:44 +0000 (UTC) (envelope-from gkeramidas@gmail.com) Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by mx1.freebsd.org (Postfix) with ESMTP id 97CC0FC4; Wed, 20 Feb 2013 09:49:43 +0000 (UTC) Received: by mail-ee0-f49.google.com with SMTP id d4so3915344eek.36 for ; Wed, 20 Feb 2013 01:49:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to; bh=PcrPtzWoUG5efqOafPhM9x0s0aU8qrLNj/QzRxT72Ts=; b=yrE4qw2u52igFFChkKmcTNPpm1XYZ99QTUjNjLrketBVU5pB3kopm/eVpMdiOUrZZg WuS+1D0H2Ns7LQp184H2YIvKZ/tI5vwdKvUmNZ6Pai993zF9Pp1hlNYC28eqL80eE129 0QyKb9B551JI1t2+xqlPr/4xDpxAlq53zlaLxzqxBEJ4VY/JbrbHDyKcLltnp++f9hIW YlzDtKpwp/fjeCC9uL+mOuwG05LKh5tozHYrg1F93q/hZjbzZjNEegx642oPKG9Y53uE ey8QeYJeuP3IW+1V+5w4n/IE/aSMS2Zo1VR4WkC7bYe2Tw+2mZ/OAvEbBnjl2YWRDNt2 MMlw== X-Received: by 10.14.182.137 with SMTP id o9mr67021251eem.13.1361353777128; Wed, 20 Feb 2013 01:49:37 -0800 (PST) Received: from saturn (217-162-217-29.dynamic.hispeed.ch. [217.162.217.29]) by mx.google.com with ESMTPS id u44sm48400183eel.7.2013.02.20.01.49.34 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 20 Feb 2013 01:49:36 -0800 (PST) Sender: Giorgos Keramidas Date: Wed, 20 Feb 2013 10:49:32 +0100 From: Giorgos Keramidas To: David Chisnall Subject: Re: svn commit: r247014 - head/lib/libc/stdlib Message-ID: <20130220094930.GB26651@saturn> References: <201302192357.r1JNveLq039940@svn.freebsd.org> <79B2F826-6CB5-4CD5-8C7D-8220833403EF@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <79B2F826-6CB5-4CD5-8C7D-8220833403EF@FreeBSD.org> Cc: svn-src-head@FreeBSD.org, mdf@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2013 09:49:44 -0000 On 2013-02-20 09:32, 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. That's true. Since we are trying to document the interface, I'd prefer if we don't compress the comparison too much. Would something like this be ok too? int int_compare(const void *p1, const void *p2) { const int *left = p1; const int *right = p2; return (*left - *right); }