On Wed, Feb 20, 2013 at 09:32:43AM +0000, David Chisnall wrote:
> On 20 Feb 2013, at 08:25, m...@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
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to